Unique constraint violation on 'code' when saving Product

Hello everyone,

I am unable to save an already existing product, after pressing ‹ Save › button ‹ Unique constraint violation › error is shown:


I have checked the database manually and there are no duplicate Product entries with same code in ‹ base_product › table.

I’ve tried removing the constraint using following SQL:

alter table base_product drop constraint uk_kmoa50rib71d6kh82rgrd9rpb;

After removing constraint pressing ‹ Save › button worked. After checking the database I found duplicate entries for Product:

select id, dtype, code, name from base_product where code = 'ABCD';

 id  |     dtype      | code |   name
  17 | Product        | ABCD | Alphabet
 114 | ProductCompany | ABCD |
(2 rows)

Products are very simillar, main difference is ‹ dtype › column, a duplicated product was added with dtype = ‹ ProductCompany › while original Product (the product ‹ Save › button was pressed on) has dtype = ‹ Product ›.

NOTE: Saving of a products were working correctly, but it broke. Unfortunately I am unable to trace what caused this. This has happened few times before and was fixed by restoring the entire linux VM from a backup.

Please advise.

Postgres version: 12
Axelor-open-suite version: 6.3.3


When record in ProductCompany has been created name and code value will be empty.

id  |         name         |   code    |     dtype      | product 
 12 | Hard Disk SSD 100 Go | COMP-0002 | Product        |        
 65 |                      |           | ProductCompany |      12
(2 rows)

There is no way to specify those values manually from view also.

So it won’t be an issue for Unique constraints. Can you check how the code has been saved for ProductCompany record ?

Thank you


After further investigation I’ve found that ‹ code › was added to a ‹ Company-specific product fields › list found in ‹ AppBase › settings.

After removing ‹ code › product saving works as expected now.

Thank you for your assistance.