~banking-addons-team/banking-addons/banking-addons-70

« back to all changes in this revision

Viewing changes to account_banking_sepa_credit_transfer/account_banking_sepa.py

[ADD] account_banking_sepa_credit_transfer implementing SEPA SCT pain
(cherrypicked for 7.0)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
##############################################################################
 
2
#
 
3
#    SEPA Credit Transfer module for OpenERP
 
4
#    Copyright (C) 2010-2013 Akretion (http://www.akretion.com)
 
5
#    @author: Alexis de Lattre <alexis.delattre@akretion.com>
 
6
#
 
7
#    This program is free software: you can redistribute it and/or modify
 
8
#    it under the terms of the GNU Affero General Public License as
 
9
#    published by the Free Software Foundation, either version 3 of the
 
10
#    License, or (at your option) any later version.
 
11
#
 
12
#    This program is distributed in the hope that it will be useful,
 
13
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
#    GNU Affero General Public License for more details.
 
16
#
 
17
#    You should have received a copy of the GNU Affero General Public License
 
18
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
#
 
20
##############################################################################
 
21
 
 
22
from openerp.osv import orm, fields
 
23
import time
 
24
from openerp.tools.translate import _
 
25
from openerp.addons.decimal_precision import decimal_precision as dp
 
26
 
 
27
 
 
28
class banking_export_sepa(orm.Model):
 
29
    '''SEPA export'''
 
30
    _name = 'banking.export.sepa'
 
31
    _description = __doc__
 
32
    _rec_name = 'msg_identification'
 
33
 
 
34
    def _generate_filename(self, cr, uid, ids, name, arg, context=None):
 
35
        res = {}
 
36
        for sepa_file in self.browse(cr, uid, ids, context=context):
 
37
            res[sepa_file.id] = 'sepa_' + (sepa_file.msg_identification or '') + '.xml'
 
38
        return res
 
39
 
 
40
    _columns = {
 
41
        'payment_order_ids': fields.many2many(
 
42
            'payment.order',
 
43
            'account_payment_order_sepa_rel',
 
44
            'banking_export_sepa_id', 'account_order_id',
 
45
            'Payment orders',
 
46
            readonly=True),
 
47
        'prefered_exec_date': fields.date('Prefered execution date', readonly=True),
 
48
        'nb_transactions': fields.integer('Number of transactions', readonly=True),
 
49
        'total_amount': fields.float('Total amount',
 
50
            digits_compute=dp.get_precision('Account'), readonly=True),
 
51
        'msg_identification': fields.char('Message identification', size=35,
 
52
            readonly=True),
 
53
        'batch_booking': fields.boolean('Batch booking', readonly=True,
 
54
            help="If true, the bank statement will display only one debit line for all the wire transfers of the SEPA XML file ; if false, the bank statement will display one debit line per wire transfer of the SEPA XML file."),
 
55
        'charge_bearer': fields.selection([
 
56
            ('SHAR', 'Shared'),
 
57
            ('CRED', 'Borne by creditor'),
 
58
            ('DEBT', 'Borne by debtor'),
 
59
            ('SLEV', 'Following service level'),
 
60
            ], 'Charge bearer', readonly=True,
 
61
            help='Shared : transaction charges on the sender side are to be borne by the debtor, transaction charges on the receiver side are to be borne by the creditor (most transfers use this). Borne by creditor : all transaction charges are to be borne by the creditor. Borne by debtor : all transaction charges are to be borne by the debtor. Following service level : transaction charges are to be applied following the rules agreed in the service level and/or scheme.'),
 
62
        'generation_date': fields.datetime('Generation date',
 
63
            readonly=True),
 
64
        'file': fields.binary('SEPA XML file', readonly=True),
 
65
        'filename': fields.function(_generate_filename, type='char', size=256,
 
66
            method=True, string='Filename', readonly=True),
 
67
        'state': fields.selection([
 
68
                ('draft', 'Draft'),
 
69
                ('sent', 'Sent'),
 
70
                ('done', 'Reconciled'),
 
71
            ], 'State', readonly=True),
 
72
    }
 
73
 
 
74
    _defaults = {
 
75
        'generation_date': fields.date.context_today,
 
76
        'state': 'draft',
 
77
    }