From 9f58c767df93d387652b1cddb0a70f652bec0646 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Thu, 18 Jun 2026 16:03:04 +0200 Subject: [PATCH] [IMP] product_margin_classification: Use new check_company feature to avoid to link product of company 1 with margin of company 2 --- .../demo/product_margin_classification.xml | 2 ++ product_margin_classification/models/product_product.py | 1 + product_margin_classification/models/product_template.py | 1 + .../tests/test_product_margin_classification.py | 1 + 4 files changed, 5 insertions(+) diff --git a/product_margin_classification/demo/product_margin_classification.xml b/product_margin_classification/demo/product_margin_classification.xml index 4abbfbf2f..9f8264c32 100644 --- a/product_margin_classification/demo/product_margin_classification.xml +++ b/product_margin_classification/demo/product_margin_classification.xml @@ -10,6 +10,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). 50 Normal Margin (33%) 0.05 + @@ -18,6 +19,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). Big Margin (50%, with 95 cents) 1 -0.05 + diff --git a/product_margin_classification/models/product_product.py b/product_margin_classification/models/product_product.py index 20fcab609..afc8bdfeb 100644 --- a/product_margin_classification/models/product_product.py +++ b/product_margin_classification/models/product_product.py @@ -20,6 +20,7 @@ class ProductProduct(models.Model): margin_classification_id = fields.Many2one( comodel_name="product.margin.classification", string="Margin Classification", + check_company=True, ) theoretical_price = fields.Float( diff --git a/product_margin_classification/models/product_template.py b/product_margin_classification/models/product_template.py index 477df7cc9..47a0315e1 100644 --- a/product_margin_classification/models/product_template.py +++ b/product_margin_classification/models/product_template.py @@ -17,6 +17,7 @@ class ProductTemplate(models.Model): inverse="_inverse_margin_classification_id", search="_search_margin_classification_id", comodel_name="product.margin.classification", + check_company=True, ) theoretical_price = fields.Float( diff --git a/product_margin_classification/tests/test_product_margin_classification.py b/product_margin_classification/tests/test_product_margin_classification.py index d366f60a6..56557240b 100644 --- a/product_margin_classification/tests/test_product_margin_classification.py +++ b/product_margin_classification/tests/test_product_margin_classification.py @@ -93,6 +93,7 @@ def test_06_create_product_template(self): { "name": "Template Name", "margin_classification_id": self.classification_big_margin, + "company_id": False, } ) self.assertEqual(