[IMP] Change strategy

pull/280/head
Jordi Ballester Alomar 2018-10-04 07:21:49 +02:00 committed by mreficent
parent e3590c6919
commit 00d267a53d
1 changed files with 12 additions and 19 deletions

View File

@ -9,23 +9,16 @@ class AccountAccount(models.Model):
@api.multi
def write(self, vals):
reconcile = False
if vals.get('reconcile', False) and not self.env.context.get(
'set_reconcilable', False):
reconcile = vals.pop('reconcile')
rec = super(AccountAccount, self).write(vals=vals)
if reconcile:
moves_lines = self.env['account.move.line'].search(
if vals.get('reconcile', False):
move_lines = self.env['account.move.line'].search(
[('account_id', 'in', self.ids)])
for account in self:
lines = moves_lines.filtered(
lambda line: line.account_id == account)
if lines:
t_account = account.copy()
lines.write({'account_id': t_account.id})
account.with_context(set_reconcilable=True).write(
{'reconcile': reconcile})
lines.write({'account_id': account.id})
lines._amount_residual()
t_account.unlink()
return rec
if move_lines:
for acc in self:
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,))
acc_move_lines._amount_residual()
vals.pop('reconcile')
return super(AccountAccount, self).write(vals=vals)