[FIX] account: forbid the change of currency_id if the accounting app has already been used

This commit is contained in:
qdp-odoo
2018-03-05 14:50:22 +01:00
parent 80f97fbd19
commit 0e881fcd3a
2 changed files with 13 additions and 1 deletions
+6
View File
@@ -8812,6 +8812,12 @@ msgstr ""
msgid "You cannot cancel an invoice which is partially paid. You need to unreconcile related payment entries first."
msgstr ""
#. module: account
#: code:addons/account/models/company.py:118
#, python-format
msgid "You cannot change the currency of the company since some journal items already exist"
msgstr ""
#. module: account
#: code:addons/account/models/account.py:162
#, python-format
+7 -1
View File
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from openerp import fields, models, api, _
from openerp.exceptions import ValidationError
from openerp.exceptions import ValidationError, UserError
from datetime import timedelta
@@ -111,4 +111,10 @@ Best Regards,''')
company.reflect_code_prefix_change(company.cash_account_code_prefix, new_cash_code, digits)
if values.get('accounts_code_digits'):
company.reflect_code_digits_change(digits)
#forbid the change of currency_id if there are already some accounting entries existing
if 'currency_id' in values and values['currency_id'] != company.currency_id.id:
if self.env['account.move.line'].search([('company_id', '=', company.id)]):
raise UserError(_('You cannot change the currency of the company since some journal items already exist'))
return super(ResCompany, self).write(values)