diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index b3bfe769652..f53447ffeae 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -3278,10 +3278,6 @@ class AccountMove(models.Model): # Create the analytic lines in batch is faster as it leads to less cache invalidation. to_post.line_ids._create_analytic_lines() - to_post.write({ - 'state': 'posted', - 'posted_before': True, - }) # Trigger copying for recurring invoices to_post.filtered(lambda m: m.auto_post not in ('no', 'at_date'))._copy_recurring_entries() @@ -3296,6 +3292,12 @@ class AccountMove(models.Model): if wrong_lines: wrong_lines.write({'partner_id': invoice.commercial_partner_id.id}) + to_post.write({ + 'state': 'posted', + 'posted_before': True, + }) + + for invoice in to_post: invoice.message_subscribe([ p.id for p in [invoice.partner_id]