[FIX] account: Fix cascading computation leading to wrong move_name computation
When l10n_mx_edi is installed and a payment is posted, the move_name field on account.move.line being a related to move_id.name is not well computed. That is because posting a move trigger the computed field in a protected mode due to `flush_recorset`. This mode prevents any computed field to be recomputed twice. This flush triggers `_compute_name` calling `sequence_mixin`, itself doing another `flush_recorset`. This extra flush triggers `_compute_l10n_mx_edi_cfdi_uuid` that access to `move.payment_id.reconciled_bill_ids`. This access to this field triggers its recomputation and then, `_compute_stat_buttons_from_reconciliation` is called. This method does `self.env['account.move.line'].flush_model()` that force the computation of `move_name` to `/`. `sequence_mixin` assigns the new `name` to the journal entry but `move_name` is not recomputed due to the protected environment. closes odoo/odoo#121114 X-original-commit: 33198b3443829d6d6e421cf9d6b8033a040b5263 Signed-off-by: Laurent Smet <las@odoo.com> Signed-off-by: Olivier Colson (oco) <oco@odoo.com>
This commit is contained in:
@@ -568,9 +568,10 @@ class AccountPayment(models.Model):
|
||||
self.reconciled_statement_lines_count = 0
|
||||
return
|
||||
|
||||
self.env['account.move'].flush_model()
|
||||
self.env['account.move.line'].flush_model()
|
||||
self.env['account.partial.reconcile'].flush_model()
|
||||
self.env['account.payment'].flush_model(fnames=['move_id', 'outstanding_account_id'])
|
||||
self.env['account.move'].flush_model(fnames=['move_type', 'payment_id', 'statement_line_id'])
|
||||
self.env['account.move.line'].flush_model(fnames=['move_id', 'account_id', 'statement_line_id'])
|
||||
self.env['account.partial.reconcile'].flush_model(fnames=['debit_move_id', 'credit_move_id'])
|
||||
|
||||
self._cr.execute('''
|
||||
SELECT
|
||||
@@ -616,7 +617,6 @@ class AccountPayment(models.Model):
|
||||
ARRAY_AGG(DISTINCT counterpart_line.statement_line_id) AS statement_line_ids
|
||||
FROM account_payment payment
|
||||
JOIN account_move move ON move.id = payment.move_id
|
||||
JOIN account_journal journal ON journal.id = move.journal_id
|
||||
JOIN account_move_line line ON line.move_id = move.id
|
||||
JOIN account_account account ON account.id = line.account_id
|
||||
JOIN account_partial_reconcile part ON
|
||||
|
||||
Reference in New Issue
Block a user