From 813ec88f24c291a7cf8726fa61c3ca56e546afec Mon Sep 17 00:00:00 2001 From: JuMiSanAr Date: Tue, 13 Feb 2024 11:42:44 +0100 Subject: [PATCH] Add shopfloor_checkout_done --- .../odoo/addons/shopfloor_checkout_done | 1 + setup/shopfloor_checkout_done/setup.py | 6 + shopfloor_checkout_done/README.rst | 86 ++++ shopfloor_checkout_done/__init__.py | 1 + shopfloor_checkout_done/__manifest__.py | 16 + shopfloor_checkout_done/models/__init__.py | 1 + .../models/stock_picking.py | 21 + .../readme/CONTRIBUTORS.rst | 1 + .../readme/DESCRIPTION.rst | 6 + .../static/description/index.html | 431 ++++++++++++++++++ shopfloor_checkout_done/tests/__init__.py | 1 + .../tests/test_stock_picking.py | 28 ++ 12 files changed, 599 insertions(+) create mode 120000 setup/shopfloor_checkout_done/odoo/addons/shopfloor_checkout_done create mode 100644 setup/shopfloor_checkout_done/setup.py create mode 100644 shopfloor_checkout_done/README.rst create mode 100644 shopfloor_checkout_done/__init__.py create mode 100644 shopfloor_checkout_done/__manifest__.py create mode 100644 shopfloor_checkout_done/models/__init__.py create mode 100644 shopfloor_checkout_done/models/stock_picking.py create mode 100644 shopfloor_checkout_done/readme/CONTRIBUTORS.rst create mode 100644 shopfloor_checkout_done/readme/DESCRIPTION.rst create mode 100644 shopfloor_checkout_done/static/description/index.html create mode 100644 shopfloor_checkout_done/tests/__init__.py create mode 100644 shopfloor_checkout_done/tests/test_stock_picking.py diff --git a/setup/shopfloor_checkout_done/odoo/addons/shopfloor_checkout_done b/setup/shopfloor_checkout_done/odoo/addons/shopfloor_checkout_done new file mode 120000 index 00000000000..e51af3e31aa --- /dev/null +++ b/setup/shopfloor_checkout_done/odoo/addons/shopfloor_checkout_done @@ -0,0 +1 @@ +../../../../shopfloor_checkout_done \ No newline at end of file diff --git a/setup/shopfloor_checkout_done/setup.py b/setup/shopfloor_checkout_done/setup.py new file mode 100644 index 00000000000..28c57bb6403 --- /dev/null +++ b/setup/shopfloor_checkout_done/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/shopfloor_checkout_done/README.rst b/shopfloor_checkout_done/README.rst new file mode 100644 index 00000000000..c86f826b421 --- /dev/null +++ b/shopfloor_checkout_done/README.rst @@ -0,0 +1,86 @@ +======================= +Shopfloor Checkout Done +======================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:9a6a9672d9e7e68f347f7df95e83665de1796e38958445e3e2ece6b5f681193a + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |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%2Fwms-lightgray.png?logo=github + :target: https://github.com/OCA/wms/tree/14.0/shopfloor_checkout_done + :alt: OCA/wms +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/wms-14-0/wms-14-0-shopfloor_checkout_done + :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/wms&target_branch=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module overrides the put_in_pack method from stock.picking +so that it marks lines as shopfloor_checkout_done +when putting them in a pack from the backend. + +This is done to make sure that these lines are displayed +in the shopfloor frontend even if they're handled in the backend. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**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 +~~~~~~~~~~~~ + +* Juan Miguel Sánchez Arce + +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/wms `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/shopfloor_checkout_done/__init__.py b/shopfloor_checkout_done/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /dev/null +++ b/shopfloor_checkout_done/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/shopfloor_checkout_done/__manifest__.py b/shopfloor_checkout_done/__manifest__.py new file mode 100644 index 00000000000..59bcb14f799 --- /dev/null +++ b/shopfloor_checkout_done/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2024 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Shopfloor Checkout Done", + "summary": "Marks lines as shopfloor checkout done when put in a pack in the backend", + "version": "14.0.1.0.0", + "development_status": "Alpha", + "category": "Inventory", + "author": "Camptocamp, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": [ + "shopfloor", + ], + "website": "https://github.com/OCA/wms", + "installable": True, +} diff --git a/shopfloor_checkout_done/models/__init__.py b/shopfloor_checkout_done/models/__init__.py new file mode 100644 index 00000000000..ae4c27227f1 --- /dev/null +++ b/shopfloor_checkout_done/models/__init__.py @@ -0,0 +1 @@ +from . import stock_picking diff --git a/shopfloor_checkout_done/models/stock_picking.py b/shopfloor_checkout_done/models/stock_picking.py new file mode 100644 index 00000000000..3e1cde4cca0 --- /dev/null +++ b/shopfloor_checkout_done/models/stock_picking.py @@ -0,0 +1,21 @@ +# Copyright 2024 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import models + + +class Picking(models.Model): + _inherit = "stock.picking" + + def _put_in_pack(self, move_line_ids, create_package_level=True): + """ + Marks the corresponding move lines as 'shopfloor_checkout_done' + when the package is created in the backend. + + """ + new_package = super()._put_in_pack(move_line_ids, create_package_level) + lines = self.move_line_ids.filtered( + lambda p: p.result_package_id == new_package + ) + lines.write({"shopfloor_checkout_done": True}) + return new_package diff --git a/shopfloor_checkout_done/readme/CONTRIBUTORS.rst b/shopfloor_checkout_done/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000000..a307f9f7c37 --- /dev/null +++ b/shopfloor_checkout_done/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Juan Miguel Sánchez Arce diff --git a/shopfloor_checkout_done/readme/DESCRIPTION.rst b/shopfloor_checkout_done/readme/DESCRIPTION.rst new file mode 100644 index 00000000000..b38002e3c45 --- /dev/null +++ b/shopfloor_checkout_done/readme/DESCRIPTION.rst @@ -0,0 +1,6 @@ +This module overrides the put_in_pack method from stock.picking +so that it marks lines as shopfloor_checkout_done +when putting them in a pack from the backend. + +This is done to make sure that these lines are displayed +in the shopfloor frontend even if they're handled in the backend. \ No newline at end of file diff --git a/shopfloor_checkout_done/static/description/index.html b/shopfloor_checkout_done/static/description/index.html new file mode 100644 index 00000000000..959ff2b2688 --- /dev/null +++ b/shopfloor_checkout_done/static/description/index.html @@ -0,0 +1,431 @@ + + + + + + +Shopfloor Checkout Done + + + +
+

Shopfloor Checkout Done

+ + +

Alpha License: AGPL-3 OCA/wms Translate me on Weblate Try me on Runboat

+

This module overrides the put_in_pack method from stock.picking +so that it marks lines as shopfloor_checkout_done +when putting them in a pack from the backend.

+

This is done to make sure that these lines are displayed +in the shopfloor frontend even if they’re handled in the backend.

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

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/wms project on GitHub.

+

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

+
+
+
+ + diff --git a/shopfloor_checkout_done/tests/__init__.py b/shopfloor_checkout_done/tests/__init__.py new file mode 100644 index 00000000000..438bdb918c8 --- /dev/null +++ b/shopfloor_checkout_done/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_picking diff --git a/shopfloor_checkout_done/tests/test_stock_picking.py b/shopfloor_checkout_done/tests/test_stock_picking.py new file mode 100644 index 00000000000..da0a2bd7b92 --- /dev/null +++ b/shopfloor_checkout_done/tests/test_stock_picking.py @@ -0,0 +1,28 @@ +from odoo.addons.shopfloor.tests.test_checkout_base import CheckoutCommonCase + + +class TestStockPicking(CheckoutCommonCase): + def test_put_in_pack(self): + picking = self._create_picking( + lines=[(self.product_a, 10), (self.product_b, 20)] + ) + self._fill_stock_for_moves(picking.move_lines) + picking.action_assign() + + # Test that the move lines are marked as 'shopfloor_checkout_done' + # when putting them in a pack in the backend. + picking._put_in_pack(picking.move_line_ids) + self.assertTrue( + all(line.shopfloor_checkout_done for line in picking.move_line_ids) + ) + + # Check that we return those lines to the frontend. + res = self.service.dispatch( + "summary", + params={ + "picking_id": picking.id, + }, + ) + returned_lines = res["data"]["summary"]["picking"]["move_lines"] + expected_line_ids = [line["id"] for line in returned_lines] + self.assertEqual(expected_line_ids, picking.move_line_ids.ids)