[FIX] sale: sale.order.line population

product template model is not a populate dependency of sale, do not try 
to fetch the ids of templates if the model wasn't populated.
This commit is contained in:
Victor Feyens
2021-12-02 12:12:04 +01:00
committed by Yannick Tivisse
parent 2541fe2067
commit c574c76bc1
+4 -3
View File
@@ -76,9 +76,10 @@ class SaleOrderLine(models.Model):
product_ids = self.env.registry.populated_models["product.product"]
# If we want more advanced products with multiple variants
# add a populate dependency on product template and the following lines
product_ids += self.env["product.product"].search([
('product_tmpl_id', 'in', self.env.registry.populated_models["product.template"])
]).ids
if 'product.template' in self.env.registry.populated_models:
product_ids += self.env["product.product"].search([
('product_tmpl_id', 'in', self.env.registry.populated_models["product.template"])
]).ids
self.env['product.product'].browse(product_ids).read(['uom_id']) # prefetch all uom_id