Skip to content

Commit

Permalink
Merge PR #1997 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Dec 23, 2024
2 parents ed2f94a + 69444e6 commit 5876e7b
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@
# Copyright 2021 CorporateHub (https://corporatehub.eu)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from datetime import timedelta
from datetime import date, timedelta

from freezegun import freeze_time

from odoo import fields
from odoo.exceptions import UserError
from odoo.tests import common


# in order to avoid a raise caused by the sequence mixin we must ensure
# that all dates are in the same year, hence we freeze the date
# in the middle of the year
@freeze_time(f"{date.today().year}-07-01")
class TestAccountInvoiceConstraintChronology(common.TransactionCase):
@classmethod
def setUpClass(cls):
Expand Down Expand Up @@ -170,6 +176,25 @@ def test_modify_invoice_date_validated_past_invoice(self):
# it should be able to validate, but if we change the date
# higher than YYYYYMM15 or lower than YYYYYMM05
# it should not be able to validate.

# FIX conflict between 'freeze_time' and account module demo data
conflicting_invoices = self.env["account.move"]
conflicting_names = [
"demo_invoice_1",
"demo_invoice_2",
"demo_invoice_3",
"demo_invoice_followup",
"demo_invoice_5",
]
for name in conflicting_names:
conflicting_invoices += self.env.ref(
f"account.{self.env.company.id}_{name}"
)
conflicting_invoices.button_draft()
conflicting_invoices.write(
{"name": False, "invoice_date": date.today().replace(day=1)}
)

after_5_days = self.today + timedelta(days=5)
after_10_days = self.today + timedelta(days=10)
after_15_days = self.today + timedelta(days=15)
Expand Down

0 comments on commit 5876e7b

Please sign in to comment.