Skip to content
Snippets Groups Projects

Fix: Handle leap year calculation for valid dates in February

Merged aronabencherif.diatta@xcg.africa requested to merge topic/16.0/Fix_leap_day into branch/16.0
All threads resolved!
@@ -56,13 +56,6 @@
year = fields.Date.from_string(self.today).year
period_today = self.Period.find(date=self.today)
# Ensure that we are not in a leap year for the month of February.
TODAY = (
self.today - datetime.timedelta(days=1)
if self.today.day == 29 and self.today.month == 2
else self.today
)
# Control: Default dates & period around today.
accdoc = self._make_invoice(company=period_today.company_id)
self._validate_invoice(accdoc)
@@ -72,7 +65,7 @@
self.assertEqual(accentries.mapped("period_id").id, period_today.id)
# Force a date on the invoice; ensure period selection follows it.
date_2017 = TODAY.replace(year=2017)
date_2017 = self.today + relativedelta(year=2017)
period_2017 = self.Period.find(date=date_2017)
accdoc_2017 = self._make_invoice(
invoice_date=date_2017, company=period_2017.company_id
Loading