Skip to content

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

Closed
fw-bot wants to merge 1 commit into
odoo:19.0from
odoo-dev:19.0-17.0-opw-4965036-protect_invoice_on_line_create-sile-475211-fw
Closed

[FIX] account, sale_stock: protect moves on line create#234567
fw-bot wants to merge 1 commit into
odoo:19.0from
odoo-dev:19.0-17.0-opw-4965036-protect_invoice_on_line_create-sile-475211-fw

Conversation

@fw-bot
Copy link
Copy Markdown
Contributor

@fw-bot fw-bot commented Nov 5, 2025

Versions

  • 17.0+

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 818cf04 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

Versions
--------
- 17.0+

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;
7. confirm the invoice.

Issue
-----
The delivery date gets reset.

Cause
-----
Commit 818cf04 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

X-original-commit: 84828f1
@robodoo
Copy link
Copy Markdown
Contributor

robodoo commented Nov 5, 2025

Pull request status dashboard

@robodoo robodoo added the forwardport This PR was created by @fw-bot label Nov 5, 2025
@fw-bot
Copy link
Copy Markdown
Contributor Author

fw-bot commented Nov 5, 2025

This PR targets 19.0 and is part of the forward-port chain. Further PRs will be created up to master.

More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port

@robodoo robodoo closed this in e992e67 Nov 6, 2025
@fw-bot fw-bot deleted the 19.0-17.0-opw-4965036-protect_invoice_on_line_create-sile-475211-fw branch November 13, 2025 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

forwardport This PR was created by @fw-bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants