odoo/odoo#234567

Created by fw-bot
Merged at e992e675145a2f4802233635f8aea527ab4ca716

Statuses:

label
odoo-dev:19.0-17.0-opw-4965036-protect_invoice_on_line_create-sile-475211-fw
head
f48a582eb94bfd24069ad56a2c47288fc46fabd2
merged
7 months ago by Bugfix, Levi Siuzdak
odoo/odoo
17.0 #231186
18.0 #234435
saas-18.2 #234452
saas-18.3 #234459
saas-18.4 #234529
19.0 #234567
saas-19.1
saas-19.2
saas-19.3
master #234592

[FIX] account, sale_stock: protect moves on line create

Versions

Steps

  1. Enable anglo-saxon accounting;
  2. have a product category with automated AVCO;
  3. assign category to a deliverable product;
  4. set product to invoice on delivery;
  5. add product to a sales order;
  6. confirm order & delivery;
  7. create invoice;
  8. change the delivery on the invoice;
  9. confirm the invoice.

Issue

The delivery date gets reset.

Cause

Commit 818cf04f05767 added delivery_date as a permanently protected field when modifying moves or move lines, protecting the records on write. With anglo-saxon accounting however, new move lines are created when confirming an invoice, which in turn recalculate the delivery date, as _get_protected_vals isn't used for their move on create.

Solution

Add self.env['account.move'].protecting(_get_protected_vals({}, moves)) when creating new lines for a move, to avoid recomputing fields that should always be protected.

opw-4965036

Forward-Port-Of: #231186