diff --git a/purchase_all_shipments/README.rst b/purchase_all_shipments/README.rst new file mode 100644 index 00000000000..f85002878b6 --- /dev/null +++ b/purchase_all_shipments/README.rst @@ -0,0 +1,92 @@ +====================== +Purchase All Shipments +====================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:81124385fa1512bf62b7ab59a3d1d00835e23be076f39cd9110d5a4536c56306 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/purchase-workflow/tree/18.0/purchase_all_shipments + :alt: OCA/purchase-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/purchase-workflow-18-0/purchase-workflow-18-0-purchase_all_shipments + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +With the core "purchase" module, in a purchase order a button "In +Shipments" lets the user see the picking that was generated by the order +itself. + +With this module, that button is replaced by an "All Shipments" button +that shows the original picking, and all others that are grouped with +it. This should include pickings associated to the procurements that +generated the purchase, and also pickings that have been chained with +push rules. + +This is consistent with the "sale" module, where from the sale order the +user can access the generated delivery and all chained ones. + +The implementation uses the procurement group of the moves in the +generated picking. The procurement group is always present in purchases, +also when there is no procurement. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Camptocamp + +Contributors +------------ + +- Leonardo Pistone +- Nicolas Mac Rouillon + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/purchase-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_all_shipments/__init__.py b/purchase_all_shipments/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/purchase_all_shipments/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/purchase_all_shipments/__manifest__.py b/purchase_all_shipments/__manifest__.py new file mode 100644 index 00000000000..ad37429ebb5 --- /dev/null +++ b/purchase_all_shipments/__manifest__.py @@ -0,0 +1,13 @@ +# Copyright 2018 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) +{ + "name": "Purchase All Shipments", + "version": "18.0.1.0.0", + "author": "Camptocamp,Odoo Community Association (OCA)", + "website": "https://github.com/OCA/purchase-workflow", + "category": "Purchases", + "license": "AGPL-3", + "depends": ["purchase_stock"], + "installable": True, + "data": ["views/purchase_order_views.xml"], +} diff --git a/purchase_all_shipments/i18n/es.po b/purchase_all_shipments/i18n/es.po new file mode 100644 index 00000000000..2d05a12cdb9 --- /dev/null +++ b/purchase_all_shipments/i18n/es.po @@ -0,0 +1,39 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_all_shipments +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 13.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-08-25 19:03+0000\n" +"PO-Revision-Date: 2023-07-20 10:15+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: purchase_all_shipments +#: model:ir.model.fields,field_description:purchase_all_shipments.field_purchase_order__all_picking_ids +#: model_terms:ir.ui.view,arch_db:purchase_all_shipments.purchase_order_view_form_inherit +msgid "All Pickings" +msgstr "En recepciones" + +#. module: purchase_all_shipments +#: model:ir.model.fields,field_description:purchase_all_shipments.field_purchase_order__all_picking_count +msgid "All Pickings Count" +msgstr "Contador de todas las recepciones" + +#. module: purchase_all_shipments +#: model_terms:ir.ui.view,arch_db:purchase_all_shipments.purchase_order_view_form_inherit +msgid "All Pickings, including chained" +msgstr "Todas las recepciones, incluidos encadenados" + +#. module: purchase_all_shipments +#: model:ir.model,name:purchase_all_shipments.model_purchase_order +msgid "Purchase Order" +msgstr "Línea orden de compra" diff --git a/purchase_all_shipments/i18n/it.po b/purchase_all_shipments/i18n/it.po new file mode 100644 index 00000000000..0cfb25da4c3 --- /dev/null +++ b/purchase_all_shipments/i18n/it.po @@ -0,0 +1,38 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_all_shipments +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-12-24 15:34+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: purchase_all_shipments +#: model:ir.model.fields,field_description:purchase_all_shipments.field_purchase_order__all_picking_ids +#: model_terms:ir.ui.view,arch_db:purchase_all_shipments.purchase_order_view_form_inherit +msgid "All Pickings" +msgstr "Tutti i prelievi" + +#. module: purchase_all_shipments +#: model:ir.model.fields,field_description:purchase_all_shipments.field_purchase_order__all_picking_count +msgid "All Pickings Count" +msgstr "Conteggio tutti i prelievi" + +#. module: purchase_all_shipments +#: model_terms:ir.ui.view,arch_db:purchase_all_shipments.purchase_order_view_form_inherit +msgid "All Pickings, including chained" +msgstr "Tutti i prelievi, inclusi i concatenati" + +#. module: purchase_all_shipments +#: model:ir.model,name:purchase_all_shipments.model_purchase_order +msgid "Purchase Order" +msgstr "Ordine di acquisto" diff --git a/purchase_all_shipments/i18n/purchase_all_shipments.pot b/purchase_all_shipments/i18n/purchase_all_shipments.pot new file mode 100644 index 00000000000..a0a765ce01f --- /dev/null +++ b/purchase_all_shipments/i18n/purchase_all_shipments.pot @@ -0,0 +1,35 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * purchase_all_shipments +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: purchase_all_shipments +#: model:ir.model.fields,field_description:purchase_all_shipments.field_purchase_order__all_picking_ids +#: model_terms:ir.ui.view,arch_db:purchase_all_shipments.purchase_order_view_form_inherit +msgid "All Pickings" +msgstr "" + +#. module: purchase_all_shipments +#: model:ir.model.fields,field_description:purchase_all_shipments.field_purchase_order__all_picking_count +msgid "All Pickings Count" +msgstr "" + +#. module: purchase_all_shipments +#: model_terms:ir.ui.view,arch_db:purchase_all_shipments.purchase_order_view_form_inherit +msgid "All Pickings, including chained" +msgstr "" + +#. module: purchase_all_shipments +#: model:ir.model,name:purchase_all_shipments.model_purchase_order +msgid "Purchase Order" +msgstr "" diff --git a/purchase_all_shipments/models/__init__.py b/purchase_all_shipments/models/__init__.py new file mode 100644 index 00000000000..9f03530643d --- /dev/null +++ b/purchase_all_shipments/models/__init__.py @@ -0,0 +1 @@ +from . import purchase_order diff --git a/purchase_all_shipments/models/purchase_order.py b/purchase_all_shipments/models/purchase_order.py new file mode 100644 index 00000000000..c54d10d2739 --- /dev/null +++ b/purchase_all_shipments/models/purchase_order.py @@ -0,0 +1,51 @@ +# Copyright 2018 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) +from odoo import fields, models + + +class PurchaseOrder(models.Model): + _inherit = "purchase.order" + + all_picking_ids = fields.One2many( + "stock.picking", string="All Pickings", compute="_compute_all_pickings" + ) + all_picking_count = fields.Integer( + "All Pickings Count", compute="_compute_all_picking_count" + ) + + def _compute_all_picking_count(self): + for rec in self: + rec.all_picking_count = len(rec.all_picking_ids) + + def _compute_all_pickings(self): + for rec in self: + groups = rec.mapped("picking_ids.group_id") + all_picking_ids = self.env["stock.picking"].search( + [("group_id", "in", groups.ids)] + ) + rec.all_picking_ids = all_picking_ids + + def action_view_all_pickings(self): + return self._get_action_view_all_pickings(self.all_picking_ids) + + def _get_action_view_all_pickings(self, picking_ids): + """Similar to the _get_action_view_picking method in the purchase module""" + self.ensure_one() + result = self.env["ir.actions.actions"]._for_xml_id( + "stock.action_picking_tree_all" + ) + # override the context to get rid of the default filtering on picking type + result["context"] = {} + + if not picking_ids or len(picking_ids) > 1: + result["domain"] = [("id", "in", picking_ids.ids)] + elif len(picking_ids) == 1: + res = self.env.ref("stock.view_picking_form", False) + form_view = [(res and res.id or False, "form")] + result["views"] = form_view + [ + (state, view) + for state, view in result.get("views", []) + if view != "form" + ] + result["res_id"] = picking_ids.id + return result diff --git a/purchase_all_shipments/pyproject.toml b/purchase_all_shipments/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/purchase_all_shipments/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/purchase_all_shipments/readme/CONTRIBUTORS.md b/purchase_all_shipments/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..73336589cb1 --- /dev/null +++ b/purchase_all_shipments/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Leonardo Pistone \<\> +- Nicolas Mac Rouillon \<\> diff --git a/purchase_all_shipments/readme/DESCRIPTION.md b/purchase_all_shipments/readme/DESCRIPTION.md new file mode 100644 index 00000000000..a79a7f53688 --- /dev/null +++ b/purchase_all_shipments/readme/DESCRIPTION.md @@ -0,0 +1,16 @@ +With the core "purchase" module, in a purchase order a button "In +Shipments" lets the user see the picking that was generated by the order +itself. + +With this module, that button is replaced by an "All Shipments" button +that shows the original picking, and all others that are grouped with +it. This should include pickings associated to the procurements that +generated the purchase, and also pickings that have been chained with +push rules. + +This is consistent with the "sale" module, where from the sale order the +user can access the generated delivery and all chained ones. + +The implementation uses the procurement group of the moves in the +generated picking. The procurement group is always present in purchases, +also when there is no procurement. diff --git a/purchase_all_shipments/static/description/icon.png b/purchase_all_shipments/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/purchase_all_shipments/static/description/icon.png differ diff --git a/purchase_all_shipments/static/description/index.html b/purchase_all_shipments/static/description/index.html new file mode 100644 index 00000000000..75bce70e777 --- /dev/null +++ b/purchase_all_shipments/static/description/index.html @@ -0,0 +1,436 @@ + + + + + +Purchase All Shipments + + + +
+

Purchase All Shipments

+ + +

Beta License: AGPL-3 OCA/purchase-workflow Translate me on Weblate Try me on Runboat

+

With the core “purchase” module, in a purchase order a button “In +Shipments” lets the user see the picking that was generated by the order +itself.

+

With this module, that button is replaced by an “All Shipments” button +that shows the original picking, and all others that are grouped with +it. This should include pickings associated to the procurements that +generated the purchase, and also pickings that have been chained with +push rules.

+

This is consistent with the “sale” module, where from the sale order the +user can access the generated delivery and all chained ones.

+

The implementation uses the procurement group of the moves in the +generated picking. The procurement group is always present in purchases, +also when there is no procurement.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Camptocamp
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/purchase-workflow project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/purchase_all_shipments/tests/__init__.py b/purchase_all_shipments/tests/__init__.py new file mode 100644 index 00000000000..19f196fac18 --- /dev/null +++ b/purchase_all_shipments/tests/__init__.py @@ -0,0 +1 @@ +from . import test_three_step_reception diff --git a/purchase_all_shipments/tests/test_three_step_reception.py b/purchase_all_shipments/tests/test_three_step_reception.py new file mode 100644 index 00000000000..deee80c2596 --- /dev/null +++ b/purchase_all_shipments/tests/test_three_step_reception.py @@ -0,0 +1,65 @@ +# Copyright 2018 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo.tests.common import TransactionCase + + +class TestThreeStepReception(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.wh = cls.env.ref("stock.warehouse0") + cls.po = cls.env.ref("purchase.purchase_order_1") + + def test_three_steps_generate_three_pickings(self): + self.wh.reception_steps = "three_steps" + self.po.button_confirm() + self.assertEqual(1, self.po.incoming_picking_count) + self.assertEqual(1, self.po.all_picking_count) + self.po.all_picking_ids.filtered( + lambda x: x.state == "assigned" + ).button_validate() + self.po._compute_all_pickings() + self.po._compute_all_picking_count() + self.assertEqual(2, self.po.all_picking_count) + self.po.all_picking_ids.filtered( + lambda x: x.state == "assigned" + ).button_validate() + self.po._compute_all_pickings() + self.po._compute_all_picking_count() + self.assertEqual(3, self.po.all_picking_count) + + def test_action_view_all_pickings_one_step(self): + self.po.button_confirm() + action_data = self.po.action_view_all_pickings() + form_view = self.env.ref("stock.view_picking_form") + self.assertEqual(1, self.po.all_picking_count) + self.assertEqual( + action_data["views"], + [(form_view.id, "form")] + + [ + (state, view) + for state, view in action_data.get("views", []) + if view != "form" + ], + ) + self.assertEqual(action_data["res_id"], self.po.all_picking_ids.id) + + def test_action_view_all_pickings_three_step(self): + self.wh.reception_steps = "three_steps" + self.po.button_confirm() + action_data = self.po.action_view_all_pickings() + self.assertEqual([action_data["res_id"]], self.po.all_picking_ids.ids) + self.po.all_picking_ids.filtered( + lambda x: x.state == "assigned" + ).button_validate() + self.po._compute_all_pickings() + self.po.all_picking_ids.filtered( + lambda x: x.state == "assigned" + ).button_validate() + self.po._compute_all_pickings() + action_data = self.po.action_view_all_pickings() + self.assertEqual( + action_data["domain"], + [("id", "in", self.po.all_picking_ids.ids)], + ) diff --git a/purchase_all_shipments/views/purchase_order_views.xml b/purchase_all_shipments/views/purchase_order_views.xml new file mode 100644 index 00000000000..5d69db02461 --- /dev/null +++ b/purchase_all_shipments/views/purchase_order_views.xml @@ -0,0 +1,36 @@ + + + + purchase.order.form + purchase.order + + + + + + + + 1 + + + +