diff --git a/addons/account/models/company.py b/addons/account/models/company.py index 176f9d38d1a..4a249c495b9 100644 --- a/addons/account/models/company.py +++ b/addons/account/models/company.py @@ -80,8 +80,7 @@ Best Regards,''') account.write({'code': account.code.rstrip('0').ljust(digits, '0')}) @api.multi - def write(self, values): - #restrict the closing of FY if there are still unposted entries + def _validate_fiscalyear_lock(self, values): if values.get('fiscalyear_lock_date'): nb_draft_entries = self.env['account.move'].search([ ('company_id', 'in', [c.id for c in self]), @@ -89,6 +88,12 @@ Best Regards,''') ('date', '<=', values['fiscalyear_lock_date'])]) if nb_draft_entries: raise ValidationError(_('There are still unposted entries in the period you want to lock. You should either post or delete them.')) + + @api.multi + def write(self, values): + #restrict the closing of FY if there are still unposted entries + self._validate_fiscalyear_lock(values) + # Reflect the change on accounts for company in self: digits = values.get('accounts_code_digits') or company.accounts_code_digits