first commit
This commit is contained in:
commit
1616f6735e
1
__init__.py
Normal file
1
__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
from . import models
|
||||||
24
__manifest__.py
Normal file
24
__manifest__.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
{
|
||||||
|
'name': 'POS Employee Role',
|
||||||
|
'version': '1.0',
|
||||||
|
'category': 'Sales/Point of Sale',
|
||||||
|
'summary': 'Add roles to employees for POS permissions',
|
||||||
|
'description': """
|
||||||
|
This module adds a role to employees for Point of Sale.
|
||||||
|
Roles: Waiter/Server, Cashier, Outlet Manager, Area Manager.
|
||||||
|
These roles are used to restrict POS UI features dynamically.
|
||||||
|
""",
|
||||||
|
'depends': ['point_of_sale', 'pos_hr'],
|
||||||
|
'data': [
|
||||||
|
'views/hr_employee_views.xml',
|
||||||
|
],
|
||||||
|
'assets': {
|
||||||
|
'point_of_sale._assets_pos': [
|
||||||
|
'pos_employee_role/static/src/app/**/*',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
'installable': True,
|
||||||
|
'application': False,
|
||||||
|
'license': 'LGPL-3',
|
||||||
|
}
|
||||||
4
models/__init__.py
Normal file
4
models/__init__.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from . import hr_employee
|
||||||
|
from . import pos_session
|
||||||
13
models/hr_employee.py
Normal file
13
models/hr_employee.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from odoo import fields, models
|
||||||
|
|
||||||
|
class HrEmployee(models.Model):
|
||||||
|
_inherit = 'hr.employee'
|
||||||
|
|
||||||
|
pos_role = fields.Selection([
|
||||||
|
('waiter', 'Waiter/Server'),
|
||||||
|
('cashier', 'Cashier'),
|
||||||
|
('outlet_manager', 'Outlet Manager'),
|
||||||
|
('area_manager', 'Area Manager')
|
||||||
|
], string='POS Role', default='waiter', help='Defines the permission level constraint in the Point of Sale.')
|
||||||
11
models/pos_session.py
Normal file
11
models/pos_session.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from odoo import models
|
||||||
|
|
||||||
|
class PosSession(models.Model):
|
||||||
|
_inherit = 'pos.session'
|
||||||
|
|
||||||
|
def _loader_params_hr_employee(self):
|
||||||
|
result = super()._loader_params_hr_employee()
|
||||||
|
result['search_params']['fields'].append('pos_role')
|
||||||
|
return result
|
||||||
21
static/src/app/components/navbar/navbar.xml
Normal file
21
static/src/app/components/navbar/navbar.xml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<templates id="template" xml:space="preserve">
|
||||||
|
<!-- Restrict navbar actions based on employee role -->
|
||||||
|
<t t-name="pos_employee_role.Navbar" t-inherit="point_of_sale.Navbar" t-inherit-mode="extension">
|
||||||
|
|
||||||
|
<!-- Print Report: Outlet Manager, Area Manager -->
|
||||||
|
<xpath expr="//DropdownItem[@onSelected='() => this.showSaleDetails()']" position="attributes">
|
||||||
|
<attribute name="t-if">hardwareProxy.printer and (this.pos.cashier.pos_role == 'outlet_manager' or this.pos.cashier.pos_role == 'area_manager')</attribute>
|
||||||
|
</xpath>
|
||||||
|
|
||||||
|
<!-- Backend: Outlet Manager, Area Manager -->
|
||||||
|
<xpath expr="//DropdownItem[@onSelected='() => pos.closePos()']" position="attributes">
|
||||||
|
<attribute name="t-if">this.pos.cashier.pos_role == 'outlet_manager' or this.pos.cashier.pos_role == 'area_manager'</attribute>
|
||||||
|
</xpath>
|
||||||
|
|
||||||
|
<!-- Close Register: Not Waiter (Cashier, Outlet Manager, Area Manager) -->
|
||||||
|
<xpath expr="//DropdownItem[@onSelected='() => this.pos.closeSession()']" position="attributes">
|
||||||
|
<attribute name="t-if">this.pos.cashier.pos_role != 'waiter'</attribute>
|
||||||
|
</xpath>
|
||||||
|
</t>
|
||||||
|
</templates>
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<templates id="template" xml:space="preserve">
|
||||||
|
<!-- Hide payment button if role is waiter -->
|
||||||
|
<t t-name="pos_employee_role.ActionpadWidget" t-inherit="point_of_sale.ActionpadWidget" t-inherit-mode="extension">
|
||||||
|
<xpath expr="//button[contains(@class, 'pay-order-button')]" position="attributes">
|
||||||
|
<attribute name="t-if">this.pos.cashier.pos_role != 'waiter'</attribute>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//t[@t-foreach='this.pos.config.fast_payment_method_ids']" position="attributes">
|
||||||
|
<attribute name="t-if">this.pos.cashier.pos_role != 'waiter' and showFastPaymentMethods</attribute>
|
||||||
|
</xpath>
|
||||||
|
</t>
|
||||||
|
</templates>
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<templates id="template" xml:space="preserve">
|
||||||
|
<!-- Hide refund button in control buttons from waiter and cashier -->
|
||||||
|
<t t-name="pos_employee_role.ControlButtons" t-inherit="point_of_sale.ControlButtons" t-inherit-mode="extension">
|
||||||
|
<xpath expr="//button[@t-on-click='() => this.clickRefund()']" position="attributes">
|
||||||
|
<attribute name="t-if">this.pos.cashier._role != 'minimal' and (this.pos.cashier.pos_role == 'outlet_manager' or this.pos.cashier.pos_role == 'area_manager')</attribute>
|
||||||
|
</xpath>
|
||||||
|
</t>
|
||||||
|
</templates>
|
||||||
9
static/src/app/screens/ticket_screen/ticket_screen.xml
Normal file
9
static/src/app/screens/ticket_screen/ticket_screen.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<templates id="template" xml:space="preserve">
|
||||||
|
<!-- Hide refund button in Ticket Screen from waiter and cashier -->
|
||||||
|
<t t-name="pos_employee_role.TicketScreen" t-inherit="point_of_sale.TicketScreen" t-inherit-mode="extension">
|
||||||
|
<xpath expr="//button[@actionToTrigger.bind='onDoRefund']" position="attributes">
|
||||||
|
<attribute name="t-if">getHasItemsToRefund() and (this.pos.cashier.pos_role == 'outlet_manager' or this.pos.cashier.pos_role == 'area_manager')</attribute>
|
||||||
|
</xpath>
|
||||||
|
</t>
|
||||||
|
</templates>
|
||||||
16
views/hr_employee_views.xml
Normal file
16
views/hr_employee_views.xml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<record id="hr_employee_view_form_pos_role" model="ir.ui.view">
|
||||||
|
<field name="name">hr.employee.form.pos.role.inherit</field>
|
||||||
|
<field name="model">hr.employee</field>
|
||||||
|
<field name="inherit_id" ref="hr.view_employee_form" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<xpath expr="//header" position="inside">
|
||||||
|
</xpath>
|
||||||
|
<!-- In Odoo 19, hr.employee form view has Point of Sale settings under identification_group -->
|
||||||
|
<xpath expr="//group[@name='identification_group']" position="inside">
|
||||||
|
<field name="pos_role" />
|
||||||
|
</xpath>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
Loading…
Reference in New Issue
Block a user