constraint error: The code of the account must be unique per company

Asked by Thorsten Vocks ( on 2009-07-13

Open ERP Version 5.0.1

I have a bug with new created module "l10n_chart_de_skr03"
Module Branch is

Reported Bug is:

The code of the account must be unique per company.

Under version 5.0.0 installation was successfull.
Are there changes between 5.0.0 and 5.0.1
depending the chart installation wizard?

regards and thanks in advance to help finish this

Question information

English Edit question
Odoo Addons (MOVED TO GITHUB) Edit question
No assignee Edit question
Solved by:
Thorsten Vocks (
Last query:
Last reply:

By the newer version,

We have put a constraint that the pair of code and company to the account must be unique.

It looks like, either the accounts have no code, or you try to create the account chart second time with the same company.

Thank you.

i completed the code field of some
remaining "view" accounts.
This solved my problems.
Thanks for your help.


polgar (kovacs-endre) said : #3

Hi Thorsten!

You can explain in more detail this solution? where should change the code?

here my first records:

 <record id="chart0" model="account.account.template">
  <field name="code">0</field>
  <field name="name">Account Chart</field>
  <field name="type">view</field>
  <field name="user_type" ref="l10n_chart_hu.account_type_view"/>

<record id="chart1" model="account.account.template">
 <field name="code">1</field>
 <field name="reconcile" eval="False"/>
 <field name="parent_id" ref="chart0"/>
 <field name="type">view</field>
 <field name="user_type" ref="l10n_chart_hu.account_type_asset"/>
 <field name="name">BEFEKTETETT ESZKÖZÖK</field>


Hello Polgar,

Can you please check whether all the xml records in your file have different CODE field?
i.e., <field name="code">0</field>.
May be, you have no code field for some account templates.Its compulsory now.
If so,

Make sure you are creating chart for another company.


polgar (kovacs-endre) said : #5

This chart of account it works well with previous openerp versions so i think i have no problems with code fields.
So installation of this chart works vell but when i want to generate chart of accounts from a Chart Template i get this error..
If i have x company i should "generate chart of accounts from a Chart Template" for y company?

Yes, exactly.
We have put a constraint that the pair of code and company to the account must be unique.

So , go for 'Y' company.

polgar (kovacs-endre) said : #7

Thanks for help!

With the 'y' company with same error yet but i working on it

I am quite stuck with the installation of the accounts using module "l10n_chart_de_skr03" doe to the described error.
Are there any diagnosis possibilities to find exactly where the duplicate or missing code field is ?

I have a clean database without demo data and nearly all tables are empty.
Only some account types are defined.

Thank you in advance,