1
votes

When applying filter to a many2many field I'm getting this error.

Field Definition in python is: Here is field definition in python

fields.Many2many(string='AnalysisProfile',
                    comodel_name='olims.analysis_profile',
                    relation='ar_to_analysisprofile',
                    domain="[('Deactivated', '=',False )]"

and in XML View:

 <field name="AnalysisProfile" string="Analysis Profile"></field>

I'm getting following error:

raise ValueError("Invalid leaf %s" % str(self.leaf))

ValueError: Invalid leaf [

3
@MuhammadSajid Are you making some kind of modifications? If so, please include them. This is most likely an issue with a field definition or trying to use a domain improperly.travisw
I think you either missed closing/opening parenthesis or try to use a nonexisting field in condition. Here is the example domain = "[('groups_id','=',group_id)]"KbiR
what do you mean by "try to use a non existing field in condition." The field exists and its type is many2many. @KbiRMuhammad Sajid
@MuhammadSajid Update your question to add the field definition in Python and in XMLtravisw
@Mohammed Sajid, at least update your question with the code which you tried.KbiR

3 Answers

3
votes

You added extra double quotes in the domain, remove it and try.

fields.Many2many(string='AnalysisProfile',
                comodel_name='olims.analysis_profile',
                relation='ar_to_analysisprofile',
                domain=[('Deactivated', '=',False )])

And make sure you defined a field Deactivated (Uppercase letter D) in olims.analysis_profile. Hope it will help you.

2
votes

In Odoo, a domain comparison consists in a 3-leaf tuple such as:

('field', "=", 'value')

That error message typically means that one of those 3 leaves is wrong. Check your domain to fix it.

0
votes

Try this code:

Python file:

def _analysis_profile(self):

    return [('Deactivated', '=', False)]

AnalysisProfile = fields.Many2many(string='AnalysisProfile',
                    comodel_name='olims.analysis_profile',
                   relation='ar_to_analysisprofile',
                   domain=_analysis_profile)

XML file:

<field name="AnalysisProfile" string="Analysis Profile" widget="many2many_tags"></field>