Odoo Help

Welcome!

This community 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.

0

QWEB: How to call a function to test in odoo

By
Drees Far
on 6/24/16, 10:10 AM 424 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.

0

Ankit H Gandhi(AHG)

--Ankit H Gandhi(AHG)--
996
| 5 3 6
Rajkot, India
--Ankit H Gandhi(AHG)--

Learning Python..

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

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.

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

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>

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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