[FIX] account: wrong implementation of journal account check
In case we have an account type which is allowed it is not needed to check the account allowed as it would fail although the account type is allowed before, so we need to do the check correctly as it was done in previous versions. closes odoo/odoo#59547 X-original-commit: 220a1ffe69ddd9e4b45f31bf2911f1b6c3bfdfd7 Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com> Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
This commit is contained in:
committed by
oco-odoo
parent
a900f96619
commit
8dcc8bc217
@@ -3571,12 +3571,18 @@ class AccountMoveLine(models.Model):
|
||||
if account_currency and account_currency != line.company_currency_id and account_currency != line.currency_id:
|
||||
raise UserError(_('The account selected on your journal entry forces to provide a secondary currency. You should remove the secondary currency on the account.'))
|
||||
|
||||
control_journal_failed = account.allowed_journal_ids and journal not in account.allowed_journal_ids
|
||||
control_type_failed = journal.type_control_ids and account.user_type_id not in journal.type_control_ids
|
||||
control_account_failed = journal.account_control_ids and account not in journal.account_control_ids
|
||||
if control_journal_failed:
|
||||
if account.allowed_journal_ids and journal not in account.allowed_journal_ids:
|
||||
raise UserError(_('You cannot use this account (%s) in this journal, check the field \'Allowed Journals\' on the related account.', account.display_name))
|
||||
if control_type_failed or control_account_failed:
|
||||
|
||||
failed_check = False
|
||||
if journal.type_control_ids or journal.account_control_ids:
|
||||
failed_check = True
|
||||
if journal.type_control_ids:
|
||||
failed_check = account.user_type_id not in journal.type_control_ids
|
||||
if failed_check and journal.account_control_ids:
|
||||
failed_check = account not in journal.account_control_ids
|
||||
|
||||
if failed_check:
|
||||
raise UserError(_('You cannot use this account (%s) in this journal, check the section \'Control-Access\' under tab \'Advanced Settings\' on the related journal.', account.display_name))
|
||||
|
||||
@api.constrains('account_id', 'tax_ids', 'tax_line_id', 'reconciled')
|
||||
|
||||
Reference in New Issue
Block a user