From 2e273cb0cbf3a919597ba28adc2709dbf91de678 Mon Sep 17 00:00:00 2001 From: bch <> Date: Thu, 11 Jan 2007 14:50:56 +0000 Subject: [PATCH] DTA : Improved way to manage the differents types of record with less technical concept for the user bzr revid: bch-5a62ad1fda35fad3acf124f3f6e3f6dba065779e --- addons/l10n_ch/dta/dta_demo.xml | 12 ++++++------ addons/l10n_ch/dta/dta_view.xml | 8 ++++++++ addons/l10n_ch/dta/dta_wizard.py | 33 +++++++++++++++++++++++--------- addons/l10n_ch/dta/invoice.py | 2 ++ 4 files changed, 40 insertions(+), 15 deletions(-) diff --git a/addons/l10n_ch/dta/dta_demo.xml b/addons/l10n_ch/dta/dta_demo.xml index ca62b81df73..66c6fbcc06a 100644 --- a/addons/l10n_ch/dta/dta_demo.xml +++ b/addons/l10n_ch/dta/dta_demo.xml @@ -2,16 +2,16 @@ - - With Iban (GT 836) + + With Iban (will generate gt836 records) - gt836 + iban - - With BVR (GT 826) + + Regular type - gt826 + diff --git a/addons/l10n_ch/dta/dta_view.xml b/addons/l10n_ch/dta/dta_view.xml index 9d3570d2a4e..03d04868a46 100644 --- a/addons/l10n_ch/dta/dta_view.xml +++ b/addons/l10n_ch/dta/dta_view.xml @@ -15,6 +15,9 @@ + + + account.invoice.form account.invoice @@ -22,11 +25,16 @@ + + + + + account.invoice.dta ir.actions.act_window diff --git a/addons/l10n_ch/dta/dta_wizard.py b/addons/l10n_ch/dta/dta_wizard.py index d90864b0265..1d2429fa225 100644 --- a/addons/l10n_ch/dta/dta_wizard.py +++ b/addons/l10n_ch/dta/dta_wizard.py @@ -229,6 +229,12 @@ class record_gt826(record): 'ref2':'','ref3':'', 'format':'0'}) +class record_gt827(record): + # -> interne suisse + def init_local_context(self): + raise Exception("Record gt827 not yet available") + + class record_gt836(record): # -> iban @@ -266,6 +272,7 @@ class record_gt836(record): 'format':'0'}) self.post.update({'option_motif':'U'}) + class record_gt890(record): # -> total def init_local_context(self): @@ -304,8 +311,6 @@ def _create_dta(self,cr,uid,data,context): log='' dta='' - record_table = {'gt826':record_gt826,'gt836':record_gt836} - pool = pooler.get_pool(cr.dbname) bank= pool.get('res.partner.bank').browse(cr,uid,[data['form']['bank']])[0] @@ -370,6 +375,8 @@ def _create_dta(self,cr,uid,data,context): }) for dtal in dta_line_obj.browse(cr,uid,dta_line_ids): + + i = dtal.name #dta_line.name = invoice's id invoice_number = i.number or '??' if not i.partner_bank_id: @@ -425,16 +432,24 @@ def _create_dta(self,cr,uid,data,context): v['date_value'] = "000000" + + # si compte iban -> iban (836) + # si payment structure -> bvr (826) + # si non -> (827) + + elec_pay = i.partner_bank_id.type_id.elec_pay - if not elec_pay: - log= log +'\nNo payment mode defined for the partner bank. (invoice '+ invoice_number +')' - continue - if not record_table.has_key( elec_pay ): - log= log +'\nPayment mode '+str(elec_pay)+' not supported. (invoice '+ invoice_number +')' - continue + if elec_pay and elec_pay == 'iban': + record_type = record_gt836 + if i.structured_ref : + v['option_motif']='I' + elif i.structured_ref : + record_type = record_gt826 + else: + record_type = record_gt827 try: - dta_line = record_table[ elec_pay ](v).generate() + dta_line = record_type(v).generate() except Exception,e : log= log +'\nERROR:'+ str(e)+'(invoice '+ invoice_number+')' dta_line_obj.write(cr,uid,[dtal.id],{'state':'cancel'}) diff --git a/addons/l10n_ch/dta/invoice.py b/addons/l10n_ch/dta/invoice.py index ea27bb6c389..25d46305596 100644 --- a/addons/l10n_ch/dta/invoice.py +++ b/addons/l10n_ch/dta/invoice.py @@ -40,10 +40,12 @@ class account_invoice(osv.osv): ('2bp','To be paid'), ('paid','Paid')], 'DTA state',readonly=True,select=True, states={'draft':[('readonly',False)]}), + 'structured_ref': fields.boolean('Structured Reference'), } _defaults = { 'dta_state': lambda *a: 'none', + 'structured_ref': lambda *a: False, } account_invoice()