odoo/odoo#204074

Created by fw-bot
Merged at 6bd45c3d4176e762152264c5d9d1e61dd5cd3c31

Statuses:

label
odoo-dev:master-18.0-opw-4509006-stock_landed_cost-fix-lot-standard-price-otd-426539-fw
head
3e583c01927d647a7082ced7e2b610ca554a6381
merged
3 months ago by Bugfix, Djamel Touati (otd)
odoo/odoo
18.0 #197019
saas-18.1 #198777
saas-18.2 #204070
saas-18.3
master #204074

[FW][FIX] stock_landed_cost: update the lot standard price correctly

Steps to reproduce the bug:
- Create two storable products, P1 and P2:
- tracked by: lot
- Valuated by: lot

  • Create a service product, S1:

    • is landed cost: True
    • value: $100
  • Create a receipt:

    • unit of P1, unit price: $1
    • unit of P2, unit price: $1
  • Add the landed cost S1, split by quantity.

Problem:

The cost valuation of the products is then $51 each. The product form
and valuation are displayed correctly. However, if we check the lot,
the cost appears as $101.
This issue occurs because, when validating the landed cost, we have a
dictionary mapping lots to values. Then, we iterate over each product,
but we do not filter the lot dictionary for the current product.
Instead, we traverse the entire dictionary, leading to the lot values
being processed twice.

opw-4509006

Forward-Port-Of: #198777
Forward-Port-Of: #197019