diff options
| author | qdp-odoo <qdp@odoo.com> | 2017-03-28 10:49:32 +0200 |
|---|---|---|
| committer | qdp-odoo <qdp@odoo.com> | 2017-03-28 10:49:32 +0200 |
| commit | 925440b7a0dbde85ec9b7a4474f205da0ef96f94 (patch) | |
| tree | 15fb2bbe45d7f65118b4164cf163dfbdffca3dce | |
| parent | a3b70c5f70617c26ed2ae7be097ccdfa7d6ff773 (diff) | |
[FIX] account: restrict fiscalyear closing if there are still unposted entries
| -rw-r--r-- | addons/account/i18n/account.pot | 6 | ||||
| -rw-r--r-- | addons/account/models/company.py | 9 |
2 files changed, 15 insertions, 0 deletions
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 @@ -7863,6 +7863,12 @@ 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 msgid "There is no account defined on the journal %s for %s involved in a cash difference." 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 |
