Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
2709 Visualizações

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
Cancelar
Publicações relacionadas Respostas Visualizações Atividade
1
jan. 24
1910
1
ago. 23
23487
3
set. 17
7840
3
jul. 15
33129
1
mar. 15
5689