Skip to content

Commit

Permalink
[MIG] pos_access_right: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jumeldi74 committed Apr 24, 2023
1 parent 833283f commit 1bb1fbc
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 87 deletions.
16 changes: 10 additions & 6 deletions pos_access_right/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@

{
"name": "Point of Sale - Extra Access Right",
"version": "14.0.1.0.2",
"version": "16.0.1.0.0",
"category": "Point Of Sale",
"summary": "Point of Sale - Extra Access Right for certain actions",
"author": "La Louve, GRAP, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/pos",
"license": "AGPL-3",
"depends": ["point_of_sale"],
"depends": ["pos_hr"],
"demo": ["demo/res_groups.xml"],
"data": [
"security/res_groups.xml",
"views/templates.xml",
],
"demo": [
"demo/res_groups.xml",
],
"assets": {
"point_of_sale.assets": [
"pos_access_right/static/src/css/*",
"pos_access_right/static/src/js/*.js",
"pos_access_right/static/src/xml/*.xml",
]
},
"qweb": [
"static/src/xml/*.xml",
],
Expand Down
1 change: 1 addition & 0 deletions pos_access_right/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import pos_config
from . import pos_session
38 changes: 38 additions & 0 deletions pos_access_right/models/pos_session.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from odoo import models


class PosSession(models.Model):
_inherit = "pos.session"

def _get_pos_ui_hr_employee(self, params):
employees = super()._get_pos_ui_hr_employee(params)
for employee in employees:
user = self.env["res.users"].browse(employee["user_id"])
if user:
groups = user.groups_id
config = self.config_id
employee["hasGroupPayment"] = (
True if config.group_payment_id in groups else False
)

employee["hasGroupDiscount"] = (
True if config.group_discount_id in groups else False
)

employee["hasGroupNegativeQty"] = (
True if config.group_negative_qty_id in groups else False
)

employee["hasGroupPriceControl"] = (
True if config.group_change_unit_price_id in groups else False
)

employee["hasGroupMultiOrder"] = (
True if config.group_multi_order_id in groups else False
)

employee["hasGroupDeleteOrder"] = (
True if config.group_delete_order_id in groups else False
)

return employees
1 change: 1 addition & 0 deletions pos_access_right/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* Sylvain LE GAL <https://twitter.com/legalsylvain>
* Ammmar Officewala <https://twitter.com/AmmarOfficewala>
* Helly kapatel <[email protected]>
* Jumeldi <[email protected], PT Solusi Aglis Indonesia>
19 changes: 7 additions & 12 deletions pos_access_right/static/src/js/NumpadWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,24 @@ odoo.define("pos_access_right.NumpadWidget", function (require) {
get hasManualDiscount() {
const res = super.hasManualDiscount;
if (res) {
if (this.env.pos.get_cashier().hasGroupDiscount) {
return true;
}
return false;
return this.env.pos.get_cashier().hasGroupDiscount;
}
return res;
}
get hasMinusControlRights() {
if (this.env.pos.get_cashier().hasGroupNegativeQty) {
return true;
}
return false;
return this.env.pos.get_cashier().hasGroupNegativeQty;
}
get hasPriceControlRights() {
const res = super.hasPriceControlRights;
if (res) {
if (this.env.pos.get_cashier().hasGroupPriceControl) {
return true;
}
return false;
return this.env.pos.get_cashier().hasGroupPriceControl;
}
return res;
}

get hasDeleteOrderLineRights() {
return this.env.pos.get_cashier().hasGroupDeleteOrder;
}
};

Registries.Component.extend(NumpadWidget, PosNumpadWidget);
Expand Down
9 changes: 3 additions & 6 deletions pos_access_right/static/src/js/TicketScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ odoo.define("pos_access_right.TicketScreen", function (require) {
const PosTicketScreen = (TicketScreen) =>
class extends TicketScreen {
get hasNewOrdersControlRights() {
if (this.env.pos.get_cashier().hasGroupMultiOrder) {
return true;
}
return false;
return this.env.pos.get_cashier().hasGroupMultiOrder;
}

async deleteOrder(order) {
async _onDeleteOrder({detail: order}) {
if (this.env.pos.get_cashier().hasGroupDeleteOrder) {
return super.deleteOrder(order);
return super._onDeleteOrder({detail: order});
}
return false;
}
Expand Down
40 changes: 0 additions & 40 deletions pos_access_right/static/src/js/models.js

This file was deleted.

12 changes: 12 additions & 0 deletions pos_access_right/static/src/xml/NumpadWidget.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@
>{'disabled-mode': !hasMinusControlRights}</attribute>
<attribute name="t-att-disabled">!hasMinusControlRights</attribute>
</xpath>

<xpath
expr="div[hasclass('numpad')]//button[hasclass('numpad-backspace')]"
position="attributes"
>
<attribute
name="t-att-class"
>{'disabled-mode': !hasDeleteOrderLineRights}</attribute>
<attribute name="t-att-disabled">!hasDeleteOrderLineRights</attribute>
</xpath>


</t>

</templates>
23 changes: 0 additions & 23 deletions pos_access_right/views/templates.xml

This file was deleted.

0 comments on commit 1bb1fbc

Please sign in to comment.