diff --git a/addons/account/i18n/account.pot b/addons/account/i18n/account.pot index 04d61791600..70464967077 100644 --- a/addons/account/i18n/account.pot +++ b/addons/account/i18n/account.pot @@ -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 diff --git a/addons/account/models/company.py b/addons/account/models/company.py index 1a43f3c59f9..176f9d38d1a 100644 --- a/addons/account/models/company.py +++ b/addons/account/models/company.py @@ -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