| 1 | import logging |
| 2 | |
| 3 | from . import models |
| 4 | |
| 5 | _logger = logging.getLogger(__name__) |
| 6 | |
| 7 | |
| 8 | def _l10n_tr_nilvera_einvoice_extended_post_init(env): |
| 9 | """Existing none branch companies that have the Turkish Chart of Accounts set""" |
| 10 | tr_companies = env["res.company"].search([("chart_template", "=", "tr"), ("parent_id", "=", False)], order="parent_path") |
| 11 | for company in tr_companies: |
| 12 | ChartTemplate = env["account.chart.template"].with_company(company) |
| 13 | data = { |
| 14 | "l10n_tr_nilvera_einvoice_extended.account.tax.code": ChartTemplate._get_tr_withholding_account_tax_code(), |
| 15 | "account.tax": { |
| 16 | xml_id: data |
| 17 | for xml_id, data in ChartTemplate._get_tr_withholding_account_tax().items() |
| 18 | if not env.ref(f"account.{company.id}_{xml_id}", raise_if_not_found=False) |
| 19 | }, |
| 20 | } |
| 21 | ChartTemplate._deref_account_tags("tr", data["account.tax"]) |
| 22 | ChartTemplate._pre_reload_data(company, {}, data) |
| 23 | ChartTemplate._load_data(data) |
| 24 | ChartTemplate._load_translations(companies=company) |