This question has been flagged
3 Replies
3547 Views

Hi,


how can I create a new group in form tree on a related field ?

in a form tree, I have "filters", "group" and "favorites", how can I add a custom group on related field  ?

Avatar
Discard
Author

my field's definition is :

asset_cat = fields.Many2many(related='asset_id.category_ids', store =True)

what's wrong ?

Best Answer

To don't get the error when using store=True you need to add the relation argument to the field definition, using of course the same model name as the original category_ids field, for example:

##updated

asset_cat = fields.Many2many(related='asset_id.category_ids', store =True, relation='account.asset.category', column1='asset_id', column2='categ_id')
Avatar
Discard
Author

now I have this bug

Traceback (most recent call last):

File "C:\Program Files (x86)\Odoo 10.0\server\odoo\modules\registry.py", line 78, in new

File "C:\Program Files (x86)\Odoo 10.0\server\odoo\modules\loading.py", line 335, in load_modules

File "C:\Program Files (x86)\Odoo 10.0\server\odoo\modules\loading.py", line 237, in load_marked_modules

File "C:\Program Files (x86)\Odoo 10.0\server\odoo\modules\loading.py", line 136, in load_module_graph

File "C:\Program Files (x86)\Odoo 10.0\server\odoo\modules\registry.py", line 315, in init_models

File "C:\Program Files (x86)\Odoo 10.0\server\odoo\models.py", line 2361, in _auto_init

File "C:\Program Files (x86)\Odoo 10.0\server\odoo\fields.py", line 2308, in check_schema

File "C:\Program Files (x86)\Odoo 10.0\server\odoo\sql_db.py", line 141, in wrapper

File "C:\Program Files (x86)\Odoo 10.0\server\odoo\sql_db.py", line 218, in execute

ProgrammingError: ERREUR: la colonne ¶® None ¶¯ apparaÇ©t deux fois sur une contrainte unique

LINE 1: ..."None" INTEGER NOT NULL, "None" INTEGER NOT NULL, UNIQUE("No...

Sorry but I don't understand french yet, :), that seems to be that it will need more args for the column on the relation table, I will update the answer

Author

haha sorry, it's mean

The None column appears twice on the unique constraint

try the update

Author Best Answer

I used "store= True" but now I can't access to my database.

so, I delete "store= True" to reaccess database. 

any other solution for filter with related field please ?

Avatar
Discard