feat: hide PoS reporting menu in kanban view for restricted users via pos.config inheritance

This commit is contained in:
Suherdy Yacob 2026-06-08 15:46:16 +07:00
parent 7cc9f961f0
commit bc0487f65a
4 changed files with 32 additions and 0 deletions

View File

@ -14,6 +14,7 @@
'depends': ['base', 'point_of_sale', 'pos_enterprise'], 'depends': ['base', 'point_of_sale', 'pos_enterprise'],
'data': [ 'data': [
'views/res_users_views.xml', 'views/res_users_views.xml',
'views/pos_config_views.xml',
], ],
'installable': True, 'installable': True,
'application': False, 'application': False,

View File

@ -1,2 +1,3 @@
from . import res_users from . import res_users
from . import ir_ui_menu from . import ir_ui_menu
from . import pos_config

11
models/pos_config.py Normal file
View File

@ -0,0 +1,11 @@
from odoo import models, fields
class PosConfig(models.Model):
_inherit = 'pos.config'
is_pos_user_restricted = fields.Boolean(compute='_compute_is_pos_user_restricted')
def _compute_is_pos_user_restricted(self):
is_pos = self.env.user.is_pos_user
for config in self:
config.is_pos_user_restricted = is_pos

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_pos_config_kanban_inherit" model="ir.ui.view">
<field name="name">pos.config.kanban.view.inherit</field>
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.view_pos_config_kanban"/>
<field name="arch" type="xml">
<!-- Add our computed field to the kanban card view so it can be evaluated in templates -->
<xpath expr="//kanban" position="inside">
<field name="is_pos_user_restricted"/>
</xpath>
<!-- Hide the Reporting section (col-6) from the menu template if user is restricted -->
<xpath expr="//t[@t-name='menu']//div[contains(@class, 'row')]/div[2]" position="attributes">
<attribute name="invisible">is_pos_user_restricted</attribute>
</xpath>
</field>
</record>
</odoo>