Skip to Content
Menu
This question has been flagged
6 Replies
8311 Views

how can i pass a local Variable defined in qweb to a Python-method?

<t t-set="shop_location" t-value="Munich"/>
....
....
<t t-set="location" t-value="product.get_shop_barcode_location(shop_location)"/>

the function is defined like:

def get_shop_barcode_location(self,location)
....
but the location variable in Python is always just None.


Avatar
Discard
Author Best Answer

@Divyesh Patel:

here some mor code:

class product_product(models.Model):
_inherit = 'product.product'
	
def get_shop_barcode_location(self,location):
if location != None and location == 'Munich':
for loc in self.x_default_stock_location_ids:
if loc.location_type == 'shop':
return {'barcode':loc.barcode,'name':loc.name}
return False
else:
return False

and reduced XML-REport:
<template id="x_article.report_product_shop_label">
<div style="height:149px;overflow:hidden;">
<table>
<tr valign="top" style="line-height:1;">
<t t-set="location" t-value="product.get_shop_barcode_location(shop_location)"/>
</td>
</tr>

</table>
</div>
</template>

<template id="x_article.report_product_shop_label_wien">
<t t-call="web.basic_layout">
<div class="page page_stock_product_barcodes">
<t t-set="shop_location" t-value="Munich"/>
<t t-foreach="docs" t-as="product">
<t t-call="x_article.report_product_shop_label">
<t t-set="product" t-value="product"/>
                    <t t-set="shop_location" t-value="Munich"/>
</t>
</t>
</div>
</t>
</template>
Avatar
Discard
Best Answer

Hello,

plasese check it.

<t t-set="location" t-value="product.get_special_location(shop_location)"/>

def get_shop_barcode_location(self,location)
it maybe call method and calling mathod should be diffrent.
Avatar
Discard
Author

was a copy/paste mistake. i just edited my original poste. the functions are identicalls but the location param will be passed as "None"

hello, Jack can you send me your both file I will check.

Author

how can i send/transfer files in this forum?

I have needed only both file code you can past hear.