Odoo Help


QWEB: How to call a function to test in odoo

Vale Trood
on 6/24/16, 10:10 AM 1,281 views

Hello everybody!!!

I want to ask you : I have a function with it i want to test a value.

But, the question is how can i call it in qweb.

Can anyone give me an example please.

Thanks a lot in advance.

Best regards.


Ankit H Gandhi(AHG)

--Ankit H Gandhi(AHG)--

| 6 5 6
Baroda, India
--Ankit H Gandhi(AHG)--

Learning Python..

Ankit H Gandhi(AHG)
On 6/25/16, 8:13 AM


you can call the function like this:

<span t-esc="o.function(o.your_parameter_value)" />

Hope this help for you..


Ankit H Gandhi.

Is there any way I could call the function on t-field attribute. My function returns a float value and calling the function in t-esc attribute causes some stripping in floating point value. For example, if the function returns 10.00, calling it from t-esc displays only 10.0 and the last zero is stripped.

Gopakumar N G
on 10/28/16, 7:41 AM
ayman mohammed adam
On 6/25/16, 5:40 AM

I have function on py:

 def _get_batch_exp_date(self,invoice_line):

packing_list= []

res= {}

product_list= []

pack_obj= self.pool.get('stock.pack.operation')

for line in invoice_line:

if not line.invoice_id.origin:



if line.product_id and (line.product_id.id not in product_list):


pack_ids= pack_obj.search(self.cr, self.uid, [('picking_id.origin','=',line.invoice_id.origin),('product_id','=',line.product_id.id)])

for pack_line in pack_obj.browse(self.cr, self.uid, pack_ids):


return packing_list

then i call it on qweb by write :

<tr t-foreach="get_batch_exp_date(o.invoice_line)" t-as="l">


<td><span t-field="l.product_id.name"/></td>

<td><span t-field="l.product_qty"/></td>

<td><span t-field="l.lot_id.name"/></td>

<td><span t-field="l.lot_id.life_date"/></td>


About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 6/24/16, 10:10 AM
Seen: 1281 times
Last updated: 6/25/16, 8:13 AM