From 6ea5e188424bf53d98b378a165649606b83ae778 Mon Sep 17 00:00:00 2001 From: mafo-odoo Date: Wed, 21 Sep 2022 08:18:11 +0000 Subject: [PATCH] [FIX] stock: compute quantities for newId product Steps to reproduce: - Install sale_ebay, - Some accounting localization - Go to currencies and check the box saying it can be use with eBay - Go to attributes and create two of them - Create a product - Put the attributes - Go to the eBay tab of the product - Put fixed price to the listing type field - try to check one of the product variant Current behavior: Error: Database fetch misses ids ((, ) and has extra ids ((3, 4)), may be caused by a type incoherence in a previous request Expected behavior: No error Explanation: In this situation the product_variant_ids are newID and we can use only read on their origin record. opw-2974596 are a closes odoo/odoo#102655 X-original-commit: 7e998f225096ab03c60c1cdeffc2f17a795b37de Signed-off-by: Tiffany Chang Signed-off-by: Fockedey Martin (mafo) --- addons/stock/models/product.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py index 4876ba58ade..525af9a8ab0 100644 --- a/addons/stock/models/product.py +++ b/addons/stock/models/product.py @@ -702,7 +702,7 @@ class ProductTemplate(models.Model): def _compute_quantities_dict(self): variants_available = { - p['id']: p for p in self.product_variant_ids.read(['qty_available', 'virtual_available', 'incoming_qty', 'outgoing_qty']) + p['id']: p for p in self.product_variant_ids._origin.read(['qty_available', 'virtual_available', 'incoming_qty', 'outgoing_qty']) } prod_available = {} for template in self: @@ -710,7 +710,7 @@ class ProductTemplate(models.Model): virtual_available = 0 incoming_qty = 0 outgoing_qty = 0 - for p in template.product_variant_ids: + for p in template.product_variant_ids._origin: qty_available += variants_available[p.id]["qty_available"] virtual_available += variants_available[p.id]["virtual_available"] incoming_qty += variants_available[p.id]["incoming_qty"]