[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 ((<NewId origin=3>,
<NewId origin=4>) 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 <tic@odoo.com>
Signed-off-by: Fockedey Martin (mafo) <mafo@odoo.com>
This commit is contained in:
mafo-odoo
2022-10-07 17:48:06 +02:00
parent d6fe28a5fd
commit 6ea5e18842
+2 -2
View File
@@ -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"]