Se rendre au contenu
Menu
Cette question a été signalée
2 Réponses
6723 Vues

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
Ignorer
Meilleure réponse

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
Ignorer

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.

Meilleure réponse

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
Ignorer
Publications associées Réponses Vues Activité
2
juil. 23
6252
1
juin 23
4276
1
avr. 23
5014
1
nov. 22
3716
1
oct. 21
12061