From 56c642da09b2010421357d4152026550628cc10b Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Tue, 12 Dec 2023 17:58:39 +0100 Subject: [PATCH] [FIX] joint_buying_sale : compute fields with sudo, to avoid access error if user doesn't have right on sale.order model and / or does'nt belong to the correct company [FIX] bad super call. --- .../models/joint_buying_transport_request.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/joint_buying_sale/models/joint_buying_transport_request.py b/joint_buying_sale/models/joint_buying_transport_request.py index efbc8392..a4b406fc 100644 --- a/joint_buying_sale/models/joint_buying_transport_request.py +++ b/joint_buying_sale/models/joint_buying_transport_request.py @@ -55,10 +55,10 @@ def _get_depends_can_change(self): def _compute_origin(self): super( JointBuyingTransportRequest, self.filtered(lambda x: not x.sale_order_id) - )._compute_request_type() + )._compute_origin() for request in self.filtered(lambda x: x.sale_order_id): - request.origin = request.sale_order_id.name + request.origin = request.sale_order_id.sudo().name def _compute_request_type(self): super( @@ -74,7 +74,7 @@ def _compute_amount_untaxed(self): )._compute_amount_untaxed() for request in self.filtered(lambda x: x.sale_order_id): - request.amount_untaxed = request.sale_order_id.amount_untaxed + request.amount_untaxed = request.sale_order_id.sudo().amount_untaxed def _compute_total_weight(self): super( @@ -82,7 +82,7 @@ def _compute_total_weight(self): )._compute_total_weight() for request in self.filtered(lambda x: x.sale_order_id): - request.total_weight = request.sale_order_id.total_ordered_weight + request.total_weight = request.sale_order_id.sudo().total_ordered_weight def _compute_description(self): super( @@ -91,7 +91,7 @@ def _compute_description(self): for request in self.filtered(lambda x: x.sale_order_id): description = "" - for line in request.sale_order_id.order_line.filtered( + for line in request.sale_order_id.sudo().order_line.filtered( lambda x: x.display_type not in ["line_note", "line_section"] ): description += ( @@ -115,7 +115,7 @@ def _compute_can_change(self): def _get_report_tour_data_sale(self): self.ensure_one() res = [] - for line in self.sudo().sale_order_id.order_line.filtered( + for line in self.sale_order_id.sudo().order_line.filtered( lambda x: x.display_type not in ["line_note", "line_section"] ): res.append(line._get_report_tour_data())