Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Odoo 17 : writing python conditions in XML
Jeevachaithanyan Sivanandan
Jeevachaithanyan Sivanandan

Posted on

     

Odoo 17 : writing python conditions in XML

In Odoo 17, it's possible to write Python conditions directly in the XML view. For instance, if we have a field named 'can_edit_shop_orders' in our model and we need to dynamically show/hide another field based on its value, here's how we can achieve that. Let's assume 'can_edit_shop_orders' is a boolean field, and we want to control the visibility of another field named 'shop_orders' based on its value.

<field name="shop_orders" string="Shop Orders" readonly="not can_edit_shop_orders"/><field name="can_edit_shop_orders"  invisible= "1"/>
Enter fullscreen modeExit fullscreen mode

As demonstrated, Python conditions can be embedded within the XML structure. It's crucial to note that the boolean field must be included in the view itself, even if it's hidden, to avoid errors thrown by Odoo.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Software Engineer / Frontend Developer / Full Stack Developer - writes about JavaScript, Php, Python and more
  • Location
    United Kingdom
  • Pronouns
    He/Him
  • Joined

More fromJeevachaithanyan Sivanandan

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp