~pedro-q/account-payment/account-payment-sepa-7.0

« back to all changes in this revision

Viewing changes to account_payment_sepa_credit_transfer/account_banking_sepa.py

  • Committer: Ignacio Ibeas - Acysos S.L.
  • Date: 2014-01-25 13:30:35 UTC
  • Revision ID: ignacio@acysos.com-20140125133035-46kipms7z97u825v
[ADD] SEPA modules ported from Banking Addons to Account Payment Extension

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
from openerp.addons.decimal_precision import decimal_precision as dp
 
24
from unidecode import unidecode
 
25
 
 
26
 
 
27
class banking_export_sepa(orm.Model):
 
28
    '''SEPA export'''
 
29
    _name = 'banking.export.sepa'
 
30
    _description = __doc__
 
31
    _rec_name = 'filename'
 
32
 
 
33
    def _generate_filename(self, cr, uid, ids, name, arg, context=None):
 
34
        res = {}
 
35
        for sepa_file in self.browse(cr, uid, ids, context=context):
 
36
            ref = sepa_file.payment_order_ids[0].reference
 
37
            if ref:
 
38
                label = unidecode(ref.replace('/', '-'))
 
39
            else:
 
40
                label = 'error'
 
41
            res[sepa_file.id] = 'sct_%s.xml' % label
 
42
        return res
 
43
 
 
44
    _columns = {
 
45
        'payment_order_ids': fields.many2many(
 
46
            'payment.order',
 
47
            'account_payment_order_sepa_rel',
 
48
            'banking_export_sepa_id', 'account_order_id',
 
49
            'Payment Orders',
 
50
            readonly=True),
 
51
        'nb_transactions': fields.integer(
 
52
            'Number of Transactions', readonly=True),
 
53
        'total_amount': fields.float(
 
54
            'Total Amount', digits_compute=dp.get_precision('Account'),
 
55
            readonly=True),
 
56
        'batch_booking': fields.boolean(
 
57
            'Batch Booking', readonly=True,
 
58
            help="If true, the bank statement will display only one debit "
 
59
            "line for all the wire transfers of the SEPA XML file ; "
 
60
            "if false, the bank statement will display one debit line "
 
61
            "per wire transfer of the SEPA XML file."),
 
62
        'charge_bearer': fields.selection([
 
63
            ('SLEV', 'Following Service Level'),
 
64
            ('SHAR', 'Shared'),
 
65
            ('CRED', 'Borne by Creditor'),
 
66
            ('DEBT', 'Borne by Debtor'),
 
67
            ], 'Charge Bearer', readonly=True,
 
68
            help="Following service level : transaction charges are to be "
 
69
            "applied following the rules agreed in the service level and/or "
 
70
            "scheme (SEPA Core messages must use this). Shared : "
 
71
            "transaction charges on the creditor side are to be borne by "
 
72
            "the creditor, transaction charges on the debtor side are to "
 
73
            "be borne by the debtor. Borne by creditor : all transaction "
 
74
            "charges are to be borne by the creditor. Borne by debtor : "
 
75
            "all transaction charges are to be borne by the debtor."),
 
76
        'create_date': fields.datetime('Generation Date', readonly=True),
 
77
        'file': fields.binary('SEPA XML File', readonly=True),
 
78
        'filename': fields.function(
 
79
            _generate_filename, type='char', size=256, string='Filename',
 
80
            readonly=True),
 
81
        'state': fields.selection([
 
82
            ('draft', 'Draft'),
 
83
            ('sent', 'Sent'),
 
84
            ('done', 'Reconciled'),
 
85
            ], 'State', readonly=True),
 
86
    }
 
87
 
 
88
    _defaults = {
 
89
        'state': 'draft',
 
90
    }