Home > Net >  Domain prefix expression in odoo
Domain prefix expression in odoo

Time:05-29

i am trying to modify a domain but i have first to understand the logic of this prefix expression :

 <field name="partner_id" position="attributes">
                <attribute name="domain">[('state', '=', 'validate'),
                                            '|', '|',
                                                '&amp;',
                                                    ('supplier', '=', to_supplier), ('customer', '=', to_customer),
                                                '&amp;',
                                                    ('supplier', '=', True), ('customer', '=', True),
                                                ('is_project', '=', True)]
                </attribute>

i tried to convert it into infix expression (for my own understanding) so i got this :

('state', '=', 'validate'),[[('supplier', '=', to_supplier),'&amp;' ('customer', '=', to_customer)],'|',[('supplier', '=', True),'&amp;', ('customer', '=', True)], '|',
                                                ('is_project', '=', True)]

in a more simple way : prefix : A,|,|,&,B,C,&,D,E,F infix : A,(B&C | D&E| F)

i don't know if this is right or no

CodePudding user response:

Yes, this is right:

[ A,
    '|', 
        '|',
            '&', B, C,
            '&', D, E,
        F]

is the same than

[
    '&'
    A,
    [
        '|', 
        [
            '|', 
            ['&', B, C,], 
            ['&', D, E,]
        ],
        F
    ]
]

To infix, it's this:

[
    A,
    '&',
    [
        [
            [B, '&', C,], 
            '|', 
            [D, '&',E,]
        ]
        '|', 
        F
    ]
]

which can be "simplified" to:

A, '&', [B, '&', C, '|', D, '&', E, '|', F]

in addition: In Odoo, if you don't write any operator, there is an implicit '&'

  • Related