Search code examples
pythonodooodoo-8

Accessing data of a field from custom widget


In a custom widget, is the data of a field that we turned into widget available to be used inside the widget?

For example if I make a custom widget for a one2many field, when I display that field using XML like this

<field name="myfield" widget="mywidget"/>

Can we use the data of field myfield? In my case for iteration, for looping and making a custom widget for each items inside the field.

Is this possible?

I didn't see any example in the https://www.odoo.com/documentation/8.0/howtos/web.html


Solution

  • Turns out the data is inside

    self.field_manager.datarecord
    

    You can use console.log to shows its content. You can also use it for coding your JavaScript.