brand icon indicating copy to clipboard operation
brand copied to clipboard

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

Open metaminux opened this issue 1 year ago • 5 comments

Module

brand_external_report_layout

Describe the bug

  • the model brand.document.layout is defining company_details (and should define is_company_details_empty also, as declared in #167 ) so it's not possible to use the same brand for different companies
  • the company Qweb variable is replaced by a res.brand object in reports, so every module inheriting company to add information in reports is conflicting (for example, l10n_ca from Odoo with account_fiscal_country_id and l10n_ca_pst fields)

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.

metaminux avatar Oct 31 '23 09:10 metaminux

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?

diniciacci avatar Mar 05 '24 11:03 diniciacci

There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.

github-actions[bot] avatar Sep 01 '24 12:09 github-actions[bot]

Closing bugs like this is not appropriate. Please disable the bot or increase the timeout, it already closed other valid bugs.

There is no activity on this because it is awaiting an aswer from the maintaner, not because the reporter didn't do his part.

The pull request is there. Keep open and merge that instead.

diniciacci avatar Sep 10 '24 08:09 diniciacci

@diniciacci is right, bug is still there...

Original PR #180 as been superseded by #201 but we're still waiting for a merge... @sbejaoui ?

metaminux avatar Sep 11 '24 11:09 metaminux

This module has never been tested properly! In the manifest file you find "assets": { "web.report_assets_common": [ "/brand_external_report_layout/" "static/src/legacy/scss/asset_styles_brand_report.scss" ] But in static/ there is only a discription where is the scss file???

@sbejaoui Can you please do the necessary?

jeanpaulrobineau avatar Sep 19 '24 06:09 jeanpaulrobineau

@OCA/brand-maintainers We need some feedback from maintainers here... please.

metaminux avatar Oct 02 '24 09:10 metaminux

Hi, I will check this and get back to you

sbejaoui avatar Oct 02 '24 10:10 sbejaoui