OCA / brand

Manage brands for products and companies
GNU Affero General Public License v3.0
47 stars 156 forks source link

[16.0] brand_external_report_layout : can't be used in multi-company context and conflicts with other modules #179

Open metaminux opened 9 months ago

metaminux commented 9 months ago

Module

brand_external_report_layout

Describe the bug

To Reproduce

16.0:

Steps to reproduce the behavior:

  1. Create a new database with brand_external_report_layout installed and demo data
  2. Go to settings and set a specific document layout for first company (this should set the company details by default)
  3. Set the company with Brand use level = optional
  4. Switch company and do the same for the second company, with another layout
  5. Create a brand and set its document layout (for the moment, #167 is preventing to go further...)
  6. From now on, every sale, invoice, etc. that will use this brand will have the same address (company/brand details) for both companies

Expected behavior I think only "style" fields should be overridden by brands.

Additional context I'll propose a PR that keeps the original company object and temporarily modify it with data from brand then go back to original after the report is generated.

diniciacci commented 5 months ago

There is an extra consequence of this. It is impossible to generate invoices for printing in "batch" (i.e. invoicing->customers->invoices; select a bunch of invoices; print->invoices) this triggers and error for users that are not part of group Administration/Settings because of the missing access to the resources:

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/report.py", line 113, in report_download
response = self.report_routes(reportname, docids=docids, converter=converter, context=context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/http.py", line 697, in route_wrapper
result = endpoint(self, *args, **params_ok)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/report.py", line 42, in report_routes
pdf = report.with_context(context)._render_qweb_pdf(reportname, docids, data=data)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/addons/account/models/ir_actions_report.py", line 58, in _render_qweb_pdf
return super()._render_qweb_pdf(report_ref, res_ids=res_ids, data=data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 807, in _render_qweb_pdf
collected_streams = self._render_qweb_pdf_prepare_streams(report_ref, data, res_ids=res_ids)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/addons/account_edi_ubl_cii/models/ir_actions_report.py", line 58, in _render_qweb_pdf_prepare_streams
collected_streams = super()._render_qweb_pdf_prepare_streams(report_ref, data, res_ids=res_ids)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/addons/account_edi/models/ir_actions_report.py", line 14, in _render_qweb_pdf_prepare_streams
collected_streams = super()._render_qweb_pdf_prepare_streams(report_ref, data, res_ids=res_ids)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/addons/account/models/ir_actions_report.py", line 20, in _render_qweb_pdf_prepare_streams
return super()._render_qweb_pdf_prepare_streams(report_ref, data, res_ids=res_ids)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 708, in _render_qweb_pdf_prepare_streams
html = self.with_context(**additional_context)._render_qweb_html(report_ref, res_ids_wo_stream, data=data)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 884, in _render_qweb_html
return self._render_template(report.report_name, data), 'html'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 623, in _render_template
return view_obj._render_template(template, values).encode()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 2128, in _render_template
return self.env['ir.qweb']._render(template, values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/tools/profiler.py", line 292, in _tracked_method_render
return method_render(self, template, values, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_qweb.py", line 580, in _render
result = ''.join(rendering)
^^^^^^^^^^^^^^^^^^
File "<662>", line 90, in template_662
File "<662>", line 72, in template_662_content
File "<662>", line 60, in template_662_t_call_0
File "<658>", line 2091, in template_658
File "<658>", line 2080, in template_658_content
File "<203>", line 156, in template_203
odoo.addons.base.models.ir_qweb.QWebException: Error while render the template
AccessError: You are not allowed to access 'View' (ir.ui.view) records.

This operation is allowed for the following groups:
- Administration/Settings

Contact your administrator to request access if necessary.
Template: web.external_layout
Path: /t/t[7]
Node: <t t-if="o and \'brand_id\' in o.fields_get() and o.brand_id and o.brand_id.external_report_layout_id" t-call="{{o.brand_id.external_report_layout_id.key}}"/>

The above server error caused the following client error:
RPC_ERROR: Odoo Server Error
at makeErrorFromResponse (https://erp.semmel.it/web/assets/565-d105eb6/web.assets_backend.min.js:985:163)
at decoder.onload (https://erp.semmel.it/web/assets/565-d105eb6/web.assets_backend.min.js:973:7)

Any chance the associated pull requests gets any attention?