Dear all,
I am working on Odoo v12 and have a problem with a many2many field.
My many2many field is related to "res.users" and since it is a many2many, for some records I have more than one value that are passed to the actual object.
I have a variable and need to check if the variable value is on the many2many field, and remove all other records from the object.
my_variable = 42
my_relatedfield_ids.ids = res.users(9, 42)
From the above result for the "my_relatedfield_ids.ids", how can I remove the value "9" and keep the value "42" which is the desired value to work with?
For obtaining the "my_relatedfield_ids" I have used:
filtered_result = object.mapped("my_relatedfield_ids") #Where "object" contains the results from a search with a specific domain using self.env...
After this, if I print "filtered_result" I get:
print(filtered_result) : res.users(9, 42)
print(filtered_result.ids) : res.users(9, 42)
My related field is declared as:
my_relatedfield_ids = fields.Many2many('res.users', relation='relatedmodel_rel_users', column1='id',column2='name')
What I need to do is to remove the excess values from this object and leave only the value "42" which is the value I need to work with and it is on "my_variable".
I need to keep it like: res.users(42)
Can you help me please?
Best regards
Paulo