2017-03-11 2 views
1

en essayant de re concevoir mon rapport qweb Odoo 9. qui a hérité sale_order_report. J'ai créé une fonction python qui a été appelée sur le qweb. Maintenant, je voudrais cacher que le contenu de la fonction python dépend des conditions. S'il vous plaît prenez un moment pour lire mon code ci-dessous et m'aider à indiquer la façon spécifique de résoudre le problème?Comment masquer ou afficher le contenu d'une fonction python sur un rapport qweb dépend de la condition?

@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 

Merci pour votre temps.

Répondre

1

entourent le code dans le modèle par un t-instruction if comme celui-ci

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