So in my project I need to deal with multitude of chart_templates to setup,
and well I supose why not just update them and reaload them directly with our main accounting use in france :
def ensure_chart_template(self, company_id, chart_template = 'fr'):
try:
company = self.env['res.company'].browse(company_id)
if not company.chart_template:
# Set the selection value directly, e.g. 'l10n_fr'
print(f"Setting chart template for company {company.name} to {chart_template}")
company.chart_template = chart_template
self.env['account.chart.template'].try_loading(company.chart_template, company=company)
except Exception as e:
print(f"Erreur dans ensure_chart_template pour la société {company_id}: {e}")
return {"type": "error", "message": f"Erreur dans ensure_chart_template: {e}"}, True
SO PERFECT we i do so i get this :
So from what i understand as expected we can still change it for now the package because we didn't creat an invoice.
When i creat one I get this :
am I missing something ?
in the res_config_settings.py i just noticed thoses 2 functions :
def set_values(self):
super().set_values()
# install a chart of accounts for the given company (if required)
if self.env.company == self.company_id and self.chart_template \
and self.chart_template != self.company_id.chart_template:
self.env['account.chart.template'].try_loading(self.chart_template, company=self.company_id)
def reload_template(self):
self.env['account.chart.template'].try_loading(self.company_id.chart_template, company=self.company_id)
I don't see what else could be wrong ? maybe the chart_template i'm using. (in odoo 18)
I also tryed l10n_fr_account and l10n_fr that i have activated but they don't work.
sends me an error when i select it
Thank you guys !!
have a nice day !
I can't really reproduce the issue you're describing in a demo odoo.sh odoo-bin shell for version 18. Does your company, prior to setting the CoA this way have a country set or a different CoA applied to it?