Skip to content

Commit

Permalink
[IMP] account: feature that links bank accounts to partners upon bank…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
Whisno committed Feb 16, 2015
1 parent a7e0b73 commit d1be21d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion addons/account/account_bank_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,11 @@ def link_bank_to_partner(self, cr, uid, ids, context=None):
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):

Expand Down

0 comments on commit d1be21d

Please sign in to comment.