From b338797346c4a60956a580c5aa751e181794576d 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 Since v14, the SO line custom description is not transferred to the stock.move name, so we need to do such transfer in this module, as the main purpose of it is to print custom texts from SO. --- .../README.rst | 18 ++++++---- .../__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 | 17 ++++++--- .../tests/__init__.py | 2 ++ ...stock_picking_report_custom_description.py | 24 +++++++++++++ 10 files changed, 99 insertions(+), 15 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 2ea2605..5f9e639 100644 --- a/stock_picking_report_custom_description/README.rst +++ b/stock_picking_report_custom_description/README.rst @@ -19,13 +19,14 @@ Stock Picking Report Custom Description .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png :target: https://translation.odoo-community.org/projects/stock-logistics-reporting-14-0/stock-logistics-reporting-14-0-stock_picking_report_custom_description :alt: Translate me on Weblate -.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/151/14.0 - :alt: Try me on Runbot +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/stock-logistics-reporting&target_branch=14.0 + :alt: Try me on Runboat |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 121fbe4..a4f2fab 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 dd870fc..3d77409 100644 --- a/stock_picking_report_custom_description/static/description/index.html +++ b/stock_picking_report_custom_description/static/description/index.html @@ -3,7 +3,7 @@ - + Stock Picking Report Custom Description