Skip to Content
Menu
This question has been flagged
5 Replies
4422 Views

we use Odoo Community Edition V12 since 1,5years now.

in a simple custom module we just changed a XML File.

Updating will be done by command-line "odoo -u CUSTOMMODULE -d DBNAME --config="PATH"

But suddenly we get this error while updating:

ERROR odoonew22 odoo.sql_db: bad query: b"INSERT INTO ir_model_fields (field_description,relation_table,copied,related,name,track_visibility,required,size,store,model,index,translate,state,on_delete,model_id,readonly,ttype,relation,column2,help,relation_field,column1,selectable) VALUES ('Pricelist Name', NULL, true, NULL, 'name', NULL, true, NULL, true, 'product.pricelist', false, true, 'base', NULL, 170, false, 'char', NULL, NULL, NULL, NULL, NULL, true),('Active', NULL, true, NULL, 'active', NULL, false, NULL, true, 'product.pricelist', false, false, 'base', NULL, 170, false, 'boolean', NULL, NULL, 'If unchecked, it will allow you to hide the pricelist without removing it.', NULL, NULL, true),('Pricelist Items', NULL, true, NULL, 'item_ids', NULL, false, NULL, true, 'product.pricelist', false, false, 'base', NULL, 170, false, 'one2many', 'product.pricelist.item', NULL, NULL, 'pricelist_id', NULL, true),('Currency', NULL, true, NULL, 'currency_id', NULL, true, NULL, true, 'product.pricelist', false, false, 'base', 'set null', 170, false, 'many2one', 'res.currency', NULL, NULL, NULL, NULL, true),('Company', NULL, true, NULL, 'company_id', NULL, false, NULL, true, 'product.pricelist', false, false, 'base', 'set null', 170, false, 'many2one', 'res.company', NULL, NULL, NULL, NULL, true),('Sequence', NULL, true, NULL, 'sequence', NULL, false, NULL, true, 'product.pricelist', false, false, 'base', NULL, 170, false, 'integer', NULL, NULL, NULL, NULL, NULL, true),('Country Groups', 'res_country_group_pricelist_rel', true, NULL, 'country_group_ids', NULL, false, NULL, true, 'product.pricelist', false, false, 'base', NULL, 170, false, 'many2many', 'res.country.group', 'res_country_group_id', NULL, NULL, 'pricelist_id', true),('Discount Policy', NULL, true, NULL, 'discount_policy', NULL, false, NULL, true, 'product.pricelist', false, false, 'base', NULL, 170, false, 'selection', NULL, NULL, NULL, NULL, NULL, true),('ID', NULL, true, NULL, 'id', NULL, false, NULL, true, 'product.pricelist', false, false, 'base', NULL, 170, true, 'integer', NULL, NULL, NULL, NULL, NULL, true),('Display Name', NULL, false, NULL, 'display_name', NULL, false, NULL, false, 'product.pricelist', false, false, 'base', NULL, 170, true, 'char', NULL, NULL, NULL, NULL, NULL, false),('Created by', NULL, true, NULL, 'create_uid', NULL, false, NULL, true, 'product.pricelist', false, false, 'base', 'set null', 170, true, 'many2one', 'res.users', NULL, NULL, NULL, NULL, true),('Created on', NULL, true, NULL, 'create_date', NULL, false, NULL, true, 'product.pricelist', false, false, 'base', NULL, 170, true, 'datetime', NULL, NULL, NULL, NULL, NULL, true),('Last Updated by', NULL, true, NULL, 'write_uid', NULL, false, NULL, true, 'product.pricelist', false, false, 'base', 'set null', 170, true, 'many2one', 'res.users', NULL, NULL, NULL, NULL, true),('Last Updated on', NULL, true, NULL, 'write_date', NULL, false, NULL, true, 'product.pricelist', false, false, 'base', NULL, 170, true, 'datetime', NULL, NULL, NULL, NULL, NULL, true),('Last Modified on', NULL, false, NULL, '__last_update', NULL, false, NULL, false, 'product.pricelist', false, false, 'base', NULL, 170, true, 'datetime', NULL, NULL, NULL, NULL, NULL, false),('Priorit\xc3\xa4t', NULL, true, NULL, 'priority', NULL, false, NULL, true, 'product.pricelist', false, false, 'base', NULL, 170, false, 'integer', NULL, NULL, 'Die h\xc3\xb6chste Priorit\xc3\xa4t startet bei 100. Ist eine Preisliste auf einem Artikel nicht verf\xc3\xbcgbar wird die n\xc3\xa4chst h\xc3\xb6here Priort\xc3\xa4t gew\xc3\xa4hlt.', NULL, NULL, true) RETURNING id"
ERROR: FEHLER:  doppelter Schlüsselwert verletzt Unique-Constraint »ir_model_fields_name_unique«
DETAIL:  Schlüssel »(model, name)=(product.pricelist, active)« existiert bereits.
 
2020-10-13 16:20:03,482 63171 WARNING odoonew22 odoo.modules.loading: Transient module states were reset
2020-10-13 16:20:03,483 63171 ERROR odoonew22 odoo.modules.registry: Failed to load registry
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 60, in __new__
    return cls.registries[db_name]
  File "/usr/lib/python3/dist-packages/odoo/tools/func.py", line 69, in wrapper
    return func(self, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/tools/lru.py", line 44, in __getitem__
    a = self.d[obj].me
KeyError: 'odoonew22'


we did not change anything at model product.pricelist.

The Error MEssage is in german: it tells that Unique-Constraint »ir_model_fields_name_unique« is violated during the upper INSERT statement to ir_model_fields.


Avatar
Discard

it will be better if you can add the code i which you made the change, also ensure the error is not there, if you revert the last change, as you are getting a unique constrains error, if you are changing some data files, try giving some another name etc

Author

any hints how to fix this? we alreads reverted all changes and in testenvironment it works as expected with same Files and inserted DB-Dump

Author

very strange..

select * from ir_model_fields where model LIKE 'product.pricelist%'

this givs us results where model is product_pricelist

BUT:

select * from ir_model_fields where model = 'product.pricelist'

this does not giv any results (although the upper query shows results with product.pricelist)

Author

solution was: "vacuumdb -f DBNAME"

Author Best Answer

we already reverted all change. (only added a field in a tree view of the custom module).

moreover we copied all sources and DB-Dump to another Server but there i do not get this duplicate insert error when updating the module. Maybe some DB-Issues?

Avatar
Discard