[fix] search for fist packaging instead of all
This commit is contained in:
parent
8b760429d5
commit
399f4fc0a7
1 changed files with 4 additions and 2 deletions
|
|
@ -21,9 +21,11 @@ class ProductTemplate(models.Model):
|
|||
product_products = self.env["product.product"].search([("product_tmpl_id", "=", product.id)])
|
||||
if qty and name:
|
||||
for product_product in product_products:
|
||||
packagings = self.env["product.packaging"].search([("product_id", "=", product_product.id)])
|
||||
packagings = self.env["product.packaging"].search(
|
||||
[("product_id", "=", product_product.id)], limit=1
|
||||
)
|
||||
if packagings:
|
||||
packagings[0].write({"name": name, "qty": qty, "sales": True})
|
||||
packagings.write({"name": name, "qty": qty, "sales": True})
|
||||
else:
|
||||
self.env["product.packaging"].create(
|
||||
{"name": name, "qty": qty, "product_id": product_product.id, "sales": True}
|
||||
|
|
|
|||
Loading…
Reference in a new issue