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:
parent
ae39205e33
commit
2e273cb0cb
|
@ -2,16 +2,16 @@
|
|||
<terp>
|
||||
<data>
|
||||
|
||||
<record model="res.partner.bank.type" id="bank_type_gt836">
|
||||
<field name="name">With Iban (GT 836)</field>
|
||||
<record model="res.partner.bank.type" id="bank_type_iban">
|
||||
<field name="name">With Iban (will generate gt836 records)</field>
|
||||
<field name="code"></field>
|
||||
<field name="elec_pay">gt836</field>
|
||||
<field name="elec_pay">iban</field>
|
||||
</record>
|
||||
|
||||
<record model="res.partner.bank.type" id="bank_type_gt826">
|
||||
<field name="name">With BVR (GT 826)</field>
|
||||
<record model="res.partner.bank.type" id="bank_type_gt">
|
||||
<field name="name">Regular type</field>
|
||||
<field name="code"></field>
|
||||
<field name="elec_pay">gt826</field>
|
||||
<field name="elec_pay"></field>
|
||||
</record>
|
||||
|
||||
<record model="res.partner.bank" id="main_bank">
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
</record>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- these two record applies t othe same parent -->
|
||||
<record model="ir.ui.view" id="invoice_form">
|
||||
<field name="name">account.invoice.form</field>
|
||||
<field name="model">account.invoice</field>
|
||||
|
@ -22,11 +25,16 @@
|
|||
<field name="inherit_id" ref="account.invoice_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="journal_id" position="after">
|
||||
<newline/>
|
||||
<field name="dta_state" select="1"/>
|
||||
<field name="structured_ref" />
|
||||
</field>
|
||||
</field>
|
||||
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
<record model="ir.actions.act_window" id="action_invoice_with_dta">
|
||||
<field name="name">account.invoice.dta</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
|
|
|
@ -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'})
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue