1
# -*- encoding: utf-8 -*-
2
##############################################################################
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)
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.
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.
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/>.
23
##############################################################################
25
from osv import osv, fields
28
class res_company(osv.osv):
29
_inherit = 'res.company'
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."),
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
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
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
63
company_id = self._company_default_get(
64
cr, uid, 'res.company', context=context)
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(
70
return initiating_party_issuer
72
def _initiating_party_issuer_def(self, cr, uid, context=None):
73
return self._initiating_party_issuer_default(
74
cr, uid, context=context)
77
'initiating_party_issuer': _initiating_party_issuer_def,