[FIX] product: prevent traceback when print preview report
qwhen user tries 'PRINT PREVIEW' product.report_producttemplatelabel_dymo report in web_studio, A traceback will appear. Step to produce: - Install 'Sales' and 'web_studio'. - Go to 'web_studio' and open 'Sales'. - reports > product.report_producttemplatelabel_dymo - Click PRINT PREVIEW Error: QWebException: Error while render the template KeyError: 'pricelist' https://github.com/odoo/odoo/blob/e4390c224c2f59afd6456bcf50910fbe3836b4ca/addons/product/report/product_label_report.py#L23-L26 Here 'pricelist' is not present in return. sentry-4673780990 closes odoo/odoo#144475 Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
This commit is contained in:
@@ -10,6 +10,8 @@ from odoo.exceptions import UserError
|
||||
def _prepare_data(env, docids, data):
|
||||
# change product ids by actual product object to get access to fields in xml template
|
||||
# we needed to pass ids because reports only accepts native python types (int, float, strings, ...)
|
||||
|
||||
layout_wizard = env['product.label.layout'].browse(data.get('layout_wizard'))
|
||||
if data.get('active_model') == 'product.template':
|
||||
Product = env['product.template'].with_context(display_default_code=False)
|
||||
elif data.get('active_model') == 'product.product':
|
||||
@@ -23,11 +25,11 @@ def _prepare_data(env, docids, data):
|
||||
return {
|
||||
'quantity': quantity_by_product,
|
||||
'page_numbers': 1,
|
||||
'pricelist': layout_wizard.pricelist_id,
|
||||
}
|
||||
else:
|
||||
raise UserError(_('Product model not defined, Please contact your administrator.'))
|
||||
|
||||
layout_wizard = env['product.label.layout'].browse(data.get('layout_wizard'))
|
||||
if not layout_wizard:
|
||||
return {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user