如何根据条件隐藏或显示qweb报表中python函数的内容?

2024-05-20 18:46:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图重新设计我的奥多9 qweb报告。继承了销售订单报告。我创建了一些在qweb上被调用的python函数。现在我想隐藏python函数的内容依赖于条件。请花点时间阅读下面的代码,并帮助我指出解决问题的具体方法?在

@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

谢谢你的时间。在


Tags: inforlineresultitemextradictquantity
1条回答
网友
1楼 · 发布于 2024-05-20 18:46:58

用这样的t-if语句将模板中的代码括起来

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

相关问题 更多 >