Files
tryton/modules/account_statement/bank.py
Cédric Krier 5310b00496 Remove grouped_slice per IN_MAX
The usage of ``grouped_slice`` without size is deprecated since `=
ANY(ARRAY[%s])` is used for PostgreSQL and SQLite is used only for tests.

The ``Database.IN_MAX`` is replaced by ``backend.MAX_QUERY_PARAMS`` which is a
more accurate limit of the backend.
The SQLite limits is indeed SQLITE_MAX_EXPR_DEPTH so we use a empirical value.
2026-03-22 21:05:26 +01:00

34 lines
1.3 KiB
Python

# 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.modules.bank.exceptions import AccountValidationError
from trytond.pool import Pool, PoolMeta
class Account(metaclass=PoolMeta):
__name__ = 'bank.account'
@classmethod
def validate_fields(cls, accounts, field_names):
super().validate_fields(accounts, field_names)
cls.check_currency_statement_journal(accounts, field_names)
@classmethod
def check_currency_statement_journal(cls, accounts, field_names):
pool = Pool()
Journal = pool.get('account.statement.journal')
if field_names and 'currency' not in field_names:
return
journals = Journal.search([
('bank_account', 'in', accounts),
])
for journal in journals:
if (journal.currency != journal.bank_account.currency
and journal.bank_account.currency):
raise AccountValidationError(
gettext('account_statement.msg_bank_account_currency',
bank_account=journal.bank_account.rec_name,
currency=journal.currency.rec_name,
journal=journal.rec_name))