From 5c052b114b261fe965b53af74155f37243609fa5 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 17 Apr 2024 16:48:51 +0200 Subject: [PATCH 1/2] [ADD] stock_weighing_auto_create_lot: New module TT47127 --- .../addons/stock_weighing_auto_create_lot | 1 + setup/stock_weighing_auto_create_lot/setup.py | 6 + stock_weighing_auto_create_lot/README.rst | 94 ++++ stock_weighing_auto_create_lot/__init__.py | 1 + .../__manifest__.py | 14 + .../readme/CONFIGURE.md | 8 + .../readme/CONTRIBUTORS.md | 3 + .../readme/DESCRIPTION.md | 1 + .../static/description/index.html | 438 ++++++++++++++++++ .../wizards/__init__.py | 1 + .../wizards/weighing_wizard.py | 34 ++ .../wizards/weighing_wizard_views.xml | 19 + 12 files changed, 620 insertions(+) create mode 120000 setup/stock_weighing_auto_create_lot/odoo/addons/stock_weighing_auto_create_lot create mode 100644 setup/stock_weighing_auto_create_lot/setup.py create mode 100644 stock_weighing_auto_create_lot/README.rst create mode 100644 stock_weighing_auto_create_lot/__init__.py create mode 100644 stock_weighing_auto_create_lot/__manifest__.py create mode 100644 stock_weighing_auto_create_lot/readme/CONFIGURE.md create mode 100644 stock_weighing_auto_create_lot/readme/CONTRIBUTORS.md create mode 100644 stock_weighing_auto_create_lot/readme/DESCRIPTION.md create mode 100644 stock_weighing_auto_create_lot/static/description/index.html create mode 100644 stock_weighing_auto_create_lot/wizards/__init__.py create mode 100644 stock_weighing_auto_create_lot/wizards/weighing_wizard.py create mode 100644 stock_weighing_auto_create_lot/wizards/weighing_wizard_views.xml diff --git a/setup/stock_weighing_auto_create_lot/odoo/addons/stock_weighing_auto_create_lot b/setup/stock_weighing_auto_create_lot/odoo/addons/stock_weighing_auto_create_lot new file mode 120000 index 000000000000..17fcdb6bda6f --- /dev/null +++ b/setup/stock_weighing_auto_create_lot/odoo/addons/stock_weighing_auto_create_lot @@ -0,0 +1 @@ +../../../../stock_weighing_auto_create_lot \ No newline at end of file diff --git a/setup/stock_weighing_auto_create_lot/setup.py b/setup/stock_weighing_auto_create_lot/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/stock_weighing_auto_create_lot/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_weighing_auto_create_lot/README.rst b/stock_weighing_auto_create_lot/README.rst new file mode 100644 index 000000000000..4f517283cd98 --- /dev/null +++ b/stock_weighing_auto_create_lot/README.rst @@ -0,0 +1,94 @@ +================================== +Weighing assistant auto create lot +================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:bbf5200fbad17a533d96a7cef44d171f3f3a6c3e316341f58816cda27c41e6ca + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fstock--logistics--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-workflow/tree/15.0/stock_weighing_auto_create_lot + :alt: OCA/stock-logistics-workflow +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-workflow-15-0/stock-logistics-workflow-15-0-stock_weighing_auto_create_lot + :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/stock-logistics-workflow&target_branch=15.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Auto-create lots when adding detailed operations from the weight kanban +card. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +You need to allow to auto-create lots in your operation type. Doing so, +you'll be able to auto-assign a lot when creating a new operation from +the weighing card. + +Remeber that you need to go to *Inventory > Configuration > Operation +Types* and set *Auto Create Lot* on in the type you want to. + +Also take into account that only products with the *Auto Create Lot* +flag will have this feature. Set it on on the product's form +traceability options. + +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 +------- + +* Tecnativa + +Contributors +------------ + +- `Tecnativa `__ + + - David Vidal + - Sergio Teruel + +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/stock-logistics-workflow `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_weighing_auto_create_lot/__init__.py b/stock_weighing_auto_create_lot/__init__.py new file mode 100644 index 000000000000..5cb1c49143f5 --- /dev/null +++ b/stock_weighing_auto_create_lot/__init__.py @@ -0,0 +1 @@ +from . import wizards diff --git a/stock_weighing_auto_create_lot/__manifest__.py b/stock_weighing_auto_create_lot/__manifest__.py new file mode 100644 index 000000000000..72384e4f990d --- /dev/null +++ b/stock_weighing_auto_create_lot/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2024 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Weighing assistant auto create lot", + "summary": "Allow to create lots from the weighing kanban cards", + "version": "15.0.1.0.0", + "development_status": "Beta", + "category": "Warehouse", + "website": "https://github.com/OCA/stock-logistics-workflow", + "author": "Tecnativa, Odoo Community Association (OCA)", + "license": "AGPL-3", + "depends": ["stock_weighing", "stock_picking_auto_create_lot"], + "data": ["wizards/weighing_wizard_views.xml"], +} diff --git a/stock_weighing_auto_create_lot/readme/CONFIGURE.md b/stock_weighing_auto_create_lot/readme/CONFIGURE.md new file mode 100644 index 000000000000..dc587798e1d4 --- /dev/null +++ b/stock_weighing_auto_create_lot/readme/CONFIGURE.md @@ -0,0 +1,8 @@ +You need to allow to auto-create lots in your operation type. Doing so, you'll be able +to auto-assign a lot when creating a new operation from the weighing card. + +Remeber that you need to go to *Inventory > Configuration > Operation Types* and set +*Auto Create Lot* on in the type you want to. + +Also take into account that only products with the *Auto Create Lot* flag will have +this feature. Set it on on the product's form traceability options. diff --git a/stock_weighing_auto_create_lot/readme/CONTRIBUTORS.md b/stock_weighing_auto_create_lot/readme/CONTRIBUTORS.md new file mode 100644 index 000000000000..295408bb40c4 --- /dev/null +++ b/stock_weighing_auto_create_lot/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- [Tecnativa](https://www.tecnativa.com) + - David Vidal + - Sergio Teruel diff --git a/stock_weighing_auto_create_lot/readme/DESCRIPTION.md b/stock_weighing_auto_create_lot/readme/DESCRIPTION.md new file mode 100644 index 000000000000..9344ca3c4412 --- /dev/null +++ b/stock_weighing_auto_create_lot/readme/DESCRIPTION.md @@ -0,0 +1 @@ +Auto-create lots when adding detailed operations from the weight kanban card. diff --git a/stock_weighing_auto_create_lot/static/description/index.html b/stock_weighing_auto_create_lot/static/description/index.html new file mode 100644 index 000000000000..6ce968602f74 --- /dev/null +++ b/stock_weighing_auto_create_lot/static/description/index.html @@ -0,0 +1,438 @@ + + + + + + +Weighing assistant auto create lot + + + +
+

Weighing assistant auto create lot

+ + +

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

+

Auto-create lots when adding detailed operations from the weight kanban +card.

+

Table of contents

+ +
+

Configuration

+

You need to allow to auto-create lots in your operation type. Doing so, +you’ll be able to auto-assign a lot when creating a new operation from +the weighing card.

+

Remeber that you need to go to Inventory > Configuration > Operation +Types and set Auto Create Lot on in the type you want to.

+

Also take into account that only products with the Auto Create Lot +flag will have this feature. Set it on on the product’s form +traceability options.

+
+
+

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

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa
      +
    • David Vidal
    • +
    • Sergio Teruel
    • +
    +
  • +
+
+
+

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/stock-logistics-workflow project on GitHub.

+

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

+
+
+
+ + diff --git a/stock_weighing_auto_create_lot/wizards/__init__.py b/stock_weighing_auto_create_lot/wizards/__init__.py new file mode 100644 index 000000000000..2baf4cfb2bf0 --- /dev/null +++ b/stock_weighing_auto_create_lot/wizards/__init__.py @@ -0,0 +1 @@ +from . import weighing_wizard diff --git a/stock_weighing_auto_create_lot/wizards/weighing_wizard.py b/stock_weighing_auto_create_lot/wizards/weighing_wizard.py new file mode 100644 index 000000000000..b5fa58e78ac4 --- /dev/null +++ b/stock_weighing_auto_create_lot/wizards/weighing_wizard.py @@ -0,0 +1,34 @@ +# Copyright 2024 Tecnativa - David Vidal +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import api, fields, models + + +class WeighingWizard(models.TransientModel): + _inherit = "weighing.wizard" + + show_auto_lot_info = fields.Boolean(compute="_compute_show_auto_lot_info") + + @api.depends("lot_id") + def _compute_show_auto_lot_info(self): + self.show_auto_lot_info = False + self.filtered( + lambda x: (x.product_tracking != "none" and not self.lot_id) + and x.wizard_state != "weight" + and x.move_id.picking_type_id.auto_create_lot + and x.product_id.auto_create_lot + ).show_auto_lot_info = True + + def _lot_creation_constraints(self): + """It will raise an exception only if no autlot is allowd""" + conditions = super()._lot_creation_constraints() + conditions += [ + not self.move_id.picking_type_id.auto_create_lot, + not self.product_id.auto_create_lot, + ] + return conditions + + def _post_add_detailed_operation(self): + """After creating a new detailed operation for lot auto-assigning""" + self.selected_move_line_id.with_context( + bypass_reservation_update=True + ).set_lot_auto() diff --git a/stock_weighing_auto_create_lot/wizards/weighing_wizard_views.xml b/stock_weighing_auto_create_lot/wizards/weighing_wizard_views.xml new file mode 100644 index 000000000000..cec48ada9d6b --- /dev/null +++ b/stock_weighing_auto_create_lot/wizards/weighing_wizard_views.xml @@ -0,0 +1,19 @@ + + + + + weighing.wizard + + + + + + + + From 8613ee9020b18b9a7796c2f3ea05ddad5b724e99 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 17 Apr 2024 17:06:50 +0200 Subject: [PATCH 2/2] [DON'T MERGE] unreleased deps --- test-requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test-requirements.txt b/test-requirements.txt index 4ad8e0eceaa8..663d810d17eb 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1 +1,2 @@ odoo-test-helper +odoo-addon-stock_weighing @ git+https://github.com/OCA/stock-logistics-workflow.git@refs/pull/1572/head#subdirectory=setup/stock_weighing