~openerp-sepa-team/sepa-tools/6.0

« back to all changes in this revision

Viewing changes to account_payment_pain_base/company.py

  • Committer: Ignacio Ibeas - Acysos S.L.
  • Date: 2014-02-11 18:29:05 UTC
  • Revision ID: ignacio@acysos.com-20140211182905-bzlhkh052cnc0qfw
[ADD] Account Payment SEPA: modules SEPA for account_paymnt_extension adapted from banking addons

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    PAIN Base module for OpenERP
 
5
#    Copyright (C) 2013 Akretion (http://www.akretion.com)
 
6
#    Copyright (C) 2013 Noviat (http://www.noviat.com)
 
7
#    @author: Alexis de Lattre <alexis.delattre@akretion.com>
 
8
#    @author: Luc de Meyer (Noviat)
 
9
#
 
10
#    This program is free software: you can redistribute it and/or modify
 
11
#    it under the terms of the GNU Affero General Public License as
 
12
#    published by the Free Software Foundation, either version 3 of the
 
13
#    License, or (at your option) any later version.
 
14
#
 
15
#    This program is distributed in the hope that it will be useful,
 
16
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
#    GNU Affero General Public License for more details.
 
19
#
 
20
#    You should have received a copy of the GNU Affero General Public License
 
21
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
22
#
 
23
##############################################################################
 
24
 
 
25
from osv import osv, fields
 
26
 
 
27
 
 
28
class res_company(osv.osv):
 
29
    _inherit = 'res.company'
 
30
 
 
31
    _columns = {
 
32
        'initiating_party_issuer': fields.char(
 
33
            'Initiating Party Issuer', size=35,
 
34
            help="This will be used as the 'Initiating Party Issuer' in the "
 
35
            "PAIN files generated by OpenERP."),
 
36
    }
 
37
 
 
38
    def _get_initiating_party_identifier(
 
39
            self, cr, uid, company_id, context=None):
 
40
        '''The code here may be different from one country to another.
 
41
        If you need to add support for an additionnal country, you can
 
42
        contribute your code here or inherit this function in the
 
43
        localization modules for your country'''
 
44
        assert isinstance(company_id, int), 'Only one company ID'
 
45
        company = self.browse(cr, uid, company_id, context=context)
 
46
        company_vat = company.partner_id.vat
 
47
        party_identifier = False
 
48
        if company_vat and company_vat[0:2].upper() in ['BE']:
 
49
            party_identifier = company_vat[2:].replace(' ', '')
 
50
        return party_identifier
 
51
 
 
52
    def _initiating_party_issuer_default(self, cr, uid, context=None):
 
53
        '''If you need to add support for an additionnal country, you can
 
54
        add an entry in the dict "party_issuer_per_country" here
 
55
        or inherit this function in the localization modules for
 
56
        your country'''
 
57
        initiating_party_issuer = ''
 
58
        # If your country require the 'Initiating Party Issuer', you should
 
59
        # contribute the entry for your country in the dict below
 
60
        party_issuer_per_country = {
 
61
            'BE': 'KBO-BCE',  # KBO-BCE = the registry of companies in Belgium
 
62
        }
 
63
        company_id = self._company_default_get(
 
64
            cr, uid, 'res.company', context=context)
 
65
        if company_id:
 
66
            company = self.browse(cr, uid, company_id, context=context)
 
67
            country_code = company.partner_id.country.code
 
68
            initiating_party_issuer = party_issuer_per_country.get(
 
69
                country_code, '')
 
70
        return initiating_party_issuer
 
71
 
 
72
    def _initiating_party_issuer_def(self, cr, uid, context=None):
 
73
        return self._initiating_party_issuer_default(
 
74
            cr, uid, context=context)
 
75
 
 
76
    _defaults = {
 
77
        'initiating_party_issuer': _initiating_party_issuer_def,
 
78
    }
 
79
 
 
80
res_company()