Skip to Content
Menu
This question has been flagged
2 Replies
5721 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.

Avatar
Discard
Best Answer

Hi,

you can call the function like this:

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

Hope this help for you..

Cheers,

Ankit H Gandhi.

Avatar
Discard

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.

Best Answer

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:

break

else:

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

product_list.append(line.product_id.id)

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):

packing_list.append(pack_line)

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></td>

<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>

</tr>

Avatar
Discard
Related Posts Replies Views Activity
2
Jul 23
3242
1
Jun 23
2597
1
Apr 23
3187
1
Nov 22
2121
1
Oct 21
10828