From 2b307b37ff08941a34c2bf103a248976bad54759 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 6 Jul 2017 17:36:30 +0200 Subject: [PATCH] [FIX] product: Print Price list When printing a report, if the company logo or report layout is not set, it will return an action (ir.actions.act_window) to set the layout or the logo. But this change of actions does not forward the data parameters to print the price list. So it raised an error. PS: the problem comes from function "set_report_template" which doesn't take the data parameters into account when it is called from "res.company.report.form". opw:749724 --- addons/product/i18n/product.pot | 12 ++++++++++++ addons/product/wizard/product_price_list.py | 8 +++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/addons/product/i18n/product.pot b/addons/product/i18n/product.pot index 480446679a9..e71a85544ec 100644 --- a/addons/product/i18n/product.pot +++ b/addons/product/i18n/product.pot @@ -1842,6 +1842,18 @@ msgstr "" msgid "You cannot define the decimal precision of 'Account' as greater than the rounding factor of the company's main currency" msgstr "" +#. module: product +#: code:addons/product/wizard/product_price_list.py:26 +#, python-format +msgid "You have to set a logo for your company." +msgstr "" + +#. module: product +#: code:addons/product/wizard/product_price_list.py:28 +#, python-format +msgid "You have to set your reports's header and footer layout." +msgstr "" + #. module: product #: model:ir.actions.act_window,help:product.product_uom_form_action msgid "You must define a conversion rate between several Units of\n" diff --git a/addons/product/wizard/product_price_list.py b/addons/product/wizard/product_price_list.py index de344bae5aa..8114c222ac6 100644 --- a/addons/product/wizard/product_price_list.py +++ b/addons/product/wizard/product_price_list.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, fields, models +from odoo import api, fields, models, _ +from odoo.exceptions import UserError class product_price_list(models.TransientModel): @@ -21,6 +22,11 @@ class product_price_list(models.TransientModel): To get the date and print the report @return : return report """ + if (not self.env.user.company_id.logo): + raise UserError(_("You have to set a logo or a layout for your company.")) + elif (not self.env.user.company_id.external_report_layout): + raise UserError(_("You have to set your reports's header and footer layout.")) + datas = {'ids': self.env.context.get('active_ids', [])} res = self.read(['price_list', 'qty1', 'qty2', 'qty3', 'qty4', 'qty5']) res = res and res[0] or {}