Skip to content

Commit

Permalink
[FIX] joint_buying_sale : compute fields with sudo, to avoid access e…
Browse files Browse the repository at this point in the history
…rror if user doesn't have right on sale.order model and / or does'nt belong to the correct company

[FIX] bad super call.
  • Loading branch information
legalsylvain committed Dec 13, 2023
1 parent ea6ec67 commit 56c642d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions joint_buying_sale/models/joint_buying_transport_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -74,15 +74,15 @@ 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(
JointBuyingTransportRequest, self.filtered(lambda x: not x.sale_order_id)
)._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(
Expand All @@ -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 += (
Expand All @@ -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())
Expand Down

0 comments on commit 56c642d

Please sign in to comment.