-
Notifications
You must be signed in to change notification settings - Fork 10
/
company.py
30 lines (26 loc) · 1.1 KB
/
company.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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 Pool, PoolMeta
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)