diff options
| author | Nicolas Martinelli <nim@odoo.com> | 2020-07-24 10:54:53 +0000 |
|---|---|---|
| committer | Nicolas Martinelli <nim@odoo.com> | 2020-07-28 12:38:33 +0000 |
| commit | 684b628c5acc298af83791fbaf8da0b774140425 (patch) | |
| tree | 8b4e4baf4fa77214f722fc6a09b61fc8abf2e497 /addons/purchase_mrp | |
| parent | c8063af7a085eda61e470fa5c861e94388429644 (diff) | |
[FIX] purchase_mrp: receive kits with multiple UOM
- Create 3 products A, B & C
A is in Units
B is in kg
C is in m
- Create a BOM kit for A using 1 kg of B and 1 m of C
- Create a PO for A, validate
- Receive the picking
An error is raised: "Conversion from Product UoM ... to Default UoM ...
is not possible as they both belong to different Category!."
It happens because `_compute_qty_received` incorrectly converts
quantities.
The computation of the quantity received for kits is done in 2 steps:
first we compute the quantity the same way we do it for a regular
product, then we overwrite the quantity with the value computed for
kits.
We can compute the quantity correctly at once by calling `super` only on
lines which are not kits.
opw-2302807
closes odoo/odoo#55047
X-original-commit: b82f71dac9452de9c1e16cde552fe260fec3c262
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Diffstat (limited to 'addons/purchase_mrp')
| -rw-r--r-- | addons/purchase_mrp/models/purchase.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/addons/purchase_mrp/models/purchase.py b/addons/purchase_mrp/models/purchase.py index 5fcdda4ed24..6256516cfe6 100644 --- a/addons/purchase_mrp/models/purchase.py +++ b/addons/purchase_mrp/models/purchase.py @@ -43,7 +43,7 @@ class PurchaseOrderLine(models.Model): _inherit = 'purchase.order.line' def _compute_qty_received(self): - super(PurchaseOrderLine, self)._compute_qty_received() + kit_lines = self.env['purchase.order.line'] for line in self: if line.qty_received_method == 'stock_moves' and line.move_ids: kit_bom = self.env['mrp.bom']._bom_find(product=line.product_id, company_id=line.company_id.id, bom_type='phantom') @@ -55,6 +55,8 @@ class PurchaseOrderLine(models.Model): 'outgoing_moves': lambda m: m.location_id.usage != 'supplier' and m.to_refund } line.qty_received = moves._compute_kit_quantities(line.product_id, order_qty, kit_bom, filters) + kit_lines += line + super(PurchaseOrderLine, self - kit_lines)._compute_qty_received() def _get_upstream_documents_and_responsibles(self, visited): return [(self.order_id, self.order_id.user_id, visited)] |
