diff --git a/stock_picking_report_custom_description/models/stock_rule.py b/stock_picking_report_custom_description/models/stock_rule.py index 0869659..43417cb 100644 --- a/stock_picking_report_custom_description/models/stock_rule.py +++ b/stock_picking_report_custom_description/models/stock_rule.py @@ -31,6 +31,15 @@ class StockRule(models.Model): ) if values.get("sale_line_id"): line = self.env["sale.order.line"].browse(values["sale_line_id"]) - res["description_picking"] = line.name + # Avoid double printing the name in the picking + pattern = f"{line.product_id.display_name}\n" + description_picking = line.name + if description_picking.startswith(pattern): + description_picking = description_picking.replace(pattern, "") + if ( + description_picking + and description_picking != line.product_id.display_name + ): + res["description_picking"] = description_picking res["name"] = line.name return res diff --git a/stock_picking_report_custom_description/tests/test_stock_picking_report_custom_description.py b/stock_picking_report_custom_description/tests/test_stock_picking_report_custom_description.py index f906b29..fefb17b 100644 --- a/stock_picking_report_custom_description/tests/test_stock_picking_report_custom_description.py +++ b/stock_picking_report_custom_description/tests/test_stock_picking_report_custom_description.py @@ -11,13 +11,16 @@ class TestStockPickingReportCustomDescription(common.TransactionCase): super().setUpClass() cls.customer = cls.env["res.partner"].create({"name": "Test customer"}) cls.product = cls.env["product.product"].create( - {"name": "Test product", "type": "product"} + { + "name": "Test product", + "type": "product", + "description_sale": "Custom description", + } ) order_form = common.Form(cls.env["sale.order"]) order_form.partner_id = cls.customer with order_form.order_line.new() as line_form: line_form.product_id = cls.product - line_form.name = "Custom description" cls.order = order_form.save() def test_so_custom_description_transfer_to_picking(self):