diff --git a/stock_picking_product_supplier/README.rst b/stock_picking_product_supplier/README.rst
index 65d1b56..bb316c6 100644
--- a/stock_picking_product_supplier/README.rst
+++ b/stock_picking_product_supplier/README.rst
@@ -14,7 +14,7 @@ Overview
--------
The ``Stock Picking Product Supplier`` module displays the supplier reference for products on stock move lines specifically during receipt operations. This supplier reference is automatically retrieved based on the supplier associated with the incoming transfer.
-When handling incoming receipts, users will see a new field on each stock move line displaying the relevant supplier reference. This field is visible only on transfers of type "Receipt" and pulls information from the supplier reference set in the Purchase tab of the product form.
+When handling incoming receipts, users will see a new field on each stock move line displaying the relevant supplier reference. **If the supplier set in the receipt differs from any suppliers listed on the product, the supplier reference field will remain empty.** This field is visible only on transfers of type "Receipt" and pulls information from the supplier reference set in the Purchase tab of the product form.
Configuration
-------------
@@ -26,10 +26,11 @@ To configure this feature, navigate to the Purchase tab on the product form view
Usage
-----
-During the processing of an incoming receipt, the supplier reference for each product will be shown on its respective stock move line. This helps users quickly reference supplier information directly within the receipt view.
+During the processing of an incoming receipt, the supplier reference for each product will be shown on its respective stock move line, provided that the supplier matches one of the product's suppliers. If there is no match, the supplier reference field remains empty. This helps users quickly reference supplier information directly within the receipt view.
.. image:: static/description/purchase_order_form.png
Contributors
------------
* Numigi (tm) and all its contributors (https://bit.ly/numigiens)
+
diff --git a/stock_picking_product_supplier/i18n/fr.po b/stock_picking_product_supplier/i18n/fr.po
index a91c47c..9585f05 100644
--- a/stock_picking_product_supplier/i18n/fr.po
+++ b/stock_picking_product_supplier/i18n/fr.po
@@ -36,6 +36,6 @@ msgid "Product Moves (Stock Move Line)"
msgstr "Mouvements d'article (Ligne de mouvement de stock)"
#. module: stock_picking_product_supplier
-#: model:ir.model.fields,field_description:stock_picking_product_supplier.field_stock_move_line__product_supplier_name
-msgid "Product Supplier Name"
+#: model:ir.model.fields,field_description:stock_picking_product_supplier.field_stock_move_line__product_supplier_code
+msgid "Product Supplier Code"
msgstr "Référence fournisseur"
diff --git a/stock_picking_product_supplier/models/stock_move_line.py b/stock_picking_product_supplier/models/stock_move_line.py
index 5c97486..1964253 100644
--- a/stock_picking_product_supplier/models/stock_move_line.py
+++ b/stock_picking_product_supplier/models/stock_move_line.py
@@ -7,9 +7,9 @@
class StockMoveLine(models.Model):
_inherit = "stock.move.line"
- product_supplier_name = fields.Char(
- compute="_compute_product_supplier_name",
- string="Product Supplier Name",
+ product_supplier_code = fields.Char(
+ compute="_compute_product_supplier_code",
+ string="Product Supplier Code",
store=True,
size=64,
)
@@ -17,13 +17,13 @@ class StockMoveLine(models.Model):
@api.depends(
"picking_id.partner_id", "product_id", "product_id.seller_ids.name"
)
- def _compute_product_supplier_name(self):
+ def _compute_product_supplier_code(self):
for line in self:
- line.product_supplier_name = False
+ line.product_supplier_code = False
partner = line.picking_id.partner_id
if partner and line.product_id.product_tmpl_id.seller_ids:
suppliers = line.product_id.product_tmpl_id.seller_ids.filtered(
lambda s: s.name == partner
)
if suppliers:
- line.product_supplier_name = suppliers[0].name.name
+ line.product_supplier_code = suppliers[0].product_code
diff --git a/stock_picking_product_supplier/tests/test_picking_product_supplier.py b/stock_picking_product_supplier/tests/test_picking_product_supplier.py
index 3381f65..66af15e 100644
--- a/stock_picking_product_supplier/tests/test_picking_product_supplier.py
+++ b/stock_picking_product_supplier/tests/test_picking_product_supplier.py
@@ -18,7 +18,7 @@ def setUp(self):
}
)
- def test_product_supplier_name_with_supplier(self):
+ def test_product_supplier_code_with_supplier(self):
picking = self.env["stock.picking"].create({
"partner_id": self.partner.id,
"picking_type_id": self.env.ref("stock.picking_type_in").id,
@@ -35,9 +35,9 @@ def test_product_supplier_name_with_supplier(self):
"location_dest_id": self.env.ref("stock.stock_location_stock").id,
}
)
- self.assertEqual(move_line.product_supplier_name, self.supplier.name)
+ self.assertEqual(move_line.product_supplier_code, "SLL_CODE")
- def test_product_supplier_name_without_supplier(self):
+ def test_product_supplier_code_without_supplier(self):
self.product.write({"seller_ids": [(5, 0, 0)]})
picking = self.env["stock.picking"].create({
"partner_id": self.partner.id,
@@ -55,4 +55,4 @@ def test_product_supplier_name_without_supplier(self):
"location_dest_id": self.env.ref("stock.stock_location_stock").id,
}
)
- self.assertFalse(move_line.product_supplier_name)
+ self.assertFalse(move_line.product_supplier_code)
diff --git a/stock_picking_product_supplier/views/stock_move_line_views.xml b/stock_picking_product_supplier/views/stock_move_line_views.xml
index c2e88eb..61fcadd 100644
--- a/stock_picking_product_supplier/views/stock_move_line_views.xml
+++ b/stock_picking_product_supplier/views/stock_move_line_views.xml
@@ -6,7 +6,7 @@
-
+