From 5e4fe411b673216aafa219e82ca41b40d44c8417 Mon Sep 17 00:00:00 2001 From: Aaron Henriquez Date: Wed, 6 Mar 2019 12:35:55 +0100 Subject: [PATCH] [IMP]calculate amount residual also when setting the account as not reconcilable --- account_set_reconcilable/models/account_account.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/account_set_reconcilable/models/account_account.py b/account_set_reconcilable/models/account_account.py index 2c759388..a16dfd16 100644 --- a/account_set_reconcilable/models/account_account.py +++ b/account_set_reconcilable/models/account_account.py @@ -9,7 +9,8 @@ class AccountAccount(models.Model): @api.multi 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( [('account_id', 'in', self.ids)]) if move_lines: @@ -17,8 +18,8 @@ class AccountAccount(models.Model): acc_move_lines = move_lines.filtered( lambda line: line.account_id == acc) self.env.cr.execute( - "UPDATE account_account SET reconcile=True " - "WHERE id=%s", (acc.id,)) + "UPDATE account_account SET reconcile=%s " + "WHERE id=%s", (rec_val, acc.id,)) acc_move_lines._amount_residual() vals.pop('reconcile') return super(AccountAccount, self).write(vals=vals)