[FIX] pos_self_order: decode home images as sudo

**Current behavior:**
Trying to access the mobile order menu for a pos restaurant
with some non-default landing page images as a non-admin user
will result in an access error.

**Expected behavior:**
The images should load on this page for anyone who has a valid
access token for the page route.

**Steps to reproduce:**
1. Make a restaurant in the POS application

2. Enable mobile ordering and set a database user with `user`
     level access to the POS app to be the default user for
     this newly created restaurant

3. Upload a splash image for the restaurant

3. On the POS dashboard, select the three vertical dot button
     on the restaurant -> `Mobile Menu` to get the access error

**Cause of the issue:**
The default user on the restaurant POS will not necessarily
have access rights to the `ir.attachment` model/records.

**Fix:**
Get the images as sudo()- IMO there isn't a reason these should
be inaccessible to anybody considering they are intended to be
seen on the landing page by people trying to order.

opw-3748314

closes odoo/odoo#155589

Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com>
This commit is contained in:
Ethan Vincent
2024-02-29 10:34:20 +00:00
parent 9c9552fd20
commit 5e4e6e919f
+1 -1
View File
@@ -395,7 +395,7 @@ class PosConfig(models.Model):
for image in images:
encoded_images.append({
'id': image.id,
'data': image.datas.decode('utf-8'),
'data': image.sudo().datas.decode('utf-8'),
})
return encoded_images