Skip to Content
Menu
This question has been flagged
1 Reply
1703 Views


In my python class I defined a method:

def get_data(self):     
    var = "I am a variable"
    return var

In the view I try to call it via:

  t-esc="o.get_data()"

  

I see numerous posts that it should work like this, only it doesn't, I get:

Cannot read properties of undefined (reading 'get_data')


What could be the reason? Should this work?

Avatar
Discard
Best Answer

That is because although some qweb template function can be used in form template, form template is "NOT" qweb template. You can only use template function inside qweb template


I actually ask similar question

How to use different class based on condition in form view? 

If I assume you are using odoo 16 (which I have experience in it), you can define a read-only field. If you want to use different element, you can put it inside other element and it will act like that element

For example :

<h2>

    <field class="h-2 text-primary" name="some_field" attrs="{'readonly':True}"/>

</h2>


Avatar
Discard