[FIX] quality_control_stock_oca: Avoid singleton error

A compute must be multi-record aware
This commit is contained in:
Pedro M. Baeza
2021-07-21 16:50:17 +02:00
committed by Enrique Martín
parent 1848fc4c35
commit d192db9443
2 changed files with 7 additions and 8 deletions

View File

@@ -5,7 +5,7 @@
{
"name": "Quality control - Stock (OCA)",
"version": "13.0.1.0.0",
"version": "13.0.1.0.1",
"category": "Quality control",
"license": "AGPL-3",
"author": "OdooMRP team, AvanzOSC, Serv. Tecnol. Avanzados - Pedro M. Baeza, "

View File

@@ -63,15 +63,14 @@ class QcInspection(models.Model):
@api.depends("object_id")
def _compute_product_id(self):
"""Overriden for getting the product from a stock move."""
self.ensure_one()
super()._compute_product_id()
if self.object_id:
if self.object_id._name == "stock.move":
self.product_id = self.object_id.product_id
elif self.object_id._name == "stock.move.line":
self.product_id = self.object_id.product_id
for inspection in self.filtered("object_id"):
if inspection.object_id._name == "stock.move":
inspection.product_id = inspection.object_id.product_id
elif inspection.object_id._name == "stock.move.line":
inspection.product_id = inspection.object_id.product_id
elif self.object_id._name == "stock.production.lot":
self.product_id = self.object_id.product_id
inspection.product_id = inspection.object_id.product_id
@api.onchange("object_id")
def onchange_object_id(self):