Reputation: 81
im trying to re design my Odoo 9 qweb report. that inherited sale_order_report. I have created some python function that have been called on the qweb. Now i would like to hide that content of the python function depend on conditions. Please take a moment to read my code bellow and help me to point out the specifics way to solve the problem?
@api.multi
def handle_detail(self, order_line):
dict_item = {}
for line in order_line:
for key in
quantity_extra = int(line.quantity_extra)
if quantity_extra not in dict_item.keys():
dict_item[quantity_extra].append(line.lng)
else:
dict_item[quantity_extra] = [line.lng]
result = []
total = 0.0
for item in dict_item.keys():
lst_ing = dict_item[item]
if len(lst_ing) > 1:
result.append(
'( %s ) x %s' % (' + '.join([str(lng) for lng in lst_ing]),
str(item)))
total += (sum(lst_ing) * item)
else:
result.append('%s x %s' % (str(lst_ing[0]), str(item)))
total += (lst_ing[0] * item)
return result, total
Thank for your time.
Upvotes: 1
Views: 275
Reputation: 14721
surround the code in the template by a t-if statement like this
<t t-if="condition"> <!-- if the condition is true the contenant is shown -->
<....code that calls the method and show the value on the template />
</t>
Upvotes: 1