This question has been flagged
1 Reply
1101 Views

I'm trying to get name of product and  quotation number for each product  t in my report
but the error occurs , it said that line is an interger, so how can i get names of product for each line order
this is the function of print button:

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_read(domain)
print(domain)
data={
'form':self.read()[0],
'sales':sales
}
return self.env.ref('selling_errors.show_quotation_report').report_action(self,data=data)

this is the code of my table in report:

<tbody>
<t t-foreach="sales" t-as="o">
<t t-foreach="o['order_line']" t-as="line">
<tr>
<td>
<span t-esc="o['name']"/>
</td>
<td>
<span t-field="line.name"/>
</td>
<td></td>
<td></td>
<td></td>
</tr>
</t>
</t>
</tbody>


this is the error:

ile "E:\odoo14\server\odoo\addons\base\models\ir_qweb.py", line 361, in _get_field
    field = record._fields[field_name]
AttributeError: 'int' object has no attribute '_fields'

Error to render compiling AST
AttributeError: 'int' object has no attribute '_fields'


Avatar
Discard
Best Answer

You you get using search_read so its return ids in order_line so you need to use search methods 
Can you try this

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(domain)
data={
'form':self.read()[0],
'sales': sales
}
return self.env.ref('selling_errors.show_quotation_report').report_action(self,data=data)

and used o.name and line.name


Avatar
Discard