Skip to content

Commit

Permalink
[3700][FIX] purchase_ship, purchase_order_category: restore product u…
Browse files Browse the repository at this point in the history
…pdate logic (#348)

Commit e87073a had some oversight and a part of the product update logic went missing.
This commit fixes the issue.
  • Loading branch information
yostashiro authored Aug 26, 2023
1 parent e87073a commit 06d22c7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
13 changes: 12 additions & 1 deletion purchase_order_category/models/purchase_order.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2017-2018 Quartile Limited
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).

from odoo import fields, models
from odoo import api, fields, models


class PurchaseOrder(models.Model):
Expand All @@ -11,3 +11,14 @@ class PurchaseOrder(models.Model):
"purchase.category",
"Purchase Category",
)

@api.multi
def write(self, vals):
res = super().write(vals)
if "order_line" in vals or "purchase_category_id" in vals:
for order in self:
products = order.order_line.mapped("product_id")
products.write(
{"purchase_category_id": order.purchase_category_id.id}
)
return res
14 changes: 14 additions & 0 deletions purchase_shop/models/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,17 @@ def onchange_shop_id(self):
if picking_type_id:
self.picking_type_id = picking_type_id
return {"domain": {"purchased_by_id": ids}}

@api.multi
def write(self, vals):
res = super().write(vals)
if "order_line" in vals or "shop_id" in vals or "purchased_by_id" in vals:
for order in self:
products = order.order_line.mapped("product_id")
products.write(
{
"shop_id": order.shop_id.id,
"purchased_by_id": order.purchased_by_id.id,
}
)
return res

0 comments on commit 06d22c7

Please sign in to comment.