Prevent changing the company currency with account moves
issue10259 review361591005
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
from trytond.pool import Pool
|
||||
from . import account
|
||||
from . import configuration
|
||||
from . import company
|
||||
from . import fiscalyear
|
||||
from . import journal
|
||||
from . import move
|
||||
@@ -17,6 +18,7 @@ def register():
|
||||
Pool.register(
|
||||
fiscalyear.FiscalYear,
|
||||
fiscalyear.BalanceNonDeferralStart,
|
||||
company.Company,
|
||||
account.TypeTemplate,
|
||||
account.Type,
|
||||
account.AccountTemplate,
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.i18n import gettext
|
||||
from trytond.model.exceptions import AccessError
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
|
||||
class Company(metaclass=PoolMeta):
|
||||
__name__ = 'company.company'
|
||||
|
||||
@classmethod
|
||||
def write(cls, *args):
|
||||
pool = Pool()
|
||||
Move = pool.get('account.move')
|
||||
transaction = Transaction()
|
||||
if (transaction.user
|
||||
and transaction.context.get('_check_access')):
|
||||
actions = iter(args)
|
||||
for companies, values in zip(actions, actions):
|
||||
if 'currency' in values:
|
||||
moves = Move.search([
|
||||
('company', 'in', [c.id for c in companies]),
|
||||
],
|
||||
limit=1, order=[])
|
||||
if moves:
|
||||
raise AccessError(gettext(
|
||||
'account.msg_company_change_currency'))
|
||||
|
||||
super().write(*args)
|
||||
@@ -193,5 +193,8 @@ You may need to cancel its move "%(move)s".</field>
|
||||
<record model="ir.message" id="msg_cancel_line_delegated">
|
||||
<field name="text">The moves "%(moves)s" contain grouped lines, cancelling them will ungroup the lines.</field>
|
||||
</record>
|
||||
<record model="ir.message" id="msg_company_change_currency">
|
||||
<field name="text">You cannot change the currency of a company which is associated with account moves.</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
||||
Reference in New Issue
Block a user