Skip to content

Commit

Permalink
[IMP] loyalty_initial_date_validity: add test and change development …
Browse files Browse the repository at this point in the history
…development_status

TT45685
  • Loading branch information
pilarvargas-tecnativa committed Feb 15, 2024
1 parent 1c91829 commit b6d67c7
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 5 deletions.
6 changes: 3 additions & 3 deletions loyalty_initial_date_validity/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions loyalty_initial_date_validity/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
4 changes: 2 additions & 2 deletions loyalty_initial_date_validity/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,9 @@ <h1 class="title">Loyalty Initial Date Validity</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:e4b48708e786570ece2274c1b4521fe4595c7cd48dc1bfe54e46f198d9c4a9fc
!! source digest: sha256:2dc26e4e992169eef49e77f015df31ade2fbef82d4d62da299fefe8bd20f2445
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/sale-promotion/tree/16.0/loyalty_initial_date_validity"><img alt="OCA/sale-promotion" src="https://img.shields.io/badge/github-OCA%2Fsale--promotion-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/sale-promotion-16-0/sale-promotion-16-0-loyalty_initial_date_validity"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/sale-promotion&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/sale-promotion/tree/16.0/loyalty_initial_date_validity"><img alt="OCA/sale-promotion" src="https://img.shields.io/badge/github-OCA%2Fsale--promotion-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/sale-promotion-16-0/sale-promotion-16-0-loyalty_initial_date_validity"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/sale-promotion&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>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).</p>
Expand Down
1 change: 1 addition & 0 deletions loyalty_initial_date_validity/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_loyalty_initial_date_validity
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit b6d67c7

Please sign in to comment.