As Robin Chatfield noticed Yenthe's fix will break a lot of features, e.g. e-mail recipients will get broken links with the wrong base. I've tried to add the report.url parameter using v. 10.0 but still faced problems with website_sale reports renderings that customers receive after finishing a purchase because the corresponding default method was seeking CSS at the wrong path. So I left the created 'report.url' system parameter and overrode the built-in method like this:
from odoo import models, fields, api
from odoo.http import request
import time
class ReportGenerationFix(models.Model):
_inherit = 'report'
@api.multi
def render(self, template, values=None):
if values is None:
values = {}
context = dict(self.env.context, inherit_branding=True)
user = self.env['res.users'].browse(self.env.uid)
website = None
if request and hasattr(request, 'website'):
if request.website is not None:
website = request.website
context = dict(context, translatable=context.get('lang') != request.website.default_lang_code)
view_obj = self.env['ir.ui.view'].with_context(context)
values.update(
time=time,
context_timestamp=lambda t: fields.Datetime.context_timestamp(self.with_context(tz=user.tz), t),
editable=True,
user=user,
res_company=user.company_id,
website=website,
web_base_url=self.env['ir.config_parameter'].get_param('report.url', default='')
)
return view_obj.render_template(template, values)
Thanks
I think you could add more information about your problem... I have some problem with report generation, but in my case I have some empty sale orders. I'm searching for a solution, if I find any useful information for you I'll post here.
Maybe it's help you: https://github.com/odoo/odoo/issues/364#issuecomment-47309589 https://www.odoo.com/forum/help-1/question/openerp-v8-wkhtmltopdf-0-12-0-error-bug-52041