Skip to content

Commit

Permalink
[FIX] point_of_sale: raise access denied for user role
Browse files Browse the repository at this point in the history
We encounter an error when trying to open any POS category from the 'Dashboard,'
if the Administrator is assigned the role of 'User' for 'Point of Sale.'

Steps to reproduce:
- Install the 'point_of_sale' module(without demo)
- Change the right from 'Admin' -> 'User' in 'Point of Sale' in Users
- Now go to 'Dashboard' and try to open any category

Traceback: ParseError
while parsing /home/odoo/src/odoo/saas-17.4/addons/product/data/product_demo.xml:5, somewhere inside
<record id="base.group_user" model="res.groups">
            <field name="implied_ids" eval="[(4, ref('product.group_product_variant'))]"/>
        </record>

This commit will fix the above error by displaying an "Access Denied" pop-up for users with the
"User" role when attempting to open the POS category.

sentry-5717539295

closes odoo#187472

X-original-commit: eb6c873
Signed-off-by: David Monnom (moda) <[email protected]>
Signed-off-by: Aayush Modi (aamo) <[email protected]>
  • Loading branch information
aamo-odoo committed Nov 18, 2024
1 parent b1a81e1 commit 9a9320c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions addons/point_of_sale/i18n/point_of_sale.pot
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,12 @@ msgstr ""
msgid "Accept payments with an Adyen payment terminal"
msgstr ""

#. module: point_of_sale
#. odoo-javascript
#: code:addons/point_of_sale/static/src/backend/pos_kanban_view/pos_kanban_view.js:0
msgid "Access Denied"
msgstr ""

#. module: point_of_sale
#: model:ir.model.fields,field_description:point_of_sale.field_pos_config__access_token
msgid "Access Token"
Expand Down Expand Up @@ -3542,6 +3548,14 @@ msgstr ""
msgid "It is possible to print your tickets by making use of an IoT Box."
msgstr ""

#. module: point_of_sale
#. odoo-javascript
#: code:addons/point_of_sale/static/src/backend/pos_kanban_view/pos_kanban_view.js:0
msgid ""
"It seems like you don't have enough rights to create point of sale "
"configurations."
msgstr ""

#. module: point_of_sale
#: model:product.template,name:point_of_sale.jean_jacket_product_template
msgid "Jean Jacket"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { AlertDialog } from "@web/core/confirmation_dialog/confirmation_dialog";
import { registry } from "@web/core/registry";
import { kanbanView } from "@web/views/kanban/kanban_view";
import { onWillStart, useState, onWillRender } from "@odoo/owl";
import { KanbanRenderer } from "@web/views/kanban/kanban_renderer";
import { user } from "@web/core/user";
import { useService } from "@web/core/utils/hooks";
import { useTrackedAsync } from "@point_of_sale/app/hooks/hooks";
import { _t } from "@web/core/l10n/translation";
Expand Down Expand Up @@ -54,6 +56,9 @@ export class PosKanbanRenderer extends KanbanRenderer {
});

onWillRender(() => this.checkDisplayedResult());
onWillStart(async () => {
this.isPosManager = await user.hasGroup("point_of_sale.group_pos_manager");
});
}

checkDisplayedResult() {
Expand All @@ -62,6 +67,15 @@ export class PosKanbanRenderer extends KanbanRenderer {

async callWithViewUpdate(func) {
try {
if (!this.isPosManager) {
this.dialog.add(AlertDialog, {
title: _t("Access Denied"),
body: _t(
"It seems like you don't have enough rights to create point of sale configurations."
),
});
return;
}
await func();
await updatePosKanbanViewState(this.orm, this.posState);
} finally {
Expand Down

0 comments on commit 9a9320c

Please sign in to comment.