From 5f5a0c58a1ded1a01497058d04f8df7a2781578e Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 9 Mar 2020 11:08:35 +0000 Subject: [PATCH] [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) --- addons/sale_quotation_builder/controllers/portal.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/sale_quotation_builder/controllers/portal.py b/addons/sale_quotation_builder/controllers/portal.py index 55a8f4f84d9..3b2d52ee187 100644 --- a/addons/sale_quotation_builder/controllers/portal.py +++ b/addons/sale_quotation_builder/controllers/portal.py @@ -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/"], type='http', auth="user", website=True) - def sale_quotation_builder_template_view(self, template, **post): + @http.route(["/sale_quotation_builder/template/"], 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)