From 0da409942a0bfbd442586fc96fadb2256128d542 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Tue, 13 Dec 2022 19:49:49 +0100 Subject: [PATCH] [FIX] stock_picking_report_custom_description: Transfer line description to move --- .../README.rst | 12 +++++-- .../__init__.py | 2 ++ .../__manifest__.py | 2 +- .../models/__init__.py | 2 ++ .../models/stock_rule.py | 35 +++++++++++++++++++ .../readme/DESCRIPTION.rst | 3 +- .../readme/USAGE.rst | 9 +++-- .../static/description/index.html | 13 +++++-- .../tests/__init__.py | 2 ++ ...stock_picking_report_custom_description.py | 24 +++++++++++++ 10 files changed, 94 insertions(+), 10 deletions(-) create mode 100644 stock_picking_report_custom_description/models/__init__.py create mode 100644 stock_picking_report_custom_description/models/stock_rule.py create mode 100644 stock_picking_report_custom_description/tests/__init__.py create mode 100644 stock_picking_report_custom_description/tests/test_stock_picking_report_custom_description.py diff --git a/stock_picking_report_custom_description/README.rst b/stock_picking_report_custom_description/README.rst index 29c008f..d77e356 100644 --- a/stock_picking_report_custom_description/README.rst +++ b/stock_picking_report_custom_description/README.rst @@ -25,7 +25,8 @@ Stock Picking Report Custom Description |badge1| |badge2| |badge3| |badge4| |badge5| -This module allows to print moves description in picking reports. +This module transfers the sales order line description to the picking, and +allows to print such text on the picking reports. **Table of contents** @@ -38,8 +39,13 @@ Usage To use this module, you need to: #. Create a sale order and set manual description in sale order lines. -#. Go to *Inventory > Deliveries* and you can print the reports with move name - instead product name. +#. Confirm the order. +#. Navigate to the delivery through the smart-button. +#. You can print the reports with move name instead product name on the specific + reports: + + * Delivery Slip (Description). + * Picking Operations (Description) Bug Tracker =========== diff --git a/stock_picking_report_custom_description/__init__.py b/stock_picking_report_custom_description/__init__.py index e69de29..02179fb 100644 --- a/stock_picking_report_custom_description/__init__.py +++ b/stock_picking_report_custom_description/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import models diff --git a/stock_picking_report_custom_description/__manifest__.py b/stock_picking_report_custom_description/__manifest__.py index 0109abe..d881d1d 100644 --- a/stock_picking_report_custom_description/__manifest__.py +++ b/stock_picking_report_custom_description/__manifest__.py @@ -14,7 +14,7 @@ "maintainers": ["carlosdauden"], "license": "AGPL-3", "depends": [ - "stock", + "sale_stock", ], "data": [ "views/report_deliveryslip.xml", diff --git a/stock_picking_report_custom_description/models/__init__.py b/stock_picking_report_custom_description/models/__init__.py new file mode 100644 index 0000000..c6e6e2f --- /dev/null +++ b/stock_picking_report_custom_description/models/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import stock_rule diff --git a/stock_picking_report_custom_description/models/stock_rule.py b/stock_picking_report_custom_description/models/stock_rule.py new file mode 100644 index 0000000..041dc83 --- /dev/null +++ b/stock_picking_report_custom_description/models/stock_rule.py @@ -0,0 +1,35 @@ +# Copyright 2022 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class StockRule(models.Model): + _inherit = "stock.rule" + + def _get_stock_move_values( + self, + product_id, + product_qty, + product_uom, + location_id, + name, + origin, + company_id, + values, + ): + """Transfer the SO line description to the move name.""" + res = super()._get_stock_move_values( + product_id, + product_qty, + product_uom, + location_id, + name, + origin, + company_id, + values, + ) + if values.get("sale_line_id"): + line = self.env["sale.order.line"].browse(values["sale_line_id"]) + res["name"] = line.name + return res diff --git a/stock_picking_report_custom_description/readme/DESCRIPTION.rst b/stock_picking_report_custom_description/readme/DESCRIPTION.rst index ef441a5..a2d382e 100644 --- a/stock_picking_report_custom_description/readme/DESCRIPTION.rst +++ b/stock_picking_report_custom_description/readme/DESCRIPTION.rst @@ -1 +1,2 @@ -This module allows to print moves description in picking reports. +This module transfers the sales order line description to the picking, and +allows to print such text on the picking reports. diff --git a/stock_picking_report_custom_description/readme/USAGE.rst b/stock_picking_report_custom_description/readme/USAGE.rst index ab62328..66a59ec 100644 --- a/stock_picking_report_custom_description/readme/USAGE.rst +++ b/stock_picking_report_custom_description/readme/USAGE.rst @@ -1,5 +1,10 @@ To use this module, you need to: #. Create a sale order and set manual description in sale order lines. -#. Go to *Inventory > Deliveries* and you can print the reports with move name - instead product name. +#. Confirm the order. +#. Navigate to the delivery through the smart-button. +#. You can print the reports with move name instead product name on the specific + reports: + + * Delivery Slip (Description). + * Picking Operations (Description). diff --git a/stock_picking_report_custom_description/static/description/index.html b/stock_picking_report_custom_description/static/description/index.html index 049e756..5035a46 100644 --- a/stock_picking_report_custom_description/static/description/index.html +++ b/stock_picking_report_custom_description/static/description/index.html @@ -368,7 +368,8 @@ ul.auto-toc { !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->

Production/Stable License: AGPL-3 OCA/stock-logistics-reporting Translate me on Weblate Try me on Runboat

-

This module allows to print moves description in picking reports.

+

This module transfers the sales order line description to the picking, and +allows to print such text on the picking reports.

Table of contents

diff --git a/stock_picking_report_custom_description/tests/__init__.py b/stock_picking_report_custom_description/tests/__init__.py new file mode 100644 index 0000000..21aa35c --- /dev/null +++ b/stock_picking_report_custom_description/tests/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). +from . import test_stock_picking_report_custom_description 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 new file mode 100644 index 0000000..84981cf --- /dev/null +++ b/stock_picking_report_custom_description/tests/test_stock_picking_report_custom_description.py @@ -0,0 +1,24 @@ +# Copyright 2022 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests import common + + +class TestStockPickingReportCustomDescription(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.customer = cls.env["res.partner"].create({"name": "Test customer"}) + cls.product = cls.env["product.product"].create( + {"name": "Test product", "type": "product"} + ) + 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): + self.order.action_confirm() + self.assertEqual(self.order.order_line.move_ids.name, "Custom description")