Search code examples
pythonxmlodooodoo-11odoo-12

Get current date in xml view for field options in odoo 12?


Want to evaluate the date format value with current using options attribute

<field name="last_date" position="attributes">
    <attribute name="options"> {
      "bg_color": "red: last_date <= datetime.datetime.now().strftime('%Y-%m-%d 00:00:00')",
      "fg_color": "black"
    }</attribute>
</field>

Also I tired "& l e;" instead and both caused raised an error of none define entity

Any one knows how to solve it?


Solution

  • Use the variable current_date instead of using it with another date. you will get the result.

    { "bg_color": "red: last_date &lt=; current_date", "fg_color": "black" }

    Thanks