From 897fdb45235a404fabde62fdf1f56434e78d2e33 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 18 Oct 2024 18:27:27 +0200 Subject: [PATCH] [IMP] Allow to change a relation between local and global product, for products that doesn't belong the same supplier --- joint_buying_product/models/product_product.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/joint_buying_product/models/product_product.py b/joint_buying_product/models/product_product.py index 525edad2..d0a51352 100644 --- a/joint_buying_product/models/product_product.py +++ b/joint_buying_product/models/product_product.py @@ -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 @@ -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