diff --git a/purchase_all_shipments/README.rst b/purchase_all_shipments/README.rst new file mode 100644 index 00000000000..b54a5844d08 --- /dev/null +++ b/purchase_all_shipments/README.rst @@ -0,0 +1,80 @@ +====================== +Purchase All Shipments +====================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/13.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-13-0/purchase-workflow-13-0-purchase_all_shipments + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/142/13.0 + :alt: Try me on Runbot + +|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 smashing 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..f26dafebe4f --- /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": "15.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..6560db09c42 --- /dev/null +++ b/purchase_all_shipments/i18n/es.po @@ -0,0 +1,37 @@ +# 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: 2020-08-25 19:03+0000\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 "En recepciones" + +#. module: purchase_all_shipments +#: model:ir.model.fields,field_description:purchase_all_shipments.field_purchase_order__all_shipment_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 "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/purchase_all_shipments.pot b/purchase_all_shipments/i18n/purchase_all_shipments.pot new file mode 100644 index 00000000000..3f3285d96d4 --- /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 13.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..9f481df2998 --- /dev/null +++ b/purchase_all_shipments/models/purchase_order.py @@ -0,0 +1,44 @@ +# 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): + """Similar to the view_picking method in the purchase module""" + action_data = self.env.ref("stock.action_picking_tree_all").read()[0] + pickings = self.mapped("all_picking_ids") + + # override the context to get rid of the default filtering on + # picking type + action_data["context"] = {} + + # choose the view_mode accordingly + if len(pickings) > 1: + action_data["domain"] = [("id", "in", pickings.ids)] + else: + form_view = self.env.ref("stock.view_picking_form") + action_data["views"] = [(form_view.id, "form")] + action_data["res_id"] = pickings.id + return action_data diff --git a/purchase_all_shipments/readme/CONTRIBUTORS.rst b/purchase_all_shipments/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..c33e43a62b6 --- /dev/null +++ b/purchase_all_shipments/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Leonardo Pistone +* Nicolas Mac Rouillon diff --git a/purchase_all_shipments/readme/DESCRIPTION.rst b/purchase_all_shipments/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..7d08687a660 --- /dev/null +++ b/purchase_all_shipments/readme/DESCRIPTION.rst @@ -0,0 +1,7 @@ +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..f7d2053432e --- /dev/null +++ b/purchase_all_shipments/static/description/index.html @@ -0,0 +1,423 @@ + + + + + + +Purchase All Shipments + + + +
+

Purchase All Shipments

+ + +

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

+

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 smashing 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..fe215a32130 --- /dev/null +++ b/purchase_all_shipments/tests/test_three_step_reception.py @@ -0,0 +1,35 @@ +# Copyright 2018 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +from odoo.tests.common import SavepointCase + + +class TestThreeStepReception(SavepointCase): + @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(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")]) + 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["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..a80bee57d27 --- /dev/null +++ b/purchase_all_shipments/views/purchase_order_views.xml @@ -0,0 +1,36 @@ + + + + purchase.order.form + purchase.order + + + + + + + + 1 + + + + diff --git a/setup/purchase_all_shipments/odoo/addons/purchase_all_shipments b/setup/purchase_all_shipments/odoo/addons/purchase_all_shipments new file mode 120000 index 00000000000..ae0d8422143 --- /dev/null +++ b/setup/purchase_all_shipments/odoo/addons/purchase_all_shipments @@ -0,0 +1 @@ +../../../../purchase_all_shipments \ No newline at end of file diff --git a/setup/purchase_all_shipments/setup.py b/setup/purchase_all_shipments/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/purchase_all_shipments/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)