Skip to content

Commit

Permalink
Use sudo for browsing res.city records in website_sale.
Browse files Browse the repository at this point in the history
This ensures the operation is performed with elevated permissions, avoiding potential access rights issues. The adjustments affect city-related data processing during checkout.
  • Loading branch information
dhongu committed Jan 27, 2025
1 parent dc50b1b commit 005de07
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions deltatech_website_city/controller/website_sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ def values_postprocess(self, order, mode, values, errors, error_msg):
new_values, errors, error_msg = super().values_postprocess(order, mode, values, errors, error_msg)
new_values["city_id"] = values.get("city_id")
if new_values["city_id"]:
city = request.env["res.city"].browse(int(values.get("city_id")))
city = request.env["res.city"].sudo().browse(int(values.get("city_id")))
if city:
new_values["city"] = city.name
return new_values, errors, error_msg

def checkout_form_validate(self, mode, all_form_values, data):
if not all_form_values.get("city") and all_form_values.get("city_id"):
city = request.env["res.city"].browse(int(all_form_values.get("city_id")))
city = request.env["res.city"].sudo().browse(int(all_form_values.get("city_id")))
data["city"] = city.name
all_form_values["city"] = city.name
error, error_message = super().checkout_form_validate(mode, all_form_values, data)
Expand Down

0 comments on commit 005de07

Please sign in to comment.