Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
271 Weergaven

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 !



Avatar
Annuleer

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?

Beste antwoord
How to Automate Fiscal Localization for Invoicing in Odoo

If you're trying to automatically apply a specific chart of accounts when creating invoices or setting up new companies, here are the right steps:

  1. Set default chart template using Odoo’s “Set Defaults”
    • Activate Developer Mode → go to Settings → Technical → User-defined Defaults.
    • Create a rule that sets res.company → chart_template to your desired template (e.g., l10n_fr). This ensures it's applied automatically when a new company is created.
    • Optionally, set defaults for fiscal_country and account.chart.template.
  2. Use the configuration wizard for existing companies
    • In Settings, update values like chart of accounts, fiscal country, and localization, then hit “Apply”. This uses Odoo’s built-in set_values() logic to install them effectively.
  3. Let Odoo handle default receivable/payable accounts
    • Contact payables/receivables are fetched from their company’s chart of accounts. You don’t need separate default rules for them on contacts.
  4. Troubleshooting common errors
    • If you’re missing receivable/payable fields, make sure the chart template is correctly installed; then, the partner fields fill in automatically.
    • The ID for your chart template must exactly match what’s installed in your Odoo instance (e.g., l10n_fr for France).
  5. No custom code required
    • Avoid adding custom XML-RPC scripts. Odoo’s default feature “Set Defaults” handles most use cases cleanly without extra development.

Avatar
Annuleer