[IMP] Change strategy
parent
e3590c6919
commit
00d267a53d
|
@ -9,23 +9,16 @@ class AccountAccount(models.Model):
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
reconcile = False
|
if vals.get('reconcile', False):
|
||||||
if vals.get('reconcile', False) and not self.env.context.get(
|
move_lines = self.env['account.move.line'].search(
|
||||||
'set_reconcilable', False):
|
|
||||||
reconcile = vals.pop('reconcile')
|
|
||||||
rec = super(AccountAccount, self).write(vals=vals)
|
|
||||||
if reconcile:
|
|
||||||
moves_lines = self.env['account.move.line'].search(
|
|
||||||
[('account_id', 'in', self.ids)])
|
[('account_id', 'in', self.ids)])
|
||||||
for account in self:
|
if move_lines:
|
||||||
lines = moves_lines.filtered(
|
for acc in self:
|
||||||
lambda line: line.account_id == account)
|
acc_move_lines = move_lines.filtered(
|
||||||
if lines:
|
lambda line: line.account_id == acc)
|
||||||
t_account = account.copy()
|
self.env.cr.execute(
|
||||||
lines.write({'account_id': t_account.id})
|
"UPDATE account_account SET reconcile=True "
|
||||||
account.with_context(set_reconcilable=True).write(
|
"WHERE id=%s", (acc.id,))
|
||||||
{'reconcile': reconcile})
|
acc_move_lines._amount_residual()
|
||||||
lines.write({'account_id': account.id})
|
vals.pop('reconcile')
|
||||||
lines._amount_residual()
|
return super(AccountAccount, self).write(vals=vals)
|
||||||
t_account.unlink()
|
|
||||||
return rec
|
|
||||||
|
|
Loading…
Reference in New Issue