[IMP] account: feature that links bank accounts to partners upon bank statement closing.

Retreive additional informations to write on the res.partner.bank by using the onchange_partner_id, instead of only writing the partner_id
This commit is contained in:
Arthur Maniet 2015-02-16 11:22:05 +01:00
parent a7e0b73930
commit d1be21dfdf
1 changed files with 5 additions and 1 deletions

View File

@ -419,7 +419,11 @@ class account_bank_statement(osv.osv):
for statement in self.browse(cr, uid, ids, context=context):
for st_line in statement.line_ids:
if st_line.bank_account_id and st_line.partner_id and st_line.bank_account_id.partner_id.id != st_line.partner_id.id:
self.pool.get('res.partner.bank').write(cr, uid, [st_line.bank_account_id.id], {'partner_id': st_line.partner_id.id}, context=context)
# Update the partner informations of the bank account, possibly overriding existing ones
bank_obj = self.pool.get('res.partner.bank')
bank_vals = bank_obj.onchange_partner_id(cr, uid, [st_line.bank_account_id.id], st_line.partner_id.id, context=context)['value']
bank_vals.update({'partner_id': st_line.partner_id.id})
bank_obj.write(cr, uid, [st_line.bank_account_id.id], bank_vals, context=context)
class account_bank_statement_line(osv.osv):