diff --git a/loyalty_initial_date_validity/README.rst b/loyalty_initial_date_validity/README.rst index 2f63fc5da..d916e1a6b 100644 --- a/loyalty_initial_date_validity/README.rst +++ b/loyalty_initial_date_validity/README.rst @@ -7,12 +7,12 @@ Loyalty Initial Date Validity !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:e4b48708e786570ece2274c1b4521fe4595c7cd48dc1bfe54e46f198d9c4a9fc + !! source digest: sha256:2dc26e4e992169eef49e77f015df31ade2fbef82d4d62da299fefe8bd20f2445 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png +.. |badge1| image:: https://img.shields.io/badge/maturity-Production%2FStable-green.png :target: https://odoo-community.org/page/development-status - :alt: Beta + :alt: Production/Stable .. |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 diff --git a/loyalty_initial_date_validity/__manifest__.py b/loyalty_initial_date_validity/__manifest__.py index ca87c4291..da5ed78ba 100644 --- a/loyalty_initial_date_validity/__manifest__.py +++ b/loyalty_initial_date_validity/__manifest__.py @@ -4,6 +4,7 @@ "name": "Loyalty Initial Date Validity", "summary": "Set a start date for a promotion", "version": "16.0.1.0.0", + "development_status": "Production/Stable", "category": "Sale", "website": "https://github.com/OCA/sale-promotion", "author": "Tecnativa, Odoo Community Association (OCA)", diff --git a/loyalty_initial_date_validity/static/description/index.html b/loyalty_initial_date_validity/static/description/index.html index 72c441e04..30657462f 100644 --- a/loyalty_initial_date_validity/static/description/index.html +++ b/loyalty_initial_date_validity/static/description/index.html @@ -367,9 +367,9 @@

Loyalty Initial Date Validity

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:e4b48708e786570ece2274c1b4521fe4595c7cd48dc1bfe54e46f198d9c4a9fc +!! source digest: sha256:2dc26e4e992169eef49e77f015df31ade2fbef82d4d62da299fefe8bd20f2445 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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

+

Production/Stable License: AGPL-3 OCA/sale-promotion Translate me on Weblate Try me on Runboat

This module extends the functionality of Loyalty to add the date_from field to promotions. The aim of this is to be able to set a start date for a promotion. It’s a technical base to be extended with top level functionality (sales, pos).

diff --git a/loyalty_initial_date_validity/tests/__init__.py b/loyalty_initial_date_validity/tests/__init__.py new file mode 100644 index 000000000..e718d9c3d --- /dev/null +++ b/loyalty_initial_date_validity/tests/__init__.py @@ -0,0 +1 @@ +from . import test_loyalty_initial_date_validity diff --git a/loyalty_initial_date_validity/tests/test_loyalty_initial_date_validity.py b/loyalty_initial_date_validity/tests/test_loyalty_initial_date_validity.py new file mode 100644 index 000000000..bf6e94d12 --- /dev/null +++ b/loyalty_initial_date_validity/tests/test_loyalty_initial_date_validity.py @@ -0,0 +1,61 @@ +# Copyright 2024 Tecnativa - Pilar Vargas +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from freezegun import freeze_time + +from odoo.exceptions import UserError +from odoo.tests import tagged + +from odoo.addons.base.tests.common import BaseCommon + + +@tagged("-at_install", "post_install") +class LoyaltyInitialDateValidity(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + loyalty_program = cls.env["loyalty.program"] + # Promotion with start date currently valid + cls.promotion = loyalty_program.create( + { + "name": "Test loyalty initial date validity", + "program_type": "promotion", + "trigger": "auto", + "applies_on": "current", + "date_from": "2024-02-14", + "rule_ids": [ + ( + 0, + 0, + { + "reward_point_mode": "order", + "minimum_qty": 1, + }, + ) + ], + "reward_ids": [ + ( + 0, + 0, + { + "reward_type": "discount", + "discount": 10, + "discount_mode": "percent", + "discount_applicability": "order", + }, + ) + ], + } + ) + + @freeze_time("2024-02-15") + def test_01_check_date_from_date_to(self): + self.assertFalse(self.promotion.date_to) + # The end date cannot be earlier than the start date. + with self.assertRaises(UserError): + self.promotion.date_to = "2024-02-07" + self.promotion.date_to = "2024-02-25" + self.assertTrue(self.promotion.date_to) + # If there is no start date there is no restriction on the end date. + self.promotion.date_from = False + self.promotion.date_to = "2024-02-07"