[FIX] sale_quotation_builder: multi-company
- Create 2 companies A & B - Set the website in A - Set the user in both companies, main company being A - Create a SO template in company B - Click on "Design Template" An AccessError is raised because: - `slug` accesses the `display_name` of the template which is in company B - the `allowed_company_ids` is set to company A in [1] A solution could be to always set: ``` context['allowed_company_ids'] = request.env.user.company_ids.ids ``` But the side-effects could cause other issues. Therefore, we handle the `slug` manually. [1] https://github.com/odoo/odoo/blob/af411b866aa2052c01168342f8f05ae3dabad83e/addons/website/models/ir_http.py#L203 opw-2194103 closes odoo/odoo#47249 X-original-commit: 0bcfffd291aceb74a5260a49d2fa3032f511dba1 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
@@ -3,12 +3,17 @@
|
||||
|
||||
from odoo import http
|
||||
from odoo.http import request
|
||||
from odoo.addons.http_routing.models.ir_http import unslug
|
||||
from odoo.addons.portal.controllers.portal import CustomerPortal
|
||||
|
||||
|
||||
class CustomerPortal(CustomerPortal):
|
||||
|
||||
@http.route(["/sale_quotation_builder/template/<model('sale.order.template'):template>"], type='http', auth="user", website=True)
|
||||
def sale_quotation_builder_template_view(self, template, **post):
|
||||
@http.route(["/sale_quotation_builder/template/<string:template_id>"], type='http', auth="user", website=True)
|
||||
def sale_quotation_builder_template_view(self, template_id, **post):
|
||||
template_id = unslug(template_id)[-1]
|
||||
template = request.env['sale.order.template'].browse(template_id).with_context(
|
||||
allowed_company_ids=request.env.user.company_ids.ids,
|
||||
)
|
||||
values = {'template': template}
|
||||
return request.render('sale_quotation_builder.so_template', values)
|
||||
|
||||
Reference in New Issue
Block a user