[FIX] account: compute_fiscalyear_dates non leap years

Before this commit, when the fiscal year was setting to 29/02.
The function that compute the fiscal year dates gives an error.
This occurs when the date passed as parameter wasn't a leap year.

Now, for the non leap years we use the 28/02.

opw-1917035

closes odoo/odoo#29932
This commit is contained in:
Jorge Pinna Puissant
2019-01-04 10:23:44 +00:00
committed by Nicolas Martinelli
parent 1ffc485689
commit 9cf6662880
+5 -1
View File
@@ -115,7 +115,11 @@ Best Regards,''')
last_month = self.fiscalyear_last_month
last_day = self.fiscalyear_last_day
if (date.month < last_month or (date.month == last_month and date.day <= last_day)):
date = date.replace(month=last_month, day=last_day)
# FORWARD-PORT UP TO v11
if last_month == 2 and last_day == 29 and date.year % 4 != 0:
date = date.replace(month=last_month, day=28)
else:
date = date.replace(month=last_month, day=last_day)
else:
if last_month == 2 and last_day == 29 and (date.year + 1) % 4 != 0:
date = date.replace(month=last_month, day=28, year=date.year + 1)