1

How can I access the variable from a function? For example:

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

Then I would like to get the data of var from that function and put it to my report. And this is what I did:

<span t-esc"o.get_data(var)"/>

But I am facing an error like TypeError: get_data() takes 1 positional argument but 2 were given.
Any idea on how to achieve this?

Kai Ning
  • 159
  • 9

2 Answers2

1

I just got the answer. I just put a return to var.

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

then put this on a report: <span t-esc="o.get_data()/>

Kai Ning
  • 159
  • 9
0

you can also pass the params in xml,

<span t-esc="o.get_data(a)/>

and in python

def get_data(self, a):
    name = a
    return name