Help

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

In Odoo 17, set complex logic in xml domain

Avatar
odoo
Avatar
Discard
1 Answer
0
Avatar
odoo
Best Answer

I actually got the solution, and I'd like to share it as well:

This is the answer I found working after understanding the syntax of the logic needed:

<odoo>

    <data>

        <!-- Update existing action record -->

        <record id="mrp.action_mrp_production_moves" model="ir.actions.act_window">

            <field

                name="domain">['|',

                ('move_id.raw_material_production_id', '=',active_id),

                '|',

                ('move_id.production_id', '=', active_id),

                '&amp;',

                ('move_id.raw_material_production_id','=',False),

                '&amp;',

                ('move_id.production_id', '=', False),

                ('production_id', '=',active_id),

                ]</field>

        </record>

    </data>

</odoo>


Here is the explanation of this complex domain syntax:

  • Understanding it starts from the end.
  • |​ and &​ take only two "terms", not more. So, the "expression" is always an operator that has (precedes) two following "terms". A "term" can be a simple one (,,)​ or an expression.
  • For |A|B&C&DE​, it's evaluated as following (from the end):
    • &DE​: D & E => As X
    • &CX​: C & X = C & (D & E) => As Y
    • |BY​: B | Y = B | (C & (D & E)) => As Z
    • |AZ​: A | (B | (C & (D & E)))
  • The proper escaping of &​ as &amp​; ensures the XML is valid.


Avatar
Discard