Skip to Content
Menu
This question has been flagged

Scenario:

class Model1(models.Model):

_name = "model1"

_description = "Model 1"


custom_field = fields.One2many(
        'model2',
        'registration',
    )




class Model2(models.Model):

_name = "model2"

_description = "Model 2"


field_name = fields.Char(
        'Field Name',
        required=True,
    )

field_value = fields.Char(
        'Field Value',
        required=True,
    )

registration = fields.Many2one(
        'model1',
        required=True,
    )


Required Output:

filter records of model1 in odoo tree view based on the field_value where field_name="amount". field_value should be taken input by user. amount is a float stored as str.


Current filter (static):

domain="['&',('custom_field.field_name','=','amount'),('custom_field.field_value','>','100.0')]"/>


Current output:

records of model1 having amount='20' get filtered in above situation.(string comparison '20'>'100.0'). This 100.0 is to be input by user in interface.


Solution tried:

https://www.odoo.com/forum/help-1/how-to-use-dynamic-values-in-domain-filter-17289

Output: 

Uncaught TypeError: Cannot read property 'fields' of null


Please help! Thank you for your time!

Avatar
Discard
Related Posts Replies Views Activity
1
Jan 24
397
1
Aug 23
22050
3
Sep 17
7839
3
Jul 15
31635
1
Mar 15
4950