From d5cdb24e516eb67616d80918029e03b20476ddf5 Mon Sep 17 00:00:00 2001 From: Jacques-Etienne Baudoux Date: Wed, 27 Mar 2024 11:29:17 +0100 Subject: [PATCH 1/2] [IMP] stock_release_channel_plan: tests Extract setup in common for inheritance --- stock_release_channel_plan/tests/common.py | 38 +++++++++++++++++++ .../tests/test_stock_release_channel_plan.py | 36 +----------------- 2 files changed, 40 insertions(+), 34 deletions(-) create mode 100644 stock_release_channel_plan/tests/common.py diff --git a/stock_release_channel_plan/tests/common.py b/stock_release_channel_plan/tests/common.py new file mode 100644 index 0000000000..3e30d755e6 --- /dev/null +++ b/stock_release_channel_plan/tests/common.py @@ -0,0 +1,38 @@ +# Copyright 2023 Jacques-Etienne Baudoux (BCIM) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class ReleaseChannelPlanCase(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.plan1 = cls.env.ref( + "stock_release_channel_plan.stock_release_channel_preparation_plan_demo_mon" + ) + cls.plan1_channel1 = cls.env.ref( + "stock_release_channel_plan.stock_release_channel_mon_thu1" + ) + cls.plan1_channel2 = cls.env.ref( + "stock_release_channel_plan.stock_release_channel_mon_thu2" + ) + cls.plan2_channel1 = cls.env.ref( + "stock_release_channel_plan.stock_release_channel_tue_fri1" + ) + cls.plan2_channel2 = cls.env.ref( + "stock_release_channel_plan.stock_release_channel_tue_fri2" + ) + cls.plan3_channel1 = cls.env.ref( + "stock_release_channel_plan.stock_release_channel_wed1" + ) + cls.plan3_channel2 = cls.env.ref( + "stock_release_channel_plan.stock_release_channel_wed2" + ) + + def _launch_channel(self, preparation_plan): + self.env["stock.release.channel.plan.wizard.launch"].create( + { + "preparation_plan_id": preparation_plan.id, + } + ).action_launch() diff --git a/stock_release_channel_plan/tests/test_stock_release_channel_plan.py b/stock_release_channel_plan/tests/test_stock_release_channel_plan.py index f092780f76..1aadf6ad82 100644 --- a/stock_release_channel_plan/tests/test_stock_release_channel_plan.py +++ b/stock_release_channel_plan/tests/test_stock_release_channel_plan.py @@ -1,42 +1,10 @@ # Copyright 2023 Jacques-Etienne Baudoux (BCIM) # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -from odoo.tests.common import TransactionCase +from .common import ReleaseChannelPlanCase -class TestStockReleaseChannelPlan(TransactionCase): - @classmethod - def setUpClass(cls): - super().setUpClass() - cls.plan1 = cls.env.ref( - "stock_release_channel_plan.stock_release_channel_preparation_plan_demo_mon" - ) - cls.plan1_channel1 = cls.env.ref( - "stock_release_channel_plan.stock_release_channel_mon_thu1" - ) - cls.plan1_channel2 = cls.env.ref( - "stock_release_channel_plan.stock_release_channel_mon_thu2" - ) - cls.plan2_channel1 = cls.env.ref( - "stock_release_channel_plan.stock_release_channel_tue_fri1" - ) - cls.plan2_channel2 = cls.env.ref( - "stock_release_channel_plan.stock_release_channel_tue_fri2" - ) - cls.plan3_channel1 = cls.env.ref( - "stock_release_channel_plan.stock_release_channel_wed1" - ) - cls.plan3_channel2 = cls.env.ref( - "stock_release_channel_plan.stock_release_channel_wed2" - ) - - def _launch_channel(self, preparation_plan): - self.env["stock.release.channel.plan.wizard.launch"].create( - { - "preparation_plan_id": preparation_plan.id, - } - ).action_launch() - +class TestStockReleaseChannelPlan(ReleaseChannelPlanCase): def test_launch_plan(self): """Test launching plan1""" self.plan1_channel1.write({"state": "locked"}) From a2d96a6e5c75e53274c3e8e864642638aafefc35 Mon Sep 17 00:00:00 2001 From: Jacques-Etienne Baudoux Date: Fri, 28 Jul 2023 17:33:12 +0200 Subject: [PATCH 2/2] [ADD] stock_release_channel_plan_process_end_time --- ...tock_release_channel_plan_process_end_time | 1 + .../setup.py | 6 + .../README.rst | 93 ++++ .../__init__.py | 1 + .../__manifest__.py | 24 + .../demo/stock_release_channel.xml | 49 ++ .../readme/CONTRIBUTORS.rst | 1 + .../readme/CREDITS.rst | 3 + .../readme/DESCRIPTION.rst | 3 + .../static/description/index.html | 433 ++++++++++++++++++ .../tests/__init__.py | 1 + .../tests/test_stock_release_channel_plan.py | 41 ++ .../wizards/__init__.py | 1 + .../wizards/launch_plan.py | 32 ++ .../wizards/launch_plan.xml | 19 + 15 files changed, 708 insertions(+) create mode 120000 setup/stock_release_channel_plan_process_end_time/odoo/addons/stock_release_channel_plan_process_end_time create mode 100644 setup/stock_release_channel_plan_process_end_time/setup.py create mode 100644 stock_release_channel_plan_process_end_time/README.rst create mode 100644 stock_release_channel_plan_process_end_time/__init__.py create mode 100644 stock_release_channel_plan_process_end_time/__manifest__.py create mode 100644 stock_release_channel_plan_process_end_time/demo/stock_release_channel.xml create mode 100644 stock_release_channel_plan_process_end_time/readme/CONTRIBUTORS.rst create mode 100644 stock_release_channel_plan_process_end_time/readme/CREDITS.rst create mode 100644 stock_release_channel_plan_process_end_time/readme/DESCRIPTION.rst create mode 100644 stock_release_channel_plan_process_end_time/static/description/index.html create mode 100644 stock_release_channel_plan_process_end_time/tests/__init__.py create mode 100644 stock_release_channel_plan_process_end_time/tests/test_stock_release_channel_plan.py create mode 100644 stock_release_channel_plan_process_end_time/wizards/__init__.py create mode 100644 stock_release_channel_plan_process_end_time/wizards/launch_plan.py create mode 100644 stock_release_channel_plan_process_end_time/wizards/launch_plan.xml diff --git a/setup/stock_release_channel_plan_process_end_time/odoo/addons/stock_release_channel_plan_process_end_time b/setup/stock_release_channel_plan_process_end_time/odoo/addons/stock_release_channel_plan_process_end_time new file mode 120000 index 0000000000..0e501e51b6 --- /dev/null +++ b/setup/stock_release_channel_plan_process_end_time/odoo/addons/stock_release_channel_plan_process_end_time @@ -0,0 +1 @@ +../../../../stock_release_channel_plan_process_end_time \ No newline at end of file diff --git a/setup/stock_release_channel_plan_process_end_time/setup.py b/setup/stock_release_channel_plan_process_end_time/setup.py new file mode 100644 index 0000000000..28c57bb640 --- /dev/null +++ b/setup/stock_release_channel_plan_process_end_time/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +) diff --git a/stock_release_channel_plan_process_end_time/README.rst b/stock_release_channel_plan_process_end_time/README.rst new file mode 100644 index 0000000000..0498fac303 --- /dev/null +++ b/stock_release_channel_plan_process_end_time/README.rst @@ -0,0 +1,93 @@ +=========================================== +Stock Release Channel Plan Process End Time +=========================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:2ee3d55c2582fba0375a666a2a7e848d726ed6d6f7cd7c57cb298222fd7fad74 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fwms-lightgray.png?logo=github + :target: https://github.com/OCA/wms/tree/16.0/stock_release_channel_plan_process_end_time + :alt: OCA/wms +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/wms-16-0/wms-16-0-stock_release_channel_plan_process_end_time + :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=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +At launching a plan, a process end date is set on each release channel of the +plan. It is then up to you to process the content of the release channel and at +then end, close it and make it asleep. + +**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 +~~~~~~~ + +* BCIM + +Contributors +~~~~~~~~~~~~ + +* Jacques-Etienne Baudoux + +Other credits +~~~~~~~~~~~~~ + +**Financial support** + +* Alcyon Belux + +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-jbaudoux| image:: https://github.com/jbaudoux.png?size=40px + :target: https://github.com/jbaudoux + :alt: jbaudoux + +Current `maintainer `__: + +|maintainer-jbaudoux| + +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/stock_release_channel_plan_process_end_time/__init__.py b/stock_release_channel_plan_process_end_time/__init__.py new file mode 100644 index 0000000000..5cb1c49143 --- /dev/null +++ b/stock_release_channel_plan_process_end_time/__init__.py @@ -0,0 +1 @@ +from . import wizards diff --git a/stock_release_channel_plan_process_end_time/__manifest__.py b/stock_release_channel_plan_process_end_time/__manifest__.py new file mode 100644 index 0000000000..7b6a4d6323 --- /dev/null +++ b/stock_release_channel_plan_process_end_time/__manifest__.py @@ -0,0 +1,24 @@ +# Copyright 2023 Jacques-Etienne Baudoux (BCIM) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Stock Release Channel Plan Process End Time", + "summary": "Glue module between release channel plan and process end time", + "version": "16.0.1.0.0", + "development_status": "Beta", + "license": "AGPL-3", + "author": "BCIM,Odoo Community Association (OCA)", + "maintainers": ["jbaudoux"], + "website": "https://github.com/OCA/wms", + "depends": [ + "stock_release_channel_plan", + "stock_release_channel_process_end_time", + ], + "data": [ + "wizards/launch_plan.xml", + ], + "demo": [ + "demo/stock_release_channel.xml", + ], + "auto_install": True, +} diff --git a/stock_release_channel_plan_process_end_time/demo/stock_release_channel.xml b/stock_release_channel_plan_process_end_time/demo/stock_release_channel.xml new file mode 100644 index 0000000000..ca7427a2ba --- /dev/null +++ b/stock_release_channel_plan_process_end_time/demo/stock_release_channel.xml @@ -0,0 +1,49 @@ + + + + + + + 10.0 + + + + 14.0 + + + + 10.0 + + + + 14.0 + + + + 10.0 + + + + 14.0 + + + diff --git a/stock_release_channel_plan_process_end_time/readme/CONTRIBUTORS.rst b/stock_release_channel_plan_process_end_time/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000000..ed5b9eb64d --- /dev/null +++ b/stock_release_channel_plan_process_end_time/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Jacques-Etienne Baudoux diff --git a/stock_release_channel_plan_process_end_time/readme/CREDITS.rst b/stock_release_channel_plan_process_end_time/readme/CREDITS.rst new file mode 100644 index 0000000000..52c8452898 --- /dev/null +++ b/stock_release_channel_plan_process_end_time/readme/CREDITS.rst @@ -0,0 +1,3 @@ +**Financial support** + +* Alcyon Belux diff --git a/stock_release_channel_plan_process_end_time/readme/DESCRIPTION.rst b/stock_release_channel_plan_process_end_time/readme/DESCRIPTION.rst new file mode 100644 index 0000000000..1320df1da5 --- /dev/null +++ b/stock_release_channel_plan_process_end_time/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +At launching a plan, a process end date is set on each release channel of the +plan. It is then up to you to process the content of the release channel and at +then end, close it and make it asleep. diff --git a/stock_release_channel_plan_process_end_time/static/description/index.html b/stock_release_channel_plan_process_end_time/static/description/index.html new file mode 100644 index 0000000000..26038b16a2 --- /dev/null +++ b/stock_release_channel_plan_process_end_time/static/description/index.html @@ -0,0 +1,433 @@ + + + + + + +Stock Release Channel Plan Process End Time + + + +
+

Stock Release Channel Plan Process End Time

+ + +

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

+

At launching a plan, a process end date is set on each release channel of the +plan. It is then up to you to process the content of the release channel and at +then end, close it and make it asleep.

+

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

+
    +
  • BCIM
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

Financial support

+
    +
  • Alcyon Belux
  • +
+
+
+

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:

+

jbaudoux

+

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/stock_release_channel_plan_process_end_time/tests/__init__.py b/stock_release_channel_plan_process_end_time/tests/__init__.py new file mode 100644 index 0000000000..45df8e16e0 --- /dev/null +++ b/stock_release_channel_plan_process_end_time/tests/__init__.py @@ -0,0 +1 @@ +from . import test_stock_release_channel_plan diff --git a/stock_release_channel_plan_process_end_time/tests/test_stock_release_channel_plan.py b/stock_release_channel_plan_process_end_time/tests/test_stock_release_channel_plan.py new file mode 100644 index 0000000000..5a878829bb --- /dev/null +++ b/stock_release_channel_plan_process_end_time/tests/test_stock_release_channel_plan.py @@ -0,0 +1,41 @@ +# Copyright 2023 Jacques-Etienne Baudoux (BCIM) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from datetime import datetime + +import pytz + +from odoo import fields + +from odoo.addons.partner_tz.tools.tz_utils import tz_to_utc_naive_datetime +from odoo.addons.stock_release_channel_plan.tests.common import ReleaseChannelPlanCase +from odoo.addons.stock_release_channel_process_end_time.utils import float_to_time + + +class TestStockReleaseChannelPlan(ReleaseChannelPlanCase): + def test_launch_plan(self): + channel = self.plan1_channel1 + channel.process_end_date = False + tz_name = "Europe/Brussels" + channel.warehouse_id.partner_id.tz = tz_name + + channel.write({"state": "asleep"}) + self._launch_channel(self.plan1) + self.assertEqual(channel.state, "open") + + end_time = float_to_time(channel.process_end_time) # in TZ + end_date = datetime.combine( + fields.Date.context_today(channel), end_time + ) # in TZ + end_date_utc = tz_to_utc_naive_datetime(channel.process_end_time_tz, end_date) + self.assertEqual( + channel.process_end_date, + end_date_utc, + ) + # Local Time is 10 + offset = pytz.timezone(tz_name).utcoffset(datetime.now()).total_seconds() / 3600 + self.assertEqual( + channel.process_end_date.hour, + 10 - offset, + ) + return diff --git a/stock_release_channel_plan_process_end_time/wizards/__init__.py b/stock_release_channel_plan_process_end_time/wizards/__init__.py new file mode 100644 index 0000000000..09c9cd98d2 --- /dev/null +++ b/stock_release_channel_plan_process_end_time/wizards/__init__.py @@ -0,0 +1 @@ +from . import launch_plan diff --git a/stock_release_channel_plan_process_end_time/wizards/launch_plan.py b/stock_release_channel_plan_process_end_time/wizards/launch_plan.py new file mode 100644 index 0000000000..8b7f7c467e --- /dev/null +++ b/stock_release_channel_plan_process_end_time/wizards/launch_plan.py @@ -0,0 +1,32 @@ +# Copyright 2023 Jacques-Etienne Baudoux (BCIM) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from datetime import datetime + +from odoo import api, fields, models + +from odoo.addons.partner_tz.tools.tz_utils import tz_to_utc_naive_datetime +from odoo.addons.stock_release_channel_process_end_time.utils import float_to_time + + +class StockReleaseChannelPlanWizardLaunch(models.TransientModel): + _inherit = "stock.release.channel.plan.wizard.launch" + + process_end_date = fields.Date( + required=True, + default=fields.Date.context_today, + ) + + @api.model + def _action_launch(self, channels): + channels_to_wakeup = channels.filtered("is_action_wake_up_allowed") + # Wake up the channels + super()._action_launch(channels) + # Override the process end date + for channel in channels_to_wakeup: + end_time = float_to_time(channel.process_end_time) # in TZ + end_date = datetime.combine(self.process_end_date, end_time) # in TZ + tz = channel.process_end_time_tz or "UTC" + end_date_utc = tz_to_utc_naive_datetime(tz, end_date) + channel.write({"process_end_date": end_date_utc}) + return diff --git a/stock_release_channel_plan_process_end_time/wizards/launch_plan.xml b/stock_release_channel_plan_process_end_time/wizards/launch_plan.xml new file mode 100644 index 0000000000..98b8c96c78 --- /dev/null +++ b/stock_release_channel_plan_process_end_time/wizards/launch_plan.xml @@ -0,0 +1,19 @@ + + + + + + stock.release.channel.plan.wizard.launch + + + + + + + + +