Do not try to create periods when renewing a fiscal year without periods
The computation of interval raises a ZeroDivisionError because the length of periods is 0. Closes #13671 (grafted from baf0a88808a8c5e85116ebbc7cf5f414b6bd95fc) --HG-- branch : 7.0
This commit is contained in:
@@ -678,15 +678,19 @@ class RenewFiscalYear(Wizard):
|
||||
fiscalyear, = FiscalYear.copy(
|
||||
[self.start.previous_fiscalyear],
|
||||
default=self.fiscalyear_defaults())
|
||||
periods = [p for p in self.start.previous_fiscalyear.periods
|
||||
periods = [
|
||||
p for p in self.start.previous_fiscalyear.periods
|
||||
if p.type == 'standard']
|
||||
months = month_delta(fiscalyear.end_date, fiscalyear.start_date) + 1
|
||||
interval = months / len(periods)
|
||||
end_day = max(p.end_date.day
|
||||
for p in self.start.previous_fiscalyear.periods
|
||||
if p.type == 'standard')
|
||||
if interval.is_integer():
|
||||
FiscalYear.create_period([fiscalyear], interval, end_day)
|
||||
if periods:
|
||||
months = month_delta(fiscalyear.end_date, fiscalyear.start_date)
|
||||
months += 1
|
||||
interval = months / len(periods)
|
||||
end_day = max(
|
||||
p.end_date.day
|
||||
for p in self.start.previous_fiscalyear.periods
|
||||
if p.type == 'standard')
|
||||
if interval.is_integer():
|
||||
FiscalYear.create_period([fiscalyear], interval, end_day)
|
||||
return fiscalyear
|
||||
|
||||
def do_create_(self, action):
|
||||
|
||||
Reference in New Issue
Block a user