diff --git a/setup/stock_picking_low_priority/odoo/addons/stock_picking_low_priority b/setup/stock_picking_low_priority/odoo/addons/stock_picking_low_priority new file mode 120000 index 000000000000..bca3cfb44736 --- /dev/null +++ b/setup/stock_picking_low_priority/odoo/addons/stock_picking_low_priority @@ -0,0 +1 @@ +../../../../stock_picking_low_priority \ No newline at end of file diff --git a/setup/stock_picking_low_priority/setup.py b/setup/stock_picking_low_priority/setup.py new file mode 100644 index 000000000000..28c57bb64031 --- /dev/null +++ b/setup/stock_picking_low_priority/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_move_priority_picking_assign/models/__init__.py b/stock_move_priority_picking_assign/models/__init__.py index 90f60bebb8fa..d305f0d317ee 100644 --- a/stock_move_priority_picking_assign/models/__init__.py +++ b/stock_move_priority_picking_assign/models/__init__.py @@ -1,2 +1 @@ -from . import stock_move -from . import stock_picking_type +from . import stock_move, stock_picking, stock_picking_type diff --git a/stock_move_priority_picking_assign/models/stock_move.py b/stock_move_priority_picking_assign/models/stock_move.py index da8870095682..33535c65fa7a 100644 --- a/stock_move_priority_picking_assign/models/stock_move.py +++ b/stock_move_priority_picking_assign/models/stock_move.py @@ -35,6 +35,6 @@ def _search_picking_for_assignation_domain(self): domain += [("priority", "=", first(self).priority)] return domain - def _compute_priority(self): - move_without_priority = self.filtered(lambda m: not m.priority) - return super(StockMove, move_without_priority)._compute_priority() + # def _compute_priority(self): + # move_without_priority = self.filtered(lambda m: not m.priority) + # return super(StockMove, move_without_priority)._compute_priority() diff --git a/stock_move_priority_picking_assign/models/stock_picking.py b/stock_move_priority_picking_assign/models/stock_picking.py new file mode 100644 index 000000000000..242b0e637f7d --- /dev/null +++ b/stock_move_priority_picking_assign/models/stock_picking.py @@ -0,0 +1,13 @@ +# Copyright 2024 ACSONE SA/NV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import models + + +class StockPicking(models.Model): + + _inherit = "stock.picking" + + def write(self, vals): + if "priority" in vals: + self.move_ids.write({"priority": False}) + return super().write(vals) diff --git a/stock_picking_low_priority/README.rst b/stock_picking_low_priority/README.rst new file mode 100644 index 000000000000..ed6211ae5b4f --- /dev/null +++ b/stock_picking_low_priority/README.rst @@ -0,0 +1,76 @@ +========================== +Stock Picking Low Priority +========================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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%2Fstock--logistics--workflow-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-workflow/tree/16.0/stock_picking_low_priority + :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-16-0/stock-logistics-workflow-16-0-stock_picking_low_priority + :alt: Translate me on Weblate +.. |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-workflow&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module reintroduces a low priority (Not urgent) on stock picking +therefore stock move (compute). The goal is to make some moves less +important and serve them after others. + +**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 +~~~~~~~ + +* ACSONE SA/NV + +Contributors +~~~~~~~~~~~~ + +* Nans Lefebvre +* Hughes Damry + +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_picking_low_priority/__init__.py b/stock_picking_low_priority/__init__.py new file mode 100644 index 000000000000..3436039a6912 --- /dev/null +++ b/stock_picking_low_priority/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/stock_picking_low_priority/__manifest__.py b/stock_picking_low_priority/__manifest__.py new file mode 100644 index 000000000000..1acc962ecb07 --- /dev/null +++ b/stock_picking_low_priority/__manifest__.py @@ -0,0 +1,14 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + "name": "Stock Picking Low Priority", + "summary": """ + Reintroduces low priority in stock picking/stock move""", + "version": "16.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-workflow", + "depends": ["stock"], + "installable": True, +} diff --git a/stock_picking_low_priority/i18n/stock_picking_low_priority.pot b/stock_picking_low_priority/i18n/stock_picking_low_priority.pot new file mode 100644 index 000000000000..e5ce54b73f5a --- /dev/null +++ b/stock_picking_low_priority/i18n/stock_picking_low_priority.pot @@ -0,0 +1,45 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_picking_low_priority +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-01-20 14:00+0000\n" +"PO-Revision-Date: 2023-01-20 14:00+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: stock_picking_low_priority +#: model:ir.model.fields.selection,name:stock_picking_low_priority.selection__stock_move__priority__-1 +#: model:ir.model.fields.selection,name:stock_picking_low_priority.selection__stock_picking__priority__-1 +msgid "Not urgent" +msgstr "" + +#. module: stock_picking_low_priority +#: model:ir.model.fields,field_description:stock_picking_low_priority.field_stock_move__priority +#: model:ir.model.fields,field_description:stock_picking_low_priority.field_stock_picking__priority +msgid "Priority" +msgstr "" + +#. module: stock_picking_low_priority +#: model:ir.model.fields,help:stock_picking_low_priority.field_stock_picking__priority +msgid "" +"Products will be reserved first for the transfers with the highest " +"priorities." +msgstr "" + +#. module: stock_picking_low_priority +#: model:ir.model,name:stock_picking_low_priority.model_stock_move +msgid "Stock Move" +msgstr "" + +#. module: stock_picking_low_priority +#: model:ir.model,name:stock_picking_low_priority.model_stock_picking +msgid "Transfer" +msgstr "" diff --git a/stock_picking_low_priority/models/__init__.py b/stock_picking_low_priority/models/__init__.py new file mode 100644 index 000000000000..9ede214038e0 --- /dev/null +++ b/stock_picking_low_priority/models/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import stock_move +from . import stock_picking diff --git a/stock_picking_low_priority/models/stock_move.py b/stock_picking_low_priority/models/stock_move.py new file mode 100644 index 000000000000..a066ffa695a5 --- /dev/null +++ b/stock_picking_low_priority/models/stock_move.py @@ -0,0 +1,12 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class StockMove(models.Model): + _inherit = "stock.move" + + priority = fields.Selection( + selection_add=[("-1", "Not urgent"), ("0",)], ondelete={"-1": "set default"} + ) diff --git a/stock_picking_low_priority/models/stock_picking.py b/stock_picking_low_priority/models/stock_picking.py new file mode 100644 index 000000000000..342a5e4133e5 --- /dev/null +++ b/stock_picking_low_priority/models/stock_picking.py @@ -0,0 +1,12 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class Picking(models.Model): + _inherit = "stock.picking" + + priority = fields.Selection( + selection_add=[("-1", "Not urgent"), ("0",)], ondelete={"-1": "set default"} + ) diff --git a/stock_picking_low_priority/readme/CONTRIBUTORS.rst b/stock_picking_low_priority/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..e2702f0485c0 --- /dev/null +++ b/stock_picking_low_priority/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Nans Lefebvre +* Hughes Damry diff --git a/stock_picking_low_priority/readme/DESCRIPTION.rst b/stock_picking_low_priority/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..fd187387f71a --- /dev/null +++ b/stock_picking_low_priority/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +This module reintroduces a low priority (Not urgent) on stock picking +therefore stock move (compute). The goal is to make some moves less +important and serve them after others. diff --git a/stock_picking_low_priority/static/description/index.html b/stock_picking_low_priority/static/description/index.html new file mode 100644 index 000000000000..c86845015fa0 --- /dev/null +++ b/stock_picking_low_priority/static/description/index.html @@ -0,0 +1,422 @@ + + + + + + +Stock Picking Low Priority + + + +
+

Stock Picking Low Priority

+ + +

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

+

This module reintroduces a low priority (Non urgent) on stock picking +therefore stock move (compute). The goal is to make some moves less +important and serve them after others.

+

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

+
    +
  • ACSONE SA/NV
  • +
+
+
+

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/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_picking_low_priority/tests/__init__.py b/stock_picking_low_priority/tests/__init__.py new file mode 100644 index 000000000000..cff78ad8c4d4 --- /dev/null +++ b/stock_picking_low_priority/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_picking_low_priority diff --git a/stock_picking_low_priority/tests/test_stock_picking_low_priority.py b/stock_picking_low_priority/tests/test_stock_picking_low_priority.py new file mode 100644 index 000000000000..f31ed53d0fe2 --- /dev/null +++ b/stock_picking_low_priority/tests/test_stock_picking_low_priority.py @@ -0,0 +1,103 @@ +# Copyright 2023 ACSONE SA/NV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields +from odoo.tests import TransactionCase + + +class TestStockPickingLowPriority(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.picking_model = cls.env["stock.picking"] + cls.move_model = cls.env["stock.move"] + cls.location_model = cls.env["stock.location"] + cls.stock_location = cls.location_model.create({"name": "stock_loc"}) + cls.supplier_location = cls.location_model.create({"name": "supplier_loc"}) + cls.customer_location = cls.location_model.create({"name": "custmer_loc"}) + cls.picking_type_out = cls.env.ref("stock.picking_type_out").id + cls.picking_type_in = cls.env.ref("stock.picking_type_in").id + cls.uom_unit = cls.env.ref("uom.product_uom_unit") + cls.product = cls.env["product.product"].create( + { + "name": "Product Test", + "uom_id": cls.uom_unit.id, + "type": "product", + } + ) + + def create_picking(self, picking_type, from_loc, to_loc, sequence=10, delay=0): + picking = self.picking_model.create( + { + "picking_type_id": picking_type, + "location_id": from_loc.id, + "location_dest_id": to_loc.id, + } + ) + self.move_model.create( + { + "name": self.product.name, + "sequence": sequence, + "date": fields.Datetime.add(fields.Datetime.now(), second=delay), + "reservation_date": fields.Date.today(), + "product_id": self.product.id, + "product_uom_qty": 1, + "product_uom": self.product.uom_id.id, + "picking_id": picking.id, + "location_id": from_loc.id, + "location_dest_id": to_loc.id, + } + ) + picking.action_confirm() + return picking + + def test_selection_insertion(self): + """ + Test that the 'Not urgent' priority has been inserted in first position of the + selection + """ + priority_selection = self.picking_model.fields_get()["priority"]["selection"] + self.assertEqual(priority_selection[0], ("-1", "Not urgent")) + + def test_assign_qty_to_first_move(self): + """ + Suppose two out picking waiting for an available quantity. When receiving such + a quantity, the latter should be assign to the picking with the + highest priority. + """ + + out01 = self.create_picking( + self.picking_type_out, self.stock_location, self.customer_location + ) + out02 = self.create_picking( + self.picking_type_out, + self.stock_location, + self.customer_location, + sequence=2, + delay=1, + ) + in01 = self.create_picking( + self.picking_type_in, self.supplier_location, self.stock_location, delay=2 + ) + # normal priority for both out01 and out02 so out01 will be assigned before out02 + in01.move_ids.quantity_done = 1 + in01.button_validate() + self.assertEqual(out01.state, "assigned") + self.assertEqual(out02.state, "confirmed") + + out01.move_ids.quantity_done = 1 + out01.button_validate() + + out03 = self.create_picking( + self.picking_type_out, self.stock_location, self.customer_location, delay=3 + ) + # set out02 to not urgent so out03 will be assigned before out02 + out02.priority = "-1" + in02 = self.create_picking( + self.picking_type_in, self.supplier_location, self.stock_location, delay=4 + ) + + in02.move_ids.quantity_done = 1 + in02.button_validate() + self.assertEqual(out03.state, "assigned") + self.assertEqual(out02.state, "confirmed")