[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
This commit is contained in:
Goffin Simon
2017-07-10 14:50:04 +02:00
parent fafdd027fa
commit 2b307b37ff
2 changed files with 19 additions and 1 deletions
+12
View File
@@ -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"
+7 -1
View File
@@ -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 {}