[FIX] account: aml's partner_id modified after the move has been posted when using the hash
Steps to reproduce: 1. Activate the hash mode on a journal 2. Create an account move 3. Choose a customer who is not a commercial partner (e.g. Brandon Freeman from Azure Interior) 4. Post the move 5. Error saying that we cannot modify the `partner_id` because the move has already been posted This is because currently we first post the move and then we modify the `partner_id` of the lines whose `partner_id` is different from the account's `commercial_partner_id`. We can easily fix this by posting the move after the lines'`partner_id` have been modified. closes odoo/odoo#108177 X-original-commit: 1036134a2f0d921fd6a659b4951e5fa63975b78d Signed-off-by: William André (wan) <wan@odoo.com> Signed-off-by: Ricardo Gomes Rodrigues (rigr) <rigr@odoo.com>
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user