I created report from wizard but when i iterate the variable sales in xml template file it appear as a string, and when i iterate it in python it work correctly
This is the function of report:
def action_print_errors(self):
domain=[]
user=self.user
date_from=self.date_from
date_to=self.date_to
domain+=[('user_id','=',user.id)]
domain+=[('date_order','>=',date_from)]
domain+=[('date_order','<=',date_to)]
sales=self.env['sale.order'].search(domain)
print(sales)
for sale in sales:
for line in sale["order_line"]:
print("product:",line.product_id.name)
data = {
'form': self.read()[0],
'sales': sales,
}
return self.env.ref('selling_errors.show_quotation_report').report_action(self,data=data)
This is code of iteration in xml report:
<tbody>
<t t-foreach="sales" t-as="o">
<t t-foreach="o['order_line']" t-as="line">
<span t-esc="line.product_id.name"/>
</t>
</t>
</tbody>
Why xml consider that sales variable is string not object? how can i solve it
despite it work correctly as an object in python file
This is the error appears:
Error to render compiling AST TypeError: string indices must be integers Template: selling_errors.report_show_quotation Path: /t/t/t/div/div/table/tbody/t/t Node: