Skip to content

Commit

Permalink
[IMP] Allow to change a relation between local and global product, fo…
Browse files Browse the repository at this point in the history
…r products that doesn't belong the same supplier
  • Loading branch information
legalsylvain committed Oct 18, 2024
1 parent 7b6a4c9 commit 897fdb4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions joint_buying_product/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,17 @@ def set_joint_buying_local_product_id(self, new_local_product):
if current_local_product == new_local_product:
# Nothing change
return
if current_local_product:
raise ValidationError(_("Unimplemented Feature"))
if (
current_local_product
and current_local_product.company_id.joint_buying_partner_id
== self.joint_buying_partner_id
):
raise ValidationError(
_(
"You can not change the relation between a global product"
" and a local product if you sale it."
)
)
new_local_product.joint_buying_product_id = self and self.id

@api.model
Expand Down Expand Up @@ -209,6 +218,7 @@ def create_joint_buying_product(self):
def update_joint_buying_product(self):
products = self.filtered(lambda x: (x.joint_buying_product_id))
for product in products:

vals = product._prepare_joint_buying_product("update")
global_product = product.joint_buying_product_id.with_context(
joint_buying=True, joint_buying_local_to_global=True
Expand Down

0 comments on commit 897fdb4

Please sign in to comment.