[MERGE] l10n_ch. Merged new fixes and enhancements made by c2c. Thanks for the contribution
bzr revid: qdp-launchpad@openerp.com-20120206114533-fvh7kagc8r8ln1hb
This commit is contained in:
commit
f06bde8978
|
@ -19,8 +19,7 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
{
|
{"name" : "Switzerland - Accounting",
|
||||||
"name" : "Switzerland - Accounting",
|
|
||||||
"description" : """
|
"description" : """
|
||||||
Swiss localisation :
|
Swiss localisation :
|
||||||
- DTA generation for a lot of payment types
|
- DTA generation for a lot of payment types
|
||||||
|
@ -61,51 +60,47 @@ TODO :
|
||||||
|
|
||||||
|
|
||||||
""",
|
""",
|
||||||
"version" : "6.1",
|
"version": "6.1",
|
||||||
"author" : "Camptocamp",
|
"author": "Camptocamp",
|
||||||
'category': 'Localization/Account Charts',
|
'category': 'Localization/Account Charts',
|
||||||
"website": "http://www.camptocamp.com",
|
"website": "http://www.camptocamp.com",
|
||||||
|
|
||||||
"depends" : [
|
"depends" : [ "account_cancel",
|
||||||
"account_cancel",
|
|
||||||
"base_iban",
|
"base_iban",
|
||||||
"account_payment",
|
"account_payment",
|
||||||
"account_voucher",
|
"account_voucher",
|
||||||
"report_webkit",
|
"report_webkit",
|
||||||
],
|
"l10n_multilang"],
|
||||||
"init_xml" : [
|
|
||||||
"dta_data.xml",
|
"init_xml": ["dta_data.xml",
|
||||||
"journal_data.xml",
|
"journal_data.xml",
|
||||||
#FR sterchi chart data
|
#FR sterchi chart data
|
||||||
'sterchi_chart/account.xml',
|
'sterchi_chart/account.xml',
|
||||||
'sterchi_chart/vat.xml', #JUST REMOVE THIS FILE WHEN OBSOLETE. ALL REQUIERED DATA IN VAT2011.XML
|
'sterchi_chart/vat.xml',
|
||||||
'sterchi_chart/vat2011.xml',
|
'sterchi_chart/vat2011.xml',
|
||||||
'sterchi_chart/fiscal_position.xml',
|
'sterchi_chart/fiscal_position.xml'],
|
||||||
],
|
|
||||||
"demo_xml" : [
|
"demo_xml": ["demo/demo.xml",
|
||||||
"demo/demo.xml",
|
"demo/dta_demo.xml"],
|
||||||
"demo/dta_demo.xml",
|
|
||||||
],
|
"update_xml": ["wizard.xml",
|
||||||
"update_xml" : [
|
|
||||||
"wizard.xml",
|
|
||||||
"wizard/bvr_import_view.xml",
|
"wizard/bvr_import_view.xml",
|
||||||
"wizard/create_dta_view.xml",
|
"wizard/create_dta_view.xml",
|
||||||
"company_view.xml",
|
"company_view.xml",
|
||||||
"account_invoice.xml",
|
"account_invoice.xml",
|
||||||
"bank_view.xml",
|
"bank_view.xml",
|
||||||
"security/ir.model.access.csv",
|
"security/ir.model.access.csv",
|
||||||
"report/report_webkit_html_view.xml",
|
"report/report_webkit_html_view.xml"],
|
||||||
],
|
|
||||||
'test' : [
|
"test": ['test/l10n_ch_report.yml',
|
||||||
'test/l10n_ch_report.yml',
|
|
||||||
'test/l10n_ch_dta.yml',
|
'test/l10n_ch_dta.yml',
|
||||||
#TODO: uncomment the 2 following tests once they are fixed
|
#TODO: uncomment the 2 following tests once they are fixed
|
||||||
#'test/l10n_ch_v11.yml',
|
#'test/l10n_ch_v11.yml',
|
||||||
#'test/l10n_ch_v11_part.yml',
|
#'test/l10n_ch_v11_part.yml'
|
||||||
],
|
],
|
||||||
|
|
||||||
"auto_install": False,
|
"auto_install": False,
|
||||||
"installable": True,
|
"installable": True,
|
||||||
"certificate" : "001103836064567088989",
|
"certificate": "001103836064567088989",
|
||||||
'images': ['images/config_chart_l10n_ch.jpeg','images/l10n_ch_chart.jpeg'],
|
'images': ['images/config_chart_l10n_ch.jpeg','images/l10n_ch_chart.jpeg']}
|
||||||
}
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
from tools.translate import _
|
from tools.translate import _
|
||||||
from osv import fields, osv
|
from osv import fields, osv
|
||||||
|
import re
|
||||||
|
|
||||||
class Bank(osv.osv):
|
class Bank(osv.osv):
|
||||||
"""Inherit res.bank class in order to add swiss specific field"""
|
"""Inherit res.bank class in order to add swiss specific field"""
|
||||||
|
@ -42,8 +43,8 @@ class ResPartnerBank(osv.osv):
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.char('Description', size=128, required=True),
|
'name': fields.char('Description', size=128, required=True),
|
||||||
'post_number': fields.char('Post number', size=64),
|
'post_number': fields.char('Post number', size=64, help="Postal number 0x-xxxxxx-x or xxxxx"),
|
||||||
'bvr_adherent_num': fields.char('BVR adherent number', size=11),
|
'bvr_adherent_num': fields.char('Bank BVR adherent number', size=11, help="Your Bank adherent number to be printed in references of your BVR. This is not a postal account number."),
|
||||||
'dta_code': fields.char('DTA code', size=5),
|
'dta_code': fields.char('DTA code', size=5),
|
||||||
'print_bank': fields.boolean('Print Bank on BVR'),
|
'print_bank': fields.boolean('Print Bank on BVR'),
|
||||||
'print_account': fields.boolean('Print Account Number on BVR'),
|
'print_account': fields.boolean('Print Account Number on BVR'),
|
||||||
|
@ -68,11 +69,50 @@ class ResPartnerBank(osv.osv):
|
||||||
|
|
||||||
def _prepare_name(self, bank):
|
def _prepare_name(self, bank):
|
||||||
"Hook to get bank number of bank account"
|
"Hook to get bank number of bank account"
|
||||||
res = super(ResPartnerBank, self)._prepare_name(bank)
|
res = u''
|
||||||
|
if bank.acc_number:
|
||||||
|
res = super(ResPartnerBank, self)._prepare_name(bank) or u''
|
||||||
if bank.post_number:
|
if bank.post_number:
|
||||||
|
if res:
|
||||||
res = u"%s - %s" % (res, bank.post_number)
|
res = u"%s - %s" % (res, bank.post_number)
|
||||||
|
else:
|
||||||
|
res = bank.post_number
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def _check_9_pos_postal_num(self, number):
|
||||||
|
"""
|
||||||
|
check if a postal number in format xx-xxxxxx-x is correct,
|
||||||
|
return true if it matches the pattern
|
||||||
|
and if check sum mod10 is ok
|
||||||
|
"""
|
||||||
|
from tools import mod10r
|
||||||
|
pattern = r'^[0-9]{2}-[0-9]{1,6}-[0-9]$'
|
||||||
|
if not re.search(pattern, number):
|
||||||
|
return False
|
||||||
|
num, checksum = (number.replace('-','')[:-1], number[-1:])
|
||||||
|
return mod10r(num)[-1:] == checksum
|
||||||
|
|
||||||
|
|
||||||
|
def _check_5_pos_postal_num(self, number):
|
||||||
|
"""
|
||||||
|
check if a postal number on 5 positions is correct
|
||||||
|
"""
|
||||||
|
pattern = r'^[0-9]{1,5}$'
|
||||||
|
if not re.search(pattern, number):
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def _check_postal_num(self, cursor, uid, ids):
|
||||||
|
banks = self.browse(cursor, uid, ids)
|
||||||
|
for b in banks:
|
||||||
|
return self._check_9_pos_postal_num(b.post_number) or \
|
||||||
|
self._check_5_pos_postal_num(b.post_number)
|
||||||
|
|
||||||
|
|
||||||
|
_constraints = [(_check_postal_num,
|
||||||
|
'Please enter a correct postal number. (01-23456-5 or 12345)',
|
||||||
|
['post_number'])]
|
||||||
|
|
||||||
_sql_constraints = [('bvr_adherent_uniq', 'unique (bvr_adherent_num)',
|
_sql_constraints = [('bvr_adherent_uniq', 'unique (bvr_adherent_num)',
|
||||||
'The BVR adherent number must be unique !')]
|
'The BVR adherent number must be unique !')]
|
||||||
|
|
||||||
|
|
|
@ -130,13 +130,15 @@
|
||||||
</group>
|
</group>
|
||||||
<separator colspan="4" string="Financial institute infos"/>
|
<separator colspan="4" string="Financial institute infos"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="my_bank" attrs="{'invisible': [('company_id', '=', False)]}" colspan="4"/>
|
<group attrs="{'invisible': ['|', ('state', 'not in', ['bvrpost','bvrbank']), ('company_id', '=', False)]}" colspan="4">
|
||||||
|
<field name="my_bank" attrs="{'invisible': [('company_id', '=', False)]}" />
|
||||||
<group string="BVR print options" colspan="4" attrs="{'invisible': [('my_bank', '!=', True)]}" >
|
<group string="BVR print options" colspan="4" attrs="{'invisible': [('my_bank', '!=', True)]}" >
|
||||||
<field name="bvr_adherent_num"/>
|
<field name="bvr_adherent_num" attrs="{'invisible': [('state','!=','bvrbank')]}"/>
|
||||||
<field name="print_bank"/>
|
<field name="print_bank"/>
|
||||||
<field name="print_account"/>
|
<field name="print_account"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
</group>
|
</group>
|
||||||
|
</group>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="bank" />
|
<field name="bank" />
|
||||||
</field>
|
</field>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<field name="acc_number">11-1234-1</field>
|
<field name="acc_number">11-1234-1</field>
|
||||||
<field name="partner_id" ref="base.main_partner"/>
|
<field name="partner_id" ref="base.main_partner"/>
|
||||||
<field name="state">bvrbank</field>
|
<field name="state">bvrbank</field>
|
||||||
<field name="post_number">11-1234-1</field>
|
<field name="post_number">70-004152-8</field>
|
||||||
<field name="bank" ref="main_bank"/>
|
<field name="bank" ref="main_bank"/>
|
||||||
<!-- <field name="iban">CH9100767000S00023455</field> -->
|
<!-- <field name="iban">CH9100767000S00023455</field> -->
|
||||||
<field name="bvr_adherent_num">0000000</field>
|
<field name="bvr_adherent_num">0000000</field>
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<field name="acc_number">123456</field>
|
<field name="acc_number">123456</field>
|
||||||
<field name="partner_id" ref="base.res_partner_agrolait"/>
|
<field name="partner_id" ref="base.res_partner_agrolait"/>
|
||||||
<field name="state">bvrbank</field>
|
<field name="state">bvrbank</field>
|
||||||
<field name="post_number">234567</field>
|
<field name="post_number">01-23456-5</field>
|
||||||
<field name="bank" ref="partner_bank"/>
|
<field name="bank" ref="partner_bank"/>
|
||||||
<!-- <field name="iban">CH9100767000S00023455</field> -->
|
<!-- <field name="iban">CH9100767000S00023455</field> -->
|
||||||
</record>
|
</record>
|
||||||
|
|
|
@ -124,28 +124,24 @@ class l10n_ch_report_webkit_html(report_sxw.rml_parse):
|
||||||
invoice_obj = pool.get('account.invoice')
|
invoice_obj = pool.get('account.invoice')
|
||||||
ids = invoice_ids
|
ids = invoice_ids
|
||||||
for invoice in invoice_obj.browse(cursor, self.uid, ids):
|
for invoice in invoice_obj.browse(cursor, self.uid, ids):
|
||||||
|
invoice_name = "%s %s" %(invoice.name, invoice.number)
|
||||||
if not invoice.partner_bank_id:
|
if not invoice.partner_bank_id:
|
||||||
raise except_osv(_('UserError'),
|
raise except_osv(_('UserError'),
|
||||||
_('No bank specified on invoice:\n' + \
|
_('No bank specified on invoice:\n%s' %(invoice_name)))
|
||||||
invoice_obj.name_get(cursor, self.uid, [invoice.id],
|
|
||||||
context={})[0][1]))
|
|
||||||
if not self._compile_check_bvr.match(
|
if not self._compile_check_bvr.match(
|
||||||
invoice.partner_bank_id.post_number or ''):
|
invoice.partner_bank_id.post_number or ''):
|
||||||
raise except_osv(_('UserError'),
|
raise except_osv(_('UserError'),
|
||||||
_('Your bank BVR number should be of the form 0X-XXX-X! ' +
|
_(('Your bank BVR number should be of the form 0X-XXX-X! '
|
||||||
'Please check your company ' +
|
'Please check your company '
|
||||||
'information for the invoice:\n' +
|
'information for the invoice:\n%s')
|
||||||
invoice_obj.name_get(cursor, self.uid, [invoice.id],
|
%(invoice_name)))
|
||||||
context={})[0][1]))
|
|
||||||
if invoice.partner_bank_id.bvr_adherent_num \
|
if invoice.partner_bank_id.bvr_adherent_num \
|
||||||
and not self._compile_check_bvr_add_num.match(
|
and not self._compile_check_bvr_add_num.match(
|
||||||
invoice.partner_bank_id.bvr_adherent_num):
|
invoice.partner_bank_id.bvr_adherent_num):
|
||||||
raise except_osv(_('UserError'),
|
raise except_osv(_('UserError'),
|
||||||
_('Your bank BVR adherent number must contain exactly seven' +
|
_(('Your bank BVR adherent number must contain only '
|
||||||
'digits!\nPlease check your company ' +
|
'digits!\nPlease check your company '
|
||||||
'information for the invoice:\n' +
|
'information for the invoice:\n%s') %(invoice_name)))
|
||||||
invoice_obj.name_get(cursor, self.uid, [invoice.id],
|
|
||||||
context={})[0][1]))
|
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
class BVRWebKitParser(webkit_report.WebKitParser):
|
class BVRWebKitParser(webkit_report.WebKitParser):
|
||||||
|
|
|
@ -11802,7 +11802,12 @@
|
||||||
<field name="property_account_receivable" ref="ch_1100"/>
|
<field name="property_account_receivable" ref="ch_1100"/>
|
||||||
<field name="property_account_payable" ref="ch_2000"/>
|
<field name="property_account_payable" ref="ch_2000"/>
|
||||||
<field name="property_account_expense_categ" ref="ch_4200"/>
|
<field name="property_account_expense_categ" ref="ch_4200"/>
|
||||||
<field name="property_account_income_categ" ref="ch_1000"/>
|
<field name="property_account_income_categ" ref="ch_3200"/>
|
||||||
|
<field name="property_account_expense" ref="ch_4200"/>
|
||||||
|
<field name="property_account_income" ref="ch_3200"/>
|
||||||
|
<field name="property_account_income_opening" ref="ch_2990"/>
|
||||||
|
<field name="property_account_expense_opening" ref="ch_2990"/>
|
||||||
|
<field name="property_reserve_and_surplus_account" ref="ch_2991"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<!-- journal configuration of account -->
|
<!-- journal configuration of account -->
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
address_contact_id: base.res_partner_address_8
|
address_contact_id: base.res_partner_address_8
|
||||||
address_invoice_id: base.res_partner_address_8
|
address_invoice_id: base.res_partner_address_8
|
||||||
reference_type: bvr
|
reference_type: bvr
|
||||||
reference: 111111111111111111111111111111
|
reference: 11111111111111111111
|
||||||
date_invoice: !eval "'%s-01-01' %(datetime.now().year)"
|
date_invoice: !eval "'%s-01-01' %(datetime.now().year)"
|
||||||
period_id: account.period_1
|
period_id: account.period_1
|
||||||
#invoice_line:
|
#invoice_line:
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
amount_currency: 7000
|
amount_currency: 7000
|
||||||
bank_id: l10n_ch.agro_bank
|
bank_id: l10n_ch.agro_bank
|
||||||
#bank_statement_line_id
|
#bank_statement_line_id
|
||||||
communication: "111111111111111111111111111111"
|
communication: "11111111111111111111"
|
||||||
#communication2
|
#communication2
|
||||||
company_currency: base.EUR
|
company_currency: base.EUR
|
||||||
#create_date
|
#create_date
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
#ml_date_created
|
#ml_date_created
|
||||||
#ml_inv_ref
|
#ml_inv_ref
|
||||||
#ml_maturity_date
|
#ml_maturity_date
|
||||||
move_line_id: !ref {model: account.move.line, search: "[('ref','=','111111111111111111111111111111')]"}
|
move_line_id: !ref {model: account.move.line, search: "[('ref','=','11111111111111111111')]"}
|
||||||
#name (reference)
|
#name (reference)
|
||||||
order_id: dta_payment_order
|
order_id: dta_payment_order
|
||||||
partner_id: base.res_partner_agrolait
|
partner_id: base.res_partner_agrolait
|
||||||
|
@ -152,7 +152,7 @@
|
||||||
# wiz = self.browse(cr, uid, wiz_id)
|
# wiz = self.browse(cr, uid, wiz_id)
|
||||||
#
|
#
|
||||||
# line_obj = self.pool.get('payment.line')
|
# line_obj = self.pool.get('payment.line')
|
||||||
# pay_line_ids = line_obj.search(cr, uid, [('communication','=','111111111111111111111111111111'),('amount','=','7000')])
|
# pay_line_ids = line_obj.search(cr, uid, [('communication','=','11111111111111111111'),('amount','=','7000')])
|
||||||
#
|
#
|
||||||
# data = { 'lines': [(6, 0, [pay_line_ids[0]])],}
|
# data = { 'lines': [(6, 0, [pay_line_ids[0]])],}
|
||||||
# wiz.write(data)
|
# wiz.write(data)
|
||||||
|
|
|
@ -71,6 +71,9 @@ def _import(self, cursor, user, data, context=None):
|
||||||
statement_obj = self.pool.get('account.bank.statement')
|
statement_obj = self.pool.get('account.bank.statement')
|
||||||
property_obj = self.pool.get('ir.property')
|
property_obj = self.pool.get('ir.property')
|
||||||
file = data['form']['file']
|
file = data['form']['file']
|
||||||
|
if not file:
|
||||||
|
raise osv.except_osv(_('UserError'),
|
||||||
|
_('Please select a file first!'))
|
||||||
statement_id = data['id']
|
statement_id = data['id']
|
||||||
records = []
|
records = []
|
||||||
total_amount = 0
|
total_amount = 0
|
||||||
|
@ -239,7 +242,7 @@ def _import(self, cursor, user, data, context=None):
|
||||||
class bvr_import_wizard(osv.osv_memory):
|
class bvr_import_wizard(osv.osv_memory):
|
||||||
_name = 'bvr.import.wizard'
|
_name = 'bvr.import.wizard'
|
||||||
_columns = {
|
_columns = {
|
||||||
'file':fields.binary('BVR File', readonly=True)
|
'file':fields.binary('BVR File')
|
||||||
}
|
}
|
||||||
|
|
||||||
def import_bvr(self, cr, uid, ids, context=None):
|
def import_bvr(self, cr, uid, ids, context=None):
|
||||||
|
|
|
@ -28,6 +28,8 @@ import pooler
|
||||||
from tools.translate import _
|
from tools.translate import _
|
||||||
import unicode2ascii
|
import unicode2ascii
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
TRANS=[
|
TRANS=[
|
||||||
(u'é','e'),
|
(u'é','e'),
|
||||||
(u'è','e'),
|
(u'è','e'),
|
||||||
|
@ -346,6 +348,14 @@ def c_ljust(s, size):
|
||||||
s = s.decode('utf-8').encode('latin1','replace').ljust(size)
|
s = s.decode('utf-8').encode('latin1','replace').ljust(size)
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
def _is_9_pos_bvr_adherent(adherent_num):
|
||||||
|
"""
|
||||||
|
from a bvr adherent number,
|
||||||
|
return true if
|
||||||
|
"""
|
||||||
|
pattern = r'[0-9]{2}-[0-9]{1,6}-[0-9]'
|
||||||
|
return re.search(pattern, adherent_num)
|
||||||
|
|
||||||
def _create_dta(obj, cr, uid, data, context=None):
|
def _create_dta(obj, cr, uid, data, context=None):
|
||||||
v = {}
|
v = {}
|
||||||
v['uid'] = str(uid)
|
v['uid'] = str(uid)
|
||||||
|
@ -435,10 +445,24 @@ def _create_dta(obj, cr, uid, data, context=None):
|
||||||
or False
|
or False
|
||||||
v['partner_bvr'] = pline.bank_id.post_number or ''
|
v['partner_bvr'] = pline.bank_id.post_number or ''
|
||||||
if v['partner_bvr']:
|
if v['partner_bvr']:
|
||||||
v['partner_bvr'] = v['partner_bvr'].replace('-','')
|
is_9_pos_adherent = None
|
||||||
if len(v['partner_bvr']) < 9:
|
# if adherent bvr number is a 9 pos number
|
||||||
v['partner_bvr'] = v['partner_bvr'][:2] + '0' * \
|
# add 0 to fill 2nd part plus remove '-'
|
||||||
(9 - len(v['partner_bvr'])) + v['partner_bvr'][2:]
|
# exemple: 12-567-C becomes 12000567C
|
||||||
|
if _is_9_pos_bvr_adherent(v['partner_bvr']):
|
||||||
|
parts = v['partner_bvr'].split('-')
|
||||||
|
parts[1] = parts[1].rjust(6, '0')
|
||||||
|
v['partner_bvr'] = ''.join(parts)
|
||||||
|
is_9_pos_adherent = True
|
||||||
|
# add 4*0 to bvr adherent number with 5 pos
|
||||||
|
# exemple: 12345 becomes 000012345
|
||||||
|
elif len(v['partner_bvr']) == 5:
|
||||||
|
v['partner_bvr'] = v['partner_bvr'].rjust(9, '0')
|
||||||
|
is_9_pos_adherent = False
|
||||||
|
else:
|
||||||
|
raise osv.except_osv(_('Error'),
|
||||||
|
_('Wrong postal number format.\n'
|
||||||
|
'It must be 12-123456-9 or 12345 format'))
|
||||||
|
|
||||||
if pline.bank_id.bank:
|
if pline.bank_id.bank:
|
||||||
v['partner_bank_city'] = pline.bank_id.bank.city or False
|
v['partner_bank_city'] = pline.bank_id.bank.city or False
|
||||||
|
@ -518,15 +542,39 @@ def _create_dta(obj, cr, uid, data, context=None):
|
||||||
|
|
||||||
elif elec_pay == 'bvrbank' or elec_pay == 'bvrpost':
|
elif elec_pay == 'bvrbank' or elec_pay == 'bvrpost':
|
||||||
from tools import mod10r
|
from tools import mod10r
|
||||||
if v['reference']:
|
if not v['reference']:
|
||||||
v['reference'] = v['reference'].replace(' ',
|
raise osv.except_osv(_('Error'),
|
||||||
'').rjust(27).replace(' ', '0')
|
_('You must provide ' \
|
||||||
if not v['reference'] \
|
'a BVR reference number \n' \
|
||||||
or (mod10r(v['reference'][:-1]) != v['reference'] and \
|
|
||||||
not len(v['reference']) == 15):
|
|
||||||
raise osv.except_osv(_('Error'), _('You must provide ' \
|
|
||||||
'a valid BVR reference number \n' \
|
|
||||||
'for the line: %s') % pline.name)
|
'for the line: %s') % pline.name)
|
||||||
|
v['reference'] = v['reference'].replace(' ', '')
|
||||||
|
if is_9_pos_adherent:
|
||||||
|
if len(v['reference']) > 27:
|
||||||
|
raise osv.except_osv(_('Error'),
|
||||||
|
_('BVR reference number is not valid \n'
|
||||||
|
'for the line: %s. \n'
|
||||||
|
'Reference is too long.') % pline.name)
|
||||||
|
# do a mod10 check
|
||||||
|
if mod10r(v['reference'][:-1]) != v['reference']:
|
||||||
|
raise osv.except_osv(_('Error'),
|
||||||
|
_('BVR reference number is not valid \n'
|
||||||
|
'for the line: %s. \n'
|
||||||
|
'Mod10 check failed') % pline.name)
|
||||||
|
# fill reference with 0
|
||||||
|
v['reference'] = v['reference'].rjust(27, '0')
|
||||||
|
else:
|
||||||
|
# reference of BVR adherent with 5 positions number
|
||||||
|
# have 15 positions references
|
||||||
|
if len(v['reference']) > 15:
|
||||||
|
raise osv.except_osv(_('Error'),
|
||||||
|
_('BVR reference number is not valid \n'
|
||||||
|
'for the line: %s. \n'
|
||||||
|
'Reference is too long '
|
||||||
|
'for this type of beneficiary.') % pline.name)
|
||||||
|
# complete 15 first digit with 0 on left and complete 27 digits with trailing spaces
|
||||||
|
# exemple: 123456 becomes 00000000012345____________
|
||||||
|
v['reference'] = v['reference'].rjust(15, '0').ljust(27, ' ')
|
||||||
|
|
||||||
if not v['partner_bvr']:
|
if not v['partner_bvr']:
|
||||||
raise osv.except_osv(_('Error'), _('You must provide a BVR number\n'
|
raise osv.except_osv(_('Error'), _('You must provide a BVR number\n'
|
||||||
'for the bank account: %s' \
|
'for the bank account: %s' \
|
||||||
|
|
|
@ -8,8 +8,7 @@
|
||||||
<field name="type">form</field>
|
<field name="type">form</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="DTA file creation - Results">
|
<form string="DTA file creation - Results">
|
||||||
<group width="300" colspan="4">
|
<group colspan="4">
|
||||||
<separator string="Create DTA - (DTA file will appear after you click on create)" colspan="4"/>
|
|
||||||
<field name="dta_file"/>
|
<field name="dta_file"/>
|
||||||
<group colspan="4">
|
<group colspan="4">
|
||||||
<button special="cancel" string="Cancel" icon="gtk-cancel" colspan="2"/>
|
<button special="cancel" string="Cancel" icon="gtk-cancel" colspan="2"/>
|
||||||
|
|
Loading…
Reference in New Issue