Reputation: 59
I have got a few ids (e.g. [4, 8, 9]) and I would like to store them as a new field in module Contacts (python code). The number of ids may vary for each contact. Moreover, I would like to use this new field in filter. What type of field do I need?
Thank you in advance!
Upvotes: 1
Views: 81
Reputation: 6728
I would use One2Many field to store such data, but you need to know what model your id
s is. Something like this:
children_ids = fields.One2many('child.model', 'parent_id')
Then in the child model, you should have a Many2One field named parent_id
(you can change the field name) so it can to refer back to its parent. Something like this:
parent_id = fields.Many2one('parent.model')
For filter feature, this may guide you on how to do it. Basically, you can add the field into the search. Something like this:
<field name="children_ids" string="Children IDs" filter_domain="[('children_ids.some_field','ilike', self)]"/>
Upvotes: 1