[IMP]calculate amount residual also when setting the account as not reconcilable

pull/280/head
Aaron Henriquez 2019-03-06 12:35:55 +01:00 committed by mreficent
parent 7c2da71f5b
commit 5e4fe411b6
1 changed files with 4 additions and 3 deletions

View File

@ -9,7 +9,8 @@ class AccountAccount(models.Model):
@api.multi @api.multi
def write(self, vals): def write(self, vals):
if vals.get('reconcile', False): if 'reconcile' in vals:
rec_val = vals.get('reconcile')
move_lines = self.env['account.move.line'].search( move_lines = self.env['account.move.line'].search(
[('account_id', 'in', self.ids)]) [('account_id', 'in', self.ids)])
if move_lines: if move_lines:
@ -17,8 +18,8 @@ class AccountAccount(models.Model):
acc_move_lines = move_lines.filtered( acc_move_lines = move_lines.filtered(
lambda line: line.account_id == acc) lambda line: line.account_id == acc)
self.env.cr.execute( self.env.cr.execute(
"UPDATE account_account SET reconcile=True " "UPDATE account_account SET reconcile=%s "
"WHERE id=%s", (acc.id,)) "WHERE id=%s", (rec_val, acc.id,))
acc_move_lines._amount_residual() acc_move_lines._amount_residual()
vals.pop('reconcile') vals.pop('reconcile')
return super(AccountAccount, self).write(vals=vals) return super(AccountAccount, self).write(vals=vals)