[FIX] l10n_ae: missing if statement to avoid executing UAE related code when COA is not UAE

closes odoo/odoo#78303

X-original-commit: db21ea740a49dd98004bd75ad9fc7412e5686c0e
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
This commit is contained in:
baa
2021-10-13 15:23:01 +00:00
parent 5437dbf5dc
commit dfd75f39f8
+14 -13
View File
@@ -8,7 +8,7 @@ class AccountChartTemplate(models.Model):
def _prepare_all_journals(self, acc_template_ref, company, journals_dict=None):
""" If UAE chart, we add 2 new journals TA and IFRS"""
if company.country_id.code == "AE":
if self == self.env.ref('l10n_ae.uae_chart_template_standard'):
if not journals_dict:
journals_dict = []
journals_dict.extend(
@@ -23,16 +23,17 @@ class AccountChartTemplate(models.Model):
code_digits=code_digits,
account_ref=account_ref,
taxes_ref=taxes_ref)
ifrs_journal = self.env['account.journal'].search(
[('company_id', '=', company.id), ('code', '=', 'IFRS')]).id
if ifrs_journal:
ifrs_account_ids = [self.env.ref('l10n_ae.uae_account_100101').id,
self.env.ref('l10n_ae.uae_account_100102').id,
self.env.ref('l10n_ae.uae_account_400070').id]
ifrs_accounts = self.env['account.account'].browse([account_ref.get(id) for id in ifrs_account_ids])
for account in ifrs_accounts:
account.allowed_journal_ids = [(4, ifrs_journal, 0)]
self.env.ref('l10n_ae.ae_tax_group_5').write(
{'property_tax_payable_account_id': account_ref.get(self.env.ref('l10n_ae.uae_account_202003').id),
'property_tax_receivable_account_id': account_ref.get(self.env.ref('l10n_ae.uae_account_100103').id)})
if self == self.env.ref('l10n_ae.uae_chart_template_standard'):
ifrs_journal = self.env['account.journal'].search(
[('company_id', '=', company.id), ('code', '=', 'IFRS')]).id
if ifrs_journal:
ifrs_account_ids = [self.env.ref('l10n_ae.uae_account_100101').id,
self.env.ref('l10n_ae.uae_account_100102').id,
self.env.ref('l10n_ae.uae_account_400070').id]
ifrs_accounts = self.env['account.account'].browse([account_ref.get(id) for id in ifrs_account_ids])
for account in ifrs_accounts:
account.allowed_journal_ids = [(4, ifrs_journal, 0)]
self.env.ref('l10n_ae.ae_tax_group_5').write(
{'property_tax_payable_account_id': account_ref.get(self.env.ref('l10n_ae.uae_account_202003').id),
'property_tax_receivable_account_id': account_ref.get(self.env.ref('l10n_ae.uae_account_100103').id)})
return account_ref, taxes_ref