diff --git a/setup/stock_quant_history_queued/odoo/addons/stock_quant_history_queued b/setup/stock_quant_history_queued/odoo/addons/stock_quant_history_queued new file mode 120000 index 0000000..87dfd1a --- /dev/null +++ b/setup/stock_quant_history_queued/odoo/addons/stock_quant_history_queued @@ -0,0 +1 @@ +../../../../stock_quant_history_queued \ No newline at end of file diff --git a/setup/stock_quant_history_queued/setup.py b/setup/stock_quant_history_queued/setup.py new file mode 100644 index 0000000..28c57bb --- /dev/null +++ b/setup/stock_quant_history_queued/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_quant_history_queued/README.rst b/stock_quant_history_queued/README.rst new file mode 100644 index 0000000..eb628e3 --- /dev/null +++ b/stock_quant_history_queued/README.rst @@ -0,0 +1,83 @@ +========================== +Stock Quant History Queued +========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:885b8e66a029724a63248ef3cb53e1e5f6906fefd773e4ea69a203f2af5d8e46 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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--reporting-lightgray.png?logo=github + :target: https://github.com/OCA/stock-logistics-reporting/tree/14.0/stock_quant_history_queued + :alt: OCA/stock-logistics-reporting +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/stock-logistics-reporting-14-0/stock-logistics-reporting-14-0-stock_quant_history_queued + :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-reporting&target_branch=14.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module use queue job to regenerate stock.quant.history +asynchronously. + +This add the *In Progress* state on stock history snapshot and +delegate the generation to a queue job process. + +**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 +~~~~~~~ + +* Pierre Verkest + +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. + +.. |maintainer-petrus-v| image:: https://github.com/petrus-v.png?size=40px + :target: https://github.com/petrus-v + :alt: petrus-v + +Current `maintainer `__: + +|maintainer-petrus-v| + +This module is part of the `OCA/stock-logistics-reporting `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/stock_quant_history_queued/__init__.py b/stock_quant_history_queued/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/stock_quant_history_queued/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/stock_quant_history_queued/__manifest__.py b/stock_quant_history_queued/__manifest__.py new file mode 100644 index 0000000..b2f41ca --- /dev/null +++ b/stock_quant_history_queued/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright 2024 Foodles (https://www.foodles.co/). +# @author Pierre Verkest +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Stock Quant History Queued", + "summary": "Use Queue jop to generate stock quants snapshots", + "version": "14.0.1.0.0", + "license": "AGPL-3", + "author": "Pierre Verkest , Odoo Community Association (OCA)", + "website": "https://github.com/OCA/stock-logistics-reporting", + "depends": ["stock_quant_history", "queue_job"], + "maintainers": [ + "petrus-v", + ], + "data": [], +} diff --git a/stock_quant_history_queued/i18n/fr.po b/stock_quant_history_queued/i18n/fr.po new file mode 100644 index 0000000..310bdc8 --- /dev/null +++ b/stock_quant_history_queued/i18n/fr.po @@ -0,0 +1,47 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_quant_history_queued +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0+e\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: stock_quant_history_queued +#: model:ir.model.fields,field_description:stock_quant_history_queued.field_stock_quant_history_snapshot__display_name +msgid "Display Name" +msgstr "Libellé" + +#. module: stock_quant_history_queued +#: model:ir.model.fields,field_description:stock_quant_history_queued.field_stock_quant_history_snapshot__id +msgid "ID" +msgstr "" + +#. module: stock_quant_history_queued +#: model:ir.model.fields.selection,name:stock_quant_history_queued.selection__stock_quant_history_snapshot__state__queued +msgid "In progress" +msgstr "En cours" + +#. module: stock_quant_history_queued +#: model:ir.model.fields,field_description:stock_quant_history_queued.field_stock_quant_history_snapshot____last_update +msgid "Last Modified on" +msgstr "Dernière modification le" + +#. module: stock_quant_history_queued +#: model:ir.model.fields,field_description:stock_quant_history_queued.field_stock_quant_history_snapshot__state +msgid "Status" +msgstr "État" + +#. module: stock_quant_history_queued +#: model:ir.model,name:stock_quant_history_queued.model_stock_quant_history_snapshot +msgid "stock.quant.history generation configuration model" +msgstr "" +"Cliché de stock: Modèle de configuration pour la génération des ligne de " +"stock.quant.history" + diff --git a/stock_quant_history_queued/i18n/stock_quant_history_queued.pot b/stock_quant_history_queued/i18n/stock_quant_history_queued.pot new file mode 100644 index 0000000..bab81e7 --- /dev/null +++ b/stock_quant_history_queued/i18n/stock_quant_history_queued.pot @@ -0,0 +1,44 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_quant_history_queued +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0+e\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: stock_quant_history_queued +#: model:ir.model.fields,field_description:stock_quant_history_queued.field_stock_quant_history_snapshot__display_name +msgid "Display Name" +msgstr "" + +#. module: stock_quant_history_queued +#: model:ir.model.fields,field_description:stock_quant_history_queued.field_stock_quant_history_snapshot__id +msgid "ID" +msgstr "" + +#. module: stock_quant_history_queued +#: model:ir.model.fields.selection,name:stock_quant_history_queued.selection__stock_quant_history_snapshot__state__queued +msgid "In progress" +msgstr "" + +#. module: stock_quant_history_queued +#: model:ir.model.fields,field_description:stock_quant_history_queued.field_stock_quant_history_snapshot____last_update +msgid "Last Modified on" +msgstr "" + +#. module: stock_quant_history_queued +#: model:ir.model.fields,field_description:stock_quant_history_queued.field_stock_quant_history_snapshot__state +msgid "Status" +msgstr "" + +#. module: stock_quant_history_queued +#: model:ir.model,name:stock_quant_history_queued.model_stock_quant_history_snapshot +msgid "stock.quant.history generation configuration model" +msgstr "" diff --git a/stock_quant_history_queued/models/__init__.py b/stock_quant_history_queued/models/__init__.py new file mode 100644 index 0000000..f85d538 --- /dev/null +++ b/stock_quant_history_queued/models/__init__.py @@ -0,0 +1 @@ +from . import stock_quant_history_snapshot diff --git a/stock_quant_history_queued/models/stock_quant_history_snapshot.py b/stock_quant_history_queued/models/stock_quant_history_snapshot.py new file mode 100644 index 0000000..98d57bb --- /dev/null +++ b/stock_quant_history_queued/models/stock_quant_history_snapshot.py @@ -0,0 +1,22 @@ +# Copyright 2024 Foodles (https://www.foodles.co/). +# @author Pierre Verkest +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import fields, models + + +class StockQuantHistorySnapshot(models.Model): + _inherit = "stock.quant.history.snapshot" + state = fields.Selection( + selection_add=[("queued", "In progress"), ("generated",)], + ondelete={"queued": "set default"}, + ) + + def action_generate_stock_quant_history(self): + self._setup_queue_jobs_generate_stock_quant_history() + + def _setup_queue_jobs_generate_stock_quant_history(self): + for snapshot in self: + snapshot.state = "queued" + snapshot.with_delay( + priority=snapshot.inventory_date.timestamp() + )._generate_stock_quant_history() diff --git a/stock_quant_history_queued/readme/CONSTRIBUTORS.rst b/stock_quant_history_queued/readme/CONSTRIBUTORS.rst new file mode 100644 index 0000000..638be86 --- /dev/null +++ b/stock_quant_history_queued/readme/CONSTRIBUTORS.rst @@ -0,0 +1 @@ +* Pierre Verkest diff --git a/stock_quant_history_queued/readme/DESCRIPTION.rst b/stock_quant_history_queued/readme/DESCRIPTION.rst new file mode 100644 index 0000000..082a896 --- /dev/null +++ b/stock_quant_history_queued/readme/DESCRIPTION.rst @@ -0,0 +1,5 @@ +This module use queue job to regenerate stock.quant.history +asynchronously. + +This add the *In Progress* state on stock history snapshot and +delegate the generation to a queue job process. diff --git a/stock_quant_history_queued/static/description/index.html b/stock_quant_history_queued/static/description/index.html new file mode 100644 index 0000000..dcf416c --- /dev/null +++ b/stock_quant_history_queued/static/description/index.html @@ -0,0 +1,419 @@ + + + + + + +Stock Quant History Queued + + + +
+

Stock Quant History Queued

+ + +

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

+

This module use queue job to regenerate stock.quant.history +asynchronously.

+

This add the In Progress state on stock history snapshot and +delegate the generation to a queue job process.

+

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

+ +
+
+

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.

+

Current maintainer:

+

petrus-v

+

This module is part of the OCA/stock-logistics-reporting project on GitHub.

+

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

+
+
+
+ + diff --git a/stock_quant_history_queued/tests/__init__.py b/stock_quant_history_queued/tests/__init__.py new file mode 100644 index 0000000..a219857 --- /dev/null +++ b/stock_quant_history_queued/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_quant_history_queued diff --git a/stock_quant_history_queued/tests/test_stock_quant_history_queued.py b/stock_quant_history_queued/tests/test_stock_quant_history_queued.py new file mode 100644 index 0000000..7c5fa2e --- /dev/null +++ b/stock_quant_history_queued/tests/test_stock_quant_history_queued.py @@ -0,0 +1,42 @@ +from odoo import fields +from odoo.tests import SavepointCase + +from odoo.addons.queue_job.tests.common import trap_jobs + + +class TestStockQuantHistoryQueued(SavepointCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + + cls.stock_history_christmas_2024 = cls.env[ + "stock.quant.history.snapshot" + ].create( + { + "inventory_date": fields.Datetime.from_string("2024-12-25"), + } + ) + cls.stock_history_christmas_2023 = cls.env[ + "stock.quant.history.snapshot" + ].create( + { + "inventory_date": fields.Datetime.from_string("2023-12-25"), + } + ) + + def test_queue_job_setup(self): + recordset = ( + self.stock_history_christmas_2024 | self.stock_history_christmas_2023 + ) + with trap_jobs() as trap: + recordset.action_generate_stock_quant_history() + + trap.assert_jobs_count(2) + trap.assert_enqueued_job( + self.stock_history_christmas_2023._generate_stock_quant_history, + properties={"priority": 1703462400}, + ) + trap.assert_enqueued_job( + self.stock_history_christmas_2024._generate_stock_quant_history, + properties={"priority": 1735084800}, + )