[FIX] base: make _prepare_html a api.model

It is used in account.tour.upload.bill without a record

Part-of: odoo/odoo#85110
This commit is contained in:
Martin Trigaux
2022-03-29 10:56:16 +02:00
parent f41ec39abe
commit a9db04a719
+3 -3
View File
@@ -345,7 +345,7 @@ class IrActionsReport(models.Model):
return command_args
def _prepare_html(self, html):
def _prepare_html(self, html, report_model=False):
'''Divide and recreate the header/footer html by merging all found in html.
The bodies are extracted and added to a list. Then, extract the specific_paperformat_args.
The idea is to put all headers/footers together. Then, we will use a javascript trick
@@ -400,7 +400,7 @@ class IrActionsReport(models.Model):
'base_url': base_url
}, raise_if_not_found=False)
bodies.append(body)
if node.get('data-oe-model') == self.model:
if node.get('data-oe-model') == report_model:
res_ids.append(int(node.get('data-oe-id', 0)))
else:
res_ids.append(None)
@@ -838,7 +838,7 @@ class IrActionsReport(models.Model):
html = self_sudo.with_context(context)._render_qweb_html(res_ids, data=data)[0]
bodies, html_ids, header, footer, specific_paperformat_args = self_sudo.with_context(context)._prepare_html(html)
bodies, html_ids, header, footer, specific_paperformat_args = self.with_context(context)._prepare_html(html, report_model=self_sudo.model)
if self_sudo.attachment and set(res_ids) != set(html_ids):
raise UserError(_("The report's template '%s' is wrong, please contact your administrator. \n\n"