Browse Source

Sep 15 [FIX] : Bug Fixed 'pos_button_visibility'

pull/278/head
AjmalCybro 2 years ago
parent
commit
18b9c299bc
  1. 17
      pos_button_visibility/README.rst
  2. 3
      pos_button_visibility/__init__.py
  3. 33
      pos_button_visibility/__manifest__.py
  4. 4
      pos_button_visibility/data/pos_buttons_data.xml
  5. 6
      pos_button_visibility/doc/RELEASE_NOTES.md
  6. 3
      pos_button_visibility/models/__init__.py
  7. 6
      pos_button_visibility/models/pos_buttons.py
  8. 4
      pos_button_visibility/models/pos_session.py
  9. 9
      pos_button_visibility/models/res_users.py
  10. 2
      pos_button_visibility/security/ir.model.access.csv
  11. BIN
      pos_button_visibility/static/description/assets/modules/5.gif
  12. BIN
      pos_button_visibility/static/description/assets/modules/barcode.png
  13. BIN
      pos_button_visibility/static/description/assets/modules/custom_receipts_for_pos.png
  14. BIN
      pos_button_visibility/static/description/assets/modules/fatoorah.png
  15. BIN
      pos_button_visibility/static/description/assets/modules/integration_biometric.png
  16. BIN
      pos_button_visibility/static/description/assets/modules/login_pos_direct.png
  17. BIN
      pos_button_visibility/static/description/assets/modules/point_of_sale_logo.png
  18. BIN
      pos_button_visibility/static/description/assets/modules/pos_access_right_hr.png
  19. BIN
      pos_button_visibility/static/description/assets/modules/pos_book_order.jpg
  20. BIN
      pos_button_visibility/static/description/assets/modules/pos_receipt_extend.png
  21. BIN
      pos_button_visibility/static/description/assets/modules/product.png
  22. BIN
      pos_button_visibility/static/description/assets/modules/product_brand.png
  23. BIN
      pos_button_visibility/static/description/assets/modules/website_cart.png
  24. BIN
      pos_button_visibility/static/description/banner.jpg
  25. BIN
      pos_button_visibility/static/description/banner.png
  26. BIN
      pos_button_visibility/static/description/images/arrows-transparent.png
  27. BIN
      pos_button_visibility/static/description/images/cybro_logo.png
  28. BIN
      pos_button_visibility/static/description/images/icons/ecom.png
  29. BIN
      pos_button_visibility/static/description/images/icons/education.png
  30. BIN
      pos_button_visibility/static/description/images/icons/hotel.png
  31. BIN
      pos_button_visibility/static/description/images/icons/manufacturing.png
  32. BIN
      pos_button_visibility/static/description/images/icons/pos.png
  33. BIN
      pos_button_visibility/static/description/images/icons/restaurant.png
  34. BIN
      pos_button_visibility/static/description/images/icons/service.png
  35. BIN
      pos_button_visibility/static/description/images/icons/trading.png
  36. 34
      pos_button_visibility/static/description/index.html
  37. 54
      pos_button_visibility/static/src/js/RefundButton.js
  38. 52
      pos_button_visibility/static/src/js/refundbutton.js
  39. 2
      pos_button_visibility/static/src/xml/NumpadWidget.xml
  40. 0
      pos_button_visibility/static/src/xml/RefundButton.xml
  41. 2
      pos_button_visibility/static/src/xml/RewardButton.xml
  42. 5
      pos_button_visibility/views/res_users_views.xml

17
pos_button_visibility/README.rst

@ -1,10 +1,11 @@
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
.. image:: https://img.shields.io/badge/licence-LGPL--3-green.svg
:target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
Pos Button Visibility
User Wise Button Restrict In POS
=================================
Pos button visibility is used to visible the buttons in the pos basis of users and sessions
User Wise Button Restrict In POS is used to restrict the buttons in the pos
basis of users and sessions
Configuration
=============
@ -14,10 +15,14 @@ Company
-------
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__
License
-------
General Public License, Version 3 (LGPL v3).
(https://www.gnu.org/licenses/lgpl-3.0-standalone.html)
Credits
-------
* Developers: Cybrosys Techno Solutions odoo@cybrosys.com
Version 16: Gayathri V @cybrosys
* Developer: (V16) Gayathri V, Contact: odoo@cybrosys.com
Contacts
--------

3
pos_button_visibility/__init__.py

@ -1,4 +1,3 @@
"""pos button visibility"""
# -*- coding: utf-8 -*-
#############################################################################
#
@ -20,4 +19,4 @@
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from .import models
from . import models

33
pos_button_visibility/__manifest__.py

@ -20,33 +20,34 @@
#
#############################################################################
{
'name': 'Pos Button Visibility ',
'depends': ['base', 'point_of_sale', 'pos_sale', 'pos_loyalty'],
'version': '16.0.1.0.0',
'name': 'User Wise Button Restrict In POS ',
'version': '16.0.1.1.0',
'category': 'Point Of Sale',
'summary': """Pos button visibility is used to visible the buttons in the pos
basis of users and sessions""",
'description': """pos buttons can be restricted to the users in a specified sessions""",
'summary': """User Wise Button Restrict In POS is used to restrict the
buttons in the pos basis of users and sessions""",
'description': """pos buttons can be restricted to the users in a
specified sessions""",
'author': 'Cybrosys Techno Solutions',
'company': 'Cybrosys Techno Solutions',
'maintainer': 'Cybrosys Techno Solutions',
'website': 'https://www.cybrosys.com',
'images': ['static/description/banner.png'],
'license': 'LGPL-3',
'installable': True,
'auto_install': False,
'application': False,
'depends': ['base', 'point_of_sale', 'pos_sale', 'pos_loyalty'],
'data': {
'security/ir.model.access.csv',
'data/pos_button_visibility_data.xml',
'data/pos_buttons_data.xml',
'views/res_users_views.xml',
},
'assets': {
'point_of_sale.assets': [
'pos_button_visibility/static/src/js/refundbutton.js',
'pos_button_visibility/static/src/xml/refundbutton_templates.xml',
'pos_button_visibility/static/src/xml/rewardbutton_templates.xml',
'pos_button_visibility/static/src/xml/numpadwidget_templates.xml',
'pos_button_visibility/static/src/js/RefundButton.js',
'pos_button_visibility/static/src/xml/RefundButton.xml',
'pos_button_visibility/static/src/xml/RewardButton.xml',
'pos_button_visibility/static/src/xml/NumpadWidget.xml',
]
},
'images': ['static/description/banner.jpg'],
'license': 'LGPL-3',
'installable': True,
'auto_install': False,
'application': False,
}

4
pos_button_visibility/data/pos_button_visibility_data.xml → pos_button_visibility/data/pos_buttons_data.xml

@ -1,14 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!-- Record for Refund in model pos.button-->
<record id="refund_pos_buttons" model="pos.buttons">
<field name="name">Refund</field>
</record>
<!-- Record for Price in model pos.button-->
<record id="pos_price_buttons" model="pos.buttons">
<field name="name">Price</field>
</record>
<!-- Record for Discount in model pos.button-->
<record id="pos_discount_buttons" model="pos.buttons">
<field name="name">Discount</field>
</record>
<!-- Record for Reward in model pos.button-->
<record id="pos_reward_buttons" model="pos.buttons">
<field name="name">Reward</field>
</record>

6
pos_button_visibility/doc/RELEASE_NOTES.md

@ -3,4 +3,8 @@
#### 10.07.2023
#### Version 16.0.1.0.0
##### ADD
- Initial commit for Pos Button Visibility
- Initial commit for User Wise Button Restrict In POS
#### 15.09.2023
#### Version 16.0.1.1.0
#### DEBUG

3
pos_button_visibility/models/__init__.py

@ -1,4 +1,3 @@
"""button visibility in pos"""
# -*- coding: utf-8 -*-
#############################################################################
#
@ -21,5 +20,5 @@
#
#############################################################################
from . import pos_buttons
from . import pos_sessions
from . import pos_session
from . import res_users

6
pos_button_visibility/models/pos_buttons.py

@ -1,4 +1,3 @@
"""pos button visibility"""
# -*- coding: utf-8 -*-
#############################################################################
#
@ -23,8 +22,9 @@
from odoo import fields, models
class PosButton(models.Model):
class PosButtons(models.Model):
"""This is used to store the button"""
_name = 'pos.buttons'
_description = "Pos Buttons"
name = fields.Char(string="Name", help="pos buttons name")
name = fields.Char(string="Name", help="Pos buttons name")

4
pos_button_visibility/models/pos_sessions.py → pos_button_visibility/models/pos_session.py

@ -1,4 +1,3 @@
"""session to load"""
# -*- coding: utf-8 -*-
#############################################################################
#
@ -28,7 +27,8 @@ class PosSession(models.Model):
_inherit = 'pos.session'
def _loader_params_res_users(self):
"""Loading fields to pos sessions"""
"""Loading fields to pos sessions. This function load the fields of
res users into POS """
result = super()._loader_params_res_users()
result['search_params']['fields'].append('user_session_ids')
result['search_params']['fields'].append('buttons_pos_ids')

9
pos_button_visibility/models/res_users.py

@ -1,4 +1,3 @@
"""pos button visibility"""
# -*- coding: utf-8 -*-
#############################################################################
#
@ -29,11 +28,13 @@ class ResUsers(models.Model):
user_session_ids = fields.Many2many('pos.session',
domain=[('state', '!=', 'closed')],
string="Pos session", help="Session of pos")
buttons_pos_ids = fields.Many2many('pos.buttons', string="Pos Buttons",
string="Pos session",
help="Session of pos")
buttons_pos_ids = fields.Many2many('pos.buttons',
string="Pos Buttons",
help="pos buttons")
def pos_button_visibility(self, button):
"""this is used to return the restricted button name"""
"""This is used to return the restricted button name"""
pos_buttons = self.env['pos.buttons'].browse(button).mapped('name')
return pos_buttons

2
pos_button_visibility/security/ir.model.access.csv

@ -1,2 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_pos_buttons,pos.buttons,model_pos_buttons,base.group_user,1,1,1,1
access_pos_buttons_user,pos.buttons.user,model_pos_buttons,base.group_user,1,1,1,1

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_pos_buttons access_pos_buttons_user pos.buttons pos.buttons.user model_pos_buttons base.group_user 1 1 1 1

BIN
pos_button_visibility/static/description/assets/modules/5.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

BIN
pos_button_visibility/static/description/assets/modules/barcode.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

BIN
pos_button_visibility/static/description/assets/modules/custom_receipts_for_pos.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

BIN
pos_button_visibility/static/description/assets/modules/fatoorah.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

BIN
pos_button_visibility/static/description/assets/modules/integration_biometric.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

BIN
pos_button_visibility/static/description/assets/modules/login_pos_direct.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

BIN
pos_button_visibility/static/description/assets/modules/point_of_sale_logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

BIN
pos_button_visibility/static/description/assets/modules/pos_access_right_hr.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

BIN
pos_button_visibility/static/description/assets/modules/pos_book_order.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

BIN
pos_button_visibility/static/description/assets/modules/pos_receipt_extend.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
pos_button_visibility/static/description/assets/modules/product.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

BIN
pos_button_visibility/static/description/assets/modules/product_brand.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

BIN
pos_button_visibility/static/description/assets/modules/website_cart.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

BIN
pos_button_visibility/static/description/banner.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

BIN
pos_button_visibility/static/description/banner.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

BIN
pos_button_visibility/static/description/images/arrows-transparent.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

BIN
pos_button_visibility/static/description/images/cybro_logo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

BIN
pos_button_visibility/static/description/images/icons/ecom.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

BIN
pos_button_visibility/static/description/images/icons/education.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

BIN
pos_button_visibility/static/description/images/icons/hotel.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

BIN
pos_button_visibility/static/description/images/icons/manufacturing.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

BIN
pos_button_visibility/static/description/images/icons/pos.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

BIN
pos_button_visibility/static/description/images/icons/restaurant.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

BIN
pos_button_visibility/static/description/images/icons/service.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

BIN
pos_button_visibility/static/description/images/icons/trading.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

34
pos_button_visibility/static/description/index.html

@ -23,9 +23,9 @@
<!-- APP HERO -->
<h1 style="color: #FFFFFF; font-weight: bolder; font-size: 50px; text-align: center; margin-top: 50px;">
Pos Button Visibility</h1>
User Wise Button Restrict In POS</h1>
<p style="color:#FFFFFF; padding: 8px 15px; text-align: center; font-size: 24px;">
A module for restricting users to access the pos buttons.</p>
This module for restricting users to access the pos buttons.</p>
<!-- END OF APP HERO -->
<img src="assets/screenshots/hero.gif"
style="width: 75%; height: auto; position: absolute; margin-left: auto; margin-right: auto; top: 45%; left: 12%; right: auto;"/>
@ -108,7 +108,7 @@
<div class="row"
style="font-family: 'Montserrat', sans-serif; font-weight: 400; font-size: 14px; line-height: 200%;">
<div class="col-sm-12 py-4">
Pos button visibility is used to disable buttons for users based on the
User Wise Button Restrict In POS is used to disable buttons for users based on the
session.
</div>
</div>
@ -211,34 +211,34 @@
<div class="carousel-item" style="min-height: 198.656px;">
<div class="col-xs-12 col-sm-4 col-md-4 mb16 mt16"
style="float:left">
<a href="https://apps.odoo.com/apps/modules/16.0/myfatoorah_payment_gateway/"
<a href="https://apps.odoo.com/apps/modules/16.0/custom_receipts_for_pos/"
target="_blank">
<div style="border-radius:10px">
<img class="img img-responsive center-block"
style="border-radius: 0px;"
src="assets/modules/fatoorah.png">
src="assets/modules/custom_receipts_for_pos.png">
</div>
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-4 mb16 mt16"
style="float:left">
<a href="https://apps.odoo.com/apps/modules/16.0/website_cart_clear/"
<a href="https://apps.odoo.com/apps/modules/16.0/pos_book_order/"
target="_blank">
<div style="border-radius:10px">
<img class="img img-responsive center-block"
style="border-radius: 0px;"
src="assets/modules/website_cart.png">
src="assets/modules/pos_book_order.jpg">
</div>
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-4 mb16 mt16"
style="float:left">
<a href="https://apps.odoo.com/apps/modules/16.0/hr_zk_attendance/"
<a href="https://apps.odoo.com/apps/modules/16.0/point_of_sale_logo/"
target="_blank">
<div style="border-radius:10px">
<img class="img img-responsive center-block"
style="border-radius: 0px;"
src="assets/modules/integration_biometric.png">
src="assets/modules/point_of_sale_logo.png">
</div>
</a>
</div>
@ -247,34 +247,34 @@
style="min-height: 198.656px;">
<div class="col-xs-12 col-sm-4 col-md-4 mb16 mt16"
style="float:left">
<a href="https://apps.odoo.com/apps/modules/16.0/pos_credit_limit/"
<a href="https://apps.odoo.com/apps/modules/16.0/pos_receipt_extend/"
target="_blank">
<div style="border-radius:10px">
<img class="img img-responsive center-block"
style="border-radius: 0px;"
src="assets/modules/product_brand.png">
src="assets/modules/pos_receipt_extend.png">
</div>
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-4 mb16 mt16"
style="float:left">
<a href="https://apps.odoo.com/apps/modules/browse?search=pos_custom_percentage_tip_fixed"
<a href="https://apps.odoo.com/apps/modules/16.0/login_pos_direct/"
target="_blank">
<div style="border-radius:10px">
<img class="img img-responsive center-block"
style="border-radius: 0px;"
src="assets/modules/barcode.png">
src="assets/modules/login_pos_direct.png">
</div>
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-4 mb16 mt16"
style="float:left">
<a href="https://apps.odoo.com/apps/modules/16.0/product_brand_ecommerce/"
<a href="https://apps.odoo.com/apps/modules/16.0/pos_access_right_hr/"
target="_blank">
<div style="border-radius:10px">
<img class="img img-responsive center-block"
style="border-radius: 0px;"
src="assets/modules/product.png">
src="assets/modules/pos_access_right_hr.png">
</div>
</a>
</div>
@ -427,7 +427,7 @@
</div>
<!-- END OF END OF OUR SERVICES -->
<!-- END OF OUR SERVICES -->
<!-- OUR INDUSTRIES -->
@ -565,7 +565,7 @@
</div>
</div>
<!-- END OF END OF OUR INDUSTRIES -->
<!-- END OF OUR INDUSTRIES -->
<!-- SUPPORT -->
<div class="d-flex align-items-center"

54
pos_button_visibility/static/src/js/RefundButton.js

@ -0,0 +1,54 @@
odoo.define('pos_button_visibility.RefundButton', function (require) {
'use strict';
const Registries = require('point_of_sale.Registries');
const RefundButton = require('point_of_sale.RefundButton');
var rpc = require('web.rpc');
var { PosGlobalState } = require('point_of_sale.models');
/** Extends PosGlobalState to load model to pos **/
const PosSessionGlobalState = (PosGlobalState) => class PosSessionGlobalState extends PosGlobalState {
async _processData(loadedData) {
await super._processData(loadedData);
this.res_user = loadedData['res.users'];
this.user_session = loadedData['user_session_ids'];
this.buttons_pos = loadedData['buttons_pos_ids']
}
}
Registries.Model.extend(PosGlobalState, PosSessionGlobalState);
/** Extend RefundButton to add function **/
const PosButton = (RefundButton) =>
class extends RefundButton {
/** To set up the RefundButton **/
setup() {
super.setup(...arguments);
this.env.pos.user_session = []
this.env.pos.button =[]
this.userItem()
}
/** This is used to get the sessions and buttons**/
async userItem(){
var session;
if (this.env.pos.res_user.length !== 0)
{
var session = this.env.pos.res_user.user_session_ids;}
else{
session = false
}
var buttons;
if (this.env.pos.res_user.length !== 0)
{
var buttons = this.env.pos.res_user.buttons_pos_ids;}
else{
buttons = false
}
var def = await rpc.query({
model: 'res.users',
method: 'pos_button_visibility',
args: [,buttons]
})
this.env.pos.user_session = session
this.env.pos.button = def
}
};
Registries.Component.extend(RefundButton, PosButton)
return RefundButton
});

52
pos_button_visibility/static/src/js/refundbutton.js

@ -1,52 +0,0 @@
odoo.define('pos_all_in_one.refund', function (require) {
'use strict';
const Registries = require('point_of_sale.Registries');
const RefundButton = require('point_of_sale.RefundButton');
var rpc = require('web.rpc');
var { PosGlobalState } = require('point_of_sale.models');
const PosSessionGlobalState = (PosGlobalState) => class PosSessionGlobalState extends PosGlobalState {
//@override
async _processData(loadedData) {
await super._processData(loadedData);
this.res_user = loadedData['res.users'];
this.user_session = loadedData['user_session_ids'];
this.buttons_pos = loadedData['buttons_pos_ids']
}
}
Registries.Model.extend(PosGlobalState, PosSessionGlobalState);
const PosButton = (RefundButton) =>
class extends RefundButton {
setup() {
super.setup(...arguments);
this.env.pos.user_session = []
this.env.pos.button =[]
this.userItem()
}
//This is used to get the sessions and buttons
async userItem(){
var session;
if (this.env.pos.res_user.length !== 0)
{
var session = this.env.pos.res_user.user_session_ids;}
else{
session = false
}
var buttons;
if (this.env.pos.res_user.length !== 0)
{
var buttons = this.env.pos.res_user.buttons_pos_ids;}
else{
buttons = false
}
var def = await rpc.query({
model: 'res.users',
method: 'pos_button_visibility',
args: [,buttons]
})
this.env.pos.user_session = session
this.env.pos.button = def
}
};
Registries.Component.extend(RefundButton, PosButton)
return RefundButton
});

2
pos_button_visibility/static/src/xml/numpadwidget_templates.xml → pos_button_visibility/static/src/xml/NumpadWidget.xml

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<!--This is used to disable the restricted buttons -->
<!--This is used to disable the restricted Price button -->
<t t-name="Price" t-inherit="point_of_sale.NumpadWidget"
t-inherit-mode="extension" owl="1">
<xpath expr="//div[hasclass('numpad')]//button[hasclass('mode-button')][3]"

0
pos_button_visibility/static/src/xml/refundbutton_templates.xml → pos_button_visibility/static/src/xml/RefundButton.xml

2
pos_button_visibility/static/src/xml/rewardbutton_templates.xml → pos_button_visibility/static/src/xml/RewardButton.xml

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<!-- This is used to restrict the REFUND button if it is restricted -->
<!-- This is used to restrict the reward button if it is restricted -->
<t t-name="DisableReward" t-inherit="pos_loyalty.RewardButton"
t-inherit-mode="extension" owl="1">
<xpath expr="//span" position="replace">

5
pos_button_visibility/views/res_users_views.xml

@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!-- Adding pos sessions and buttons to the user form-->
<record id="res_users_view_form" model="ir.ui.view">
<field name="name">res.users.view.form.inherit.pos.button.visibility
</field>
<record id="view_users_form" model="ir.ui.view">
<field name="name">res.users.view.form.inherit.pos.button.visibility</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form"/>
<field name="arch" type="xml">

Loading…
Cancel
Save