Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
2361 Представления

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'


Аватар
Отменить
Лучший ответ

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


Аватар
Отменить
Related Posts Ответы Просмотры Активность
2
июн. 23
4839
1
апр. 23
2203
0
мая 22
2273
3
авг. 24
3474
1
мая 24
2090