DTA : Improved way to manage the differents types of record with less technical concept for the user

bzr revid: bch-5a62ad1fda35fad3acf124f3f6e3f6dba065779e
This commit is contained in:
bch 2007-01-11 14:50:56 +00:00
parent ae39205e33
commit 2e273cb0cb
4 changed files with 40 additions and 15 deletions

View File

@ -2,16 +2,16 @@
<terp> <terp>
<data> <data>
<record model="res.partner.bank.type" id="bank_type_gt836"> <record model="res.partner.bank.type" id="bank_type_iban">
<field name="name">With Iban (GT 836)</field> <field name="name">With Iban (will generate gt836 records)</field>
<field name="code"></field> <field name="code"></field>
<field name="elec_pay">gt836</field> <field name="elec_pay">iban</field>
</record> </record>
<record model="res.partner.bank.type" id="bank_type_gt826"> <record model="res.partner.bank.type" id="bank_type_gt">
<field name="name">With BVR (GT 826)</field> <field name="name">Regular type</field>
<field name="code"></field> <field name="code"></field>
<field name="elec_pay">gt826</field> <field name="elec_pay"></field>
</record> </record>
<record model="res.partner.bank" id="main_bank"> <record model="res.partner.bank" id="main_bank">

View File

@ -15,6 +15,9 @@
</record> </record>
<!-- these two record applies t othe same parent -->
<record model="ir.ui.view" id="invoice_form"> <record model="ir.ui.view" id="invoice_form">
<field name="name">account.invoice.form</field> <field name="name">account.invoice.form</field>
<field name="model">account.invoice</field> <field name="model">account.invoice</field>
@ -22,11 +25,16 @@
<field name="inherit_id" ref="account.invoice_form"/> <field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="journal_id" position="after"> <field name="journal_id" position="after">
<newline/>
<field name="dta_state" select="1"/> <field name="dta_state" select="1"/>
<field name="structured_ref" />
</field> </field>
</field> </field>
</record> </record>
<record model="ir.actions.act_window" id="action_invoice_with_dta"> <record model="ir.actions.act_window" id="action_invoice_with_dta">
<field name="name">account.invoice.dta</field> <field name="name">account.invoice.dta</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>

View File

@ -229,6 +229,12 @@ class record_gt826(record):
'ref2':'','ref3':'', 'ref2':'','ref3':'',
'format':'0'}) 'format':'0'})
class record_gt827(record):
# -> interne suisse
def init_local_context(self):
raise Exception("Record gt827 not yet available")
class record_gt836(record): class record_gt836(record):
# -> iban # -> iban
@ -266,6 +272,7 @@ class record_gt836(record):
'format':'0'}) 'format':'0'})
self.post.update({'option_motif':'U'}) self.post.update({'option_motif':'U'})
class record_gt890(record): class record_gt890(record):
# -> total # -> total
def init_local_context(self): def init_local_context(self):
@ -304,8 +311,6 @@ def _create_dta(self,cr,uid,data,context):
log='' log=''
dta='' dta=''
record_table = {'gt826':record_gt826,'gt836':record_gt836}
pool = pooler.get_pool(cr.dbname) pool = pooler.get_pool(cr.dbname)
bank= pool.get('res.partner.bank').browse(cr,uid,[data['form']['bank']])[0] 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): for dtal in dta_line_obj.browse(cr,uid,dta_line_ids):
i = dtal.name #dta_line.name = invoice's id i = dtal.name #dta_line.name = invoice's id
invoice_number = i.number or '??' invoice_number = i.number or '??'
if not i.partner_bank_id: if not i.partner_bank_id:
@ -425,16 +432,24 @@ def _create_dta(self,cr,uid,data,context):
v['date_value'] = "000000" 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 elec_pay = i.partner_bank_id.type_id.elec_pay
if not elec_pay: if elec_pay and elec_pay == 'iban':
log= log +'\nNo payment mode defined for the partner bank. (invoice '+ invoice_number +')' record_type = record_gt836
continue if i.structured_ref :
if not record_table.has_key( elec_pay ): v['option_motif']='I'
log= log +'\nPayment mode '+str(elec_pay)+' not supported. (invoice '+ invoice_number +')' elif i.structured_ref :
continue record_type = record_gt826
else:
record_type = record_gt827
try: try:
dta_line = record_table[ elec_pay ](v).generate() dta_line = record_type(v).generate()
except Exception,e : except Exception,e :
log= log +'\nERROR:'+ str(e)+'(invoice '+ invoice_number+')' log= log +'\nERROR:'+ str(e)+'(invoice '+ invoice_number+')'
dta_line_obj.write(cr,uid,[dtal.id],{'state':'cancel'}) dta_line_obj.write(cr,uid,[dtal.id],{'state':'cancel'})

View File

@ -40,10 +40,12 @@ class account_invoice(osv.osv):
('2bp','To be paid'), ('2bp','To be paid'),
('paid','Paid')], ('paid','Paid')],
'DTA state',readonly=True,select=True, states={'draft':[('readonly',False)]}), 'DTA state',readonly=True,select=True, states={'draft':[('readonly',False)]}),
'structured_ref': fields.boolean('Structured Reference'),
} }
_defaults = { _defaults = {
'dta_state': lambda *a: 'none', 'dta_state': lambda *a: 'none',
'structured_ref': lambda *a: False,
} }
account_invoice() account_invoice()