From 7b65e6c6bb4d998ae485c323187601c573a7c005 Mon Sep 17 00:00:00 2001 From: Kaushalya Mandaliya Date: Thu, 9 May 2019 14:01:19 +0000 Subject: [PATCH] [FIX] stock: no formatting while printing traceability report for the first time While generating the traceability report for the first time, if the assets are not in cache, the report will be having simple markup with no styles applied. To workaround this issue, we manually commit the writes in the `ir.attachment` table. It is done thanks to a key in the context. Task-1974338 --- addons/stock/models/stock_traceability.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/stock/models/stock_traceability.py b/addons/stock/models/stock_traceability.py index 29e8ac22450..23b70b9ed43 100644 --- a/addons/stock/models/stock_traceability.py +++ b/addons/stock/models/stock_traceability.py @@ -2,6 +2,7 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo import api, models, _ +from odoo.tools import config rec = 0 @@ -206,7 +207,11 @@ class MrpStockReport(models.TransientModel): 'base_url': base_url, } - body = self.env['ir.ui.view'].render_template( + context = dict(self.env.context) + if not config['test_enable']: + context['commit_assetsbundle'] = True + + body = self.env['ir.ui.view'].with_context(context).render_template( "stock.report_stock_inventory_print", values=dict(rcontext, lines=lines, report=self, context=self), )