Steps to reproduce: - Install Accounting and l10n_ar - Create 2 companies located in Argentina (e.g. Company A & Company B) - Switch to Company A - Go to Accounting settings - Set Fiscal Localization to Argentina (e.g. Argentina - Argentine Generic Chart of Accounts for Excempt individuals) - Switch to Company B - Go to Accounting settings - Set Fiscal Localization to the same Fiscal Localization than Company A (i.e. Argentina - Argentine Generic Chart of Accounts for Excempt individuals) - Try to install "l10n_ar_withholding" module Issue: A User Error is raised: "Incompatible companies on records: - 'account.tax.repartition.line,1230' belongs to company 'Company A' and 'Account' (account_id: '1.1.4.03.020 SUSS Withholding incurred') belongs to another company. - 'account.tax.repartition.line,1232' belongs to company 'Company A' and 'Account' (account_id: '1.1.4.03.020 SUSS Withholding incurred') belongs to another company. - 'account.tax.repartition.line,1234' belongs to company 'Company A' and 'Account' (account_id: '1.1.4.05.030 Withholdings of Profits incurred') belongs to another company. - 'account.tax.repartition.line,1236' belongs to company 'Company A' and 'Account' (account_id: '1.1.4.05.030 Withholdings of Profits incurred') belongs to another company." Cause: When installing "l10n_ar_withholding" module, each Argentine company is updated with some tax data. These data are "generic" (not linked to any company) and used for each company, but some treatment is performed on them by the first Argentine company, linking them to the account ids of that company. The following companies are then updated with data linked to the first company. Solution: Compute the data for each company. opw-3709819 closes odoo/odoo#154219 Signed-off-by: Cedric Snauwaert <csn@odoo.com>
35 lines
1.5 KiB
Python
35 lines
1.5 KiB
Python
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from . import models
|
|
from . import wizards
|
|
from . import demo
|
|
|
|
import logging
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
def _l10n_ar_withholding_post_init(env):
|
|
""" Existing companies that have the Argentinean Chart of Accounts set """
|
|
template_codes = ['ar_ri', 'ar_ex', 'ar_base']
|
|
ar_companies = env['res.company'].search([('chart_template', 'in', template_codes)])
|
|
used_template_codes = set(ar_companies.mapped('chart_template'))
|
|
for template_code in used_template_codes:
|
|
data = {
|
|
model: env['account.chart.template']._parse_csv(template_code, model, module='l10n_ar_withholding')
|
|
for model in [
|
|
'account.account',
|
|
'account.tax.group',
|
|
'account.tax',
|
|
]
|
|
}
|
|
for company in ar_companies.filtered(lambda c: c.chart_template == template_code):
|
|
_logger.info("Company %s already has the Argentinean localization installed, updating...", company.name)
|
|
company_chart_template = env['account.chart.template'].with_company(company)
|
|
company_chart_template._deref_account_tags(template_code, data['account.tax'])
|
|
company_chart_template._load_data(data)
|
|
company.l10n_ar_tax_base_account_id = env.ref('account.%i_base_tax_account' % company.id)
|
|
|
|
if env.ref('base.module_l10n_ar_withholding').demo:
|
|
env['account.chart.template']._post_load_demo_data(company)
|