[REF] account: validate of FY lock date into a dedicated method.

in res.company write(), create a sub method _validate_fiscalyear_lock()
so that it is easier to inherit to modify or extend its
functionality.

Was PR #16615
This commit is contained in:
qdp-odoo
2017-05-15 23:37:48 +02:00
parent 7836a83b3b
commit a95a667563
+7 -2
View File
@@ -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