Files
odoo_source/addons/purchase_mrp
Adrien Widart (awt) 5a0f546dba [FIX] purchase{,_stock,_mrp}: get unit price of AVCO kit-component
Receiving a kit's component will fail in AVCO + multi-uom

To reproduce:
1. Create a product category PC
   - Costing Method: AVCO
2. Create two products P_compo, P_kit
   - P_kit:
     - In Units
   - P_compo:
     - In L
     - Storable
     - Category PC
3. Create a BoM
   - Product: P_kit
   - Type: Kit
   - Components: 1 x P_compo
4. Create and confirm a PO with 1 x P_kit
5. Process the receipt

Error: When validating the receipt, a user error is displayed: "The
unit of measure L defined on the order line doesn't belong to the
same category [...]"

When processing the SM, we create the in-SVL. To do so, at some
point, we need the unit price of the SM, and here is where the error
comes from:
https://github.com/odoo/odoo/blob/708c3d063482e365e49a04f633c83e90e6fa4356/addons/purchase_stock/models/stock_move.py#L39
`self.product_id` is P_component, but `line.product_id` is P_kit,
hence the error with the UoM1
And there will be some similar errors with the `if` block, L40 (we
compare some SM quantities and some POL quantities: we are mixing
components and kit)

For now, in case of a kit, we will always use the `else` block (i.e.,
the unit price of the POL). This will be improved in master

OPW-3357685

closes odoo/odoo#128386

X-original-commit: 3a81eb79cad7f25843315e39da421efa2c34aaf1
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Adrien Widart (awt) <awt@odoo.com>
2023-07-13 19:28:21 +02:00
..
…
…