~therp-nl/banking-addons/6.1-lp778668-Italian_IBAN_format

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
##############################################################################
#
#    Copyright (C) 2009 EduSense BV (<http://www.edusense.nl>).
#    All Rights Reserved
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from osv import osv, fields
from datetime import date
from tools.translate import _

class clieop_export(osv.osv):
    '''ClieOp3 Export'''
    _name = 'banking.export.clieop'
    _description = __doc__
    _rec_name = 'identification'

    _columns = {
        'payment_order_ids': fields.many2many(
            'payment.order',
            'account_payment_order_clieop_rel',
            'banking_export_clieop_id', 'account_order_id',
            'Payment Orders',
            readonly=True),
        'testcode':
            fields.selection([('T', _('Yes')), ('P', _('No'))],
                             'Test Run', readonly=True),
        'daynumber':
            fields.integer('ClieOp Transaction nr of the Day', readonly=True),
        'duplicates':
            fields.integer('Number of Duplicates', readonly=True),
        'prefered_date':
            fields.date('Prefered Processing Date',readonly=True),
        'no_transactions':
            fields.integer('Number of Transactions', readonly=True),
        'check_no_accounts':
            fields.char('Check Number Accounts', size=5, readonly=True),
        'total_amount':
            fields.float('Total Amount', readonly=True),
        'identification':
            fields.char('Identification', size=6, readonly=True, select=True),
        'filetype':
            fields.selection([
                ('CREDBET', 'Payment Batch'),
                ('SALARIS', 'Salary Payment Batch'),
                ('INCASSO', 'Direct Debit Batch'),
                ], 'File Type', size=7, readonly=True, select=True),
        'date_generated':
            fields.datetime('Generation Date', readonly=True, select=True),
        'file':
            fields.binary('ClieOp File', readonly=True),
        'state':
            fields.selection([
                ('draft', 'Draft'),
                ('sent', 'Sent'),
                ('done', 'Reconciled'),
            ], 'State', readonly=True),
    }
    def _get_daynr(self, cursor, uid, ids, context):
        '''
        Return highest day number
        '''
        last = cursor.execute('SELECT max(daynumber) '
                              'FROM banking_export_clieop '
                              'WHERE date_generated = "%s"' % 
                              date.today().strftime('%Y-%m-%d')
                             ).fetchone()
        if last:
            return int(last) +1
        return 1

    _defaults = {
        'date_generated': lambda *a: date.today().strftime('%Y-%m-%d'),
        'duplicates': lambda *a: 1,
        'state': lambda *a: 'draft',
        'daynumber': _get_daynr,
    }
clieop_export()

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: