Skip to content

Commit

Permalink
[FIX] account: fiscal year last day
Browse files Browse the repository at this point in the history
Do not replace the day value without notifying the user.

In undetermined circumstances, a fiscal year last day and month can be
replaced by the default December 31st value. Since all settings are
re-written for any setting changed, this is likely to happen in the back
of the user.

Moreover, the `_verify_fiscalyear_last_day` is not correct since it
doesn't accept February 29th, while `compute_fiscalyear_dates` handles
it.

opw-1867978
opw-1873260
  • Loading branch information
nim-odoo committed Aug 14, 2018
1 parent 3411754 commit 90cdc91
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
8 changes: 2 additions & 6 deletions addons/account/models/company.py
Expand Up @@ -121,12 +121,8 @@ def _check_lock_dates(self, vals):

@api.model
def _verify_fiscalyear_last_day(self, company_id, last_day, last_month):
company = self.browse(company_id)
last_day = last_day or (company and company.fiscalyear_last_day) or 31
last_month = last_month or (company and company.fiscalyear_last_month) or 12
current_year = datetime.now().year
last_day_of_month = calendar.monthrange(current_year, last_month)[1]
return last_day > last_day_of_month and last_day_of_month or last_day
# FIXME: Remove this method in master
return last_day

@api.multi
def compute_fiscalyear_dates(self, date):
Expand Down
11 changes: 0 additions & 11 deletions addons/account/wizard/setup_wizards.py
Expand Up @@ -36,17 +36,6 @@ def unmark_as_done(self):
""" Forces fiscal year setup state to 'undone'."""
self.company_id.account_setup_fy_data_done = False

@api.multi
def write(self, vals):
if 'fiscalyear_last_day' in vals or 'fiscalyear_last_month' in vals:
for wizard in self:
company = wizard.company_id
vals['fiscalyear_last_day'] = company._verify_fiscalyear_last_day(
company.id,
vals.get('fiscalyear_last_day'),
vals.get('fiscalyear_last_month'))
return super(FinancialYearOpeningWizard, self).write(vals)


class OpeningAccountMoveWizard(models.TransientModel):
_name = 'account.opening'
Expand Down

0 comments on commit 90cdc91

Please sign in to comment.