summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorqdp-odoo <qdp@odoo.com>2017-03-28 10:49:32 +0200
committerqdp-odoo <qdp@odoo.com>2017-03-28 10:49:32 +0200
commit925440b7a0dbde85ec9b7a4474f205da0ef96f94 (patch)
tree15fb2bbe45d7f65118b4164cf163dfbdffca3dce
parenta3b70c5f70617c26ed2ae7be097ccdfa7d6ff773 (diff)
[FIX] account: restrict fiscalyear closing if there are still unposted entries
-rw-r--r--addons/account/i18n/account.pot6
-rw-r--r--addons/account/models/company.py9
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