Skip to Content
Menu
This question has been flagged
2 Replies
4263 Views

Can someone please explain in simple but detailed words how this works?

My problem: 

When installing Odoo 12 from scratch I also installed a module for Norwegian accounting (l10n_no) which declared all the accounts with the model/table account.account.template. Looking in the db I see that these are also "copied" to the account.account table.

But now, when the system is running two weird things happen. 

1) When I add new accounts to the data.xml (using account.account.template) they are not copied to account.account

2) When I add new accounts from the GUI they only show up in account.account and not in  account.account.template


This is very confusing to say the least. How can/should I add new accounts to an Odoo 12 server in production?


Thank you :)

Avatar
Discard
Best Answer

When you install a chart of account a method named try_loading_for_current_company is called. You can check this in account_chart_template_data.xml in module l10n_no.

One of the use of this method is to create new account for all templates defined [will call method generate_account from it].

You can see data noupdate="1" in the xml file which means it'll work only once. So when you create a  template from code after installation and upgrading module will not work. 


Avatar
Discard
Author

Thank you Mohammed :) I think I get it, good explaination. What would I do then if I want to create a new account from code on next upgrade of module?

Best Answer

Hi Alf:

When you install an accounting module (for example, Norway - Accounting), the module comes with a predefined chart of accounts which is the template (account.account.template).

When you set up a company, the accounts in the template are copied over into account.account and entries specific to the company are created. You can then customize these by updating the Chart of Accounts for the company.

Hope that helps.

Avatar
Discard
Author

Thank you for your explaination!