[FIX] account: restrict fiscalyear closing if there are still unposted entries
This commit is contained in:
@@ -7862,6 +7862,12 @@ msgstr ""
|
||||
msgid "The sequence of journal %s is deactivated."
|
||||
msgstr ""
|
||||
|
||||
#. module: account
|
||||
#: code:addons/account/models/company.py:91
|
||||
#, python-format
|
||||
msgid "There are still unposted entries in the period you want to lock. You should either post or delete them."
|
||||
msgstr ""
|
||||
|
||||
#. module: account
|
||||
#: code:addons/account/models/account_bank_statement.py:170
|
||||
#, python-format
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from openerp import fields, models, api, _
|
||||
from openerp.exceptions import ValidationError
|
||||
from datetime import timedelta
|
||||
|
||||
|
||||
@@ -80,6 +81,14 @@ Best Regards,''')
|
||||
|
||||
@api.multi
|
||||
def write(self, values):
|
||||
#restrict the closing of FY if there are still unposted entries
|
||||
if values.get('fiscalyear_lock_date'):
|
||||
nb_draft_entries = self.env['account.move'].search([
|
||||
('company_id', 'in', [c.id for c in self]),
|
||||
('state', '=', 'draft'),
|
||||
('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.'))
|
||||
# Reflect the change on accounts
|
||||
for company in self:
|
||||
digits = values.get('accounts_code_digits') or company.accounts_code_digits
|
||||
|
||||
Reference in New Issue
Block a user