Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎉1️⃣0️⃣ pos_disable_payment_restaurant module #941

Merged
merged 11 commits into from
Apr 8, 2019
2 changes: 1 addition & 1 deletion pos_disable_payment/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
'name': "Disable payments in POS",
'summary': "Control access to the POS payments",
'version': '10.0.3.6.1',
'version': '10.0.3.7.0',
'author': 'IT-Projects LLC, Ivan Yelizariev',
'license': 'LGPL-3',
'category': 'Point Of Sale',
Expand Down
6 changes: 6 additions & 0 deletions pos_disable_payment/doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Updates
=======

`3.7.0`
-------

**Improvement:** New option "Disable customer selection"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

**Improvement:** Move the "Allow change Qty for kitchen orders" option to pos_disable_payment_restaurant module

`3.6.1`
-------
- IMP: Compatibility with pos_restaurant_base module
Expand Down
12 changes: 1 addition & 11 deletions pos_disable_payment/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from odoo import fields, models, api
from odoo import fields, models


class ResUsers(models.Model):
Expand All @@ -10,17 +10,7 @@ class ResUsers(models.Model):
allow_discount = fields.Boolean('Allow discount', default=True)
allow_edit_price = fields.Boolean('Allow edit price', default=True)
allow_decrease_amount = fields.Boolean('Allow decrease quantity on order line', default=True)
allow_decrease_kitchen_only = fields.Boolean('Allow change Qty for kitchen orders', default=True)
allow_delete_order_line = fields.Boolean('Allow remove order line', default=True)
allow_create_order_line = fields.Boolean('Allow create order line', default=True)
allow_refund = fields.Boolean('Allow refunds', default=True)
allow_manual_customer_selecting = fields.Boolean('Allow manual customer selecting', default=True)
is_restaurant_installed = fields.Boolean(compute='_compute_state')

def _compute_state(self):
for r in self:
r.is_restaurant_installed = r.is_module_installed('pos_restaurant')

@api.model
def is_module_installed(self, module_name=None):
return module_name in self.env['ir.module.module']._installed()
1 change: 1 addition & 0 deletions pos_disable_payment/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ <h3 class="oe_slogan">Disable payments in POS</h3>
<li>Disable decrease order line</li>
<li>Disable removing order line</li>
<li>Disable refunds</li>
<li>Disable customer selection</li>
</ul>
This could be useful when using POS only to get price of item by barcode.
Also it could help to solve the problem related to the theft of money by staff members (e.g., the situation is possible when employee can print the bill, take money, then delete all lines and restart a new order on the same order).
Expand Down
32 changes: 3 additions & 29 deletions pos_disable_payment/static/src/js/pos_disable_payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ odoo.define('pos_disable_payment', function(require){
var PosBaseWidget = require('point_of_sale.BaseWidget');
var _t = core._t;

models.load_fields("res.users", ['allow_payments','allow_delete_order','allow_discount','allow_edit_price','allow_decrease_amount','allow_decrease_kitchen_only','allow_delete_order_line','allow_create_order_line','allow_refund','allow_manual_customer_selecting']);
models.load_fields("res.users", ['allow_payments','allow_delete_order','allow_discount','allow_edit_price','allow_decrease_amount', 'allow_delete_order_line','allow_create_order_line','allow_refund','allow_manual_customer_selecting']);

// Example of event binding and handling (triggering). Look up binding lower bind('change:cashier' ...
// Example extending of class (method set_cashier), than was created using extend.
Expand Down Expand Up @@ -111,7 +111,6 @@ odoo.define('pos_disable_payment', function(require){
} else {
// disable the backspace button of numpad
$('.pads .numpad').find('.numpad-backspace').addClass('disable');
this.check_kitchen_access(line);
}
}
},
Expand All @@ -122,33 +121,6 @@ odoo.define('pos_disable_payment', function(require){
if (order && !user.allow_decrease_amount) {
// disable the backspace button of numpad
$('.pads .numpad').find('.numpad-backspace').addClass('disable');
this.check_kitchen_access(line);
}
},
check_kitchen_access: function(line) {
var user = this.pos.cashier || this.pos.user;
var state = this.getParent().numpad.state;
if (user.allow_decrease_kitchen_only) {
$('.numpad').find("[data-mode='quantity']").removeClass('disable');
if (state.get('mode') !== 'quantity') {
state.changeMode('quantity');
}
} else if (line.mp_dirty) {
if ($('.numpad').find("[data-mode='quantity']").hasClass('disable')) {
$('.numpad').find("[data-mode='quantity']").removeClass('disable');
state.changeMode('quantity');
}
} else {
$('.numpad').find("[data-mode='quantity']").addClass('disable');
if (state.get('mode') === 'quantity') {
if (user.allow_discount) {
state.changeMode('discount');
} else if (user.allow_edit_price) {
state.changeMode('price');
} else {
state.changeMode("");
}
}
}
}
});
Expand Down Expand Up @@ -302,4 +274,6 @@ odoo.define('pos_disable_payment', function(require){
}
}
});

return screens;
});
2 changes: 0 additions & 2 deletions pos_disable_payment/views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
<field name="allow_discount" attrs="{'invisible':[('allow_create_order_line','=',False)]}"/>
<field name="allow_edit_price" attrs="{'invisible':[('allow_create_order_line','=',False)]}"/>
<field name="allow_decrease_amount" attrs="{'invisible':[('allow_create_order_line','=',False)]}"/>
<field name="allow_decrease_kitchen_only" attrs="{'invisible':['|',('allow_decrease_amount', '=', True),('is_restaurant_installed', '=', False)]}"/>
<field name="is_restaurant_installed" invisible="1"/>
<field name="allow_delete_order_line" attrs="{'invisible':['|',('allow_decrease_amount','=',False),('allow_create_order_line','=',False)]}"/>
<field name="allow_refund" attrs="{'invisible':[('allow_create_order_line','=',False)]}"/>
<field name="allow_manual_customer_selecting"/>
Expand Down
48 changes: 48 additions & 0 deletions pos_disable_payment_restaurant/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.. image:: https://img.shields.io/badge/license-LGPL--3-blue.png
:target: https://www.gnu.org/licenses/lgpl
:alt: License: LGPL-3

===============================================
Disable options in POS (restaurant extension)
===============================================

Control access to POS Restaurant options

The module adds new options on user form (``Point of Sale`` tab):

* ``Allow change Qty for kitchen orders``
* ``Allow remove kitchen order line``

Credits
=======

Contributors
------------
* `Dinar Gabbasov <https://it-projects.info/team/GabbasovDinar>`__

Sponsors
--------
* `IT-Projects LLC <https://it-projects.info>`__

Maintainers
-----------
* `IT-Projects LLC <https://it-projects.info>`__

To get a guaranteed support you are kindly requested to purchase the module at `odoo apps store <https://apps.odoo.com/apps/modules/10.0/pos_disable_payment_restaurant/>`__.

Thank you for understanding!

`IT-Projects Team <https://www.it-projects.info/team>`__

Further information
===================

Demo: http://runbot.it-projects.info/demo/pos-addons/10.0

HTML Description: https://apps.odoo.com/apps/modules/10.0/pos_disable_payment_restaurant/

Usage instructions: `<doc/index.rst>`_

Changelog: `<doc/changelog.rst>`_

Tested on Odoo 10.0 c4a11cb42a4a3f3f49c2024fb2b081d638e383b0
2 changes: 2 additions & 0 deletions pos_disable_payment_restaurant/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import models
55 changes: 55 additions & 0 deletions pos_disable_payment_restaurant/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Dinar Gabbasov <https://it-projects.info/team/GabbasovDinar>
# Copyright 2018 Ilmir Karamov <https://it-projects.info/team/ilmir-k>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
{
"name": """Disable options in POS (restaurant extension)""",
"summary": """Control access to POS restaurant options""",
"category": "Point of Sale",
"live_test_url": "http://apps.it-projects.info/shop/product/pos-disable-payment-restaurant?version=10.0",
"images": ['images/pos_disable_payment_restaurant.jpg'],
"version": "10.0.1.0.0",
"application": False,

"author": "IT-Projects LLC, Dinar Gabbasov",
"support": "pos@it-projects.info",
"website": "https://it-projects.info/team/GabbasovDinar",
"license": "LGPL-3",
"price": 29.00,
"currency": "EUR",

"depends": [
"pos_disable_payment",
"pos_restaurant",
"web_tour",
],
"external_dependencies": {"python": [], "bin": []},
"data": [
"views/template.xml",
"views/view.xml",
"views/assets_demo.xml",
],
"qweb": [
],
"demo": [
],

"post_load": None,
"pre_init_hook": None,
"post_init_hook": None,
"uninstall_hook": None,

"auto_install": False,
"installable": True,

"demo_title": "Disable options in POS (restaurant extension)",
"demo_addons": [
],
"demo_addons_hidden": [
],
"demo_url": "pos-disable-payment-restaurant",
"demo_summary": "Control access to POS restaurant options",
"demo_images": [
"images/pos_disable_payment_restaurant.jpg",
]
}
4 changes: 4 additions & 0 deletions pos_disable_payment_restaurant/doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
`1.0.0`
-------

- Init version
29 changes: 29 additions & 0 deletions pos_disable_payment_restaurant/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
===============================================
Disable options in POS (restaurant extension)
===============================================

Installation
============

* `Install <https://odoo-development.readthedocs.io/en/latest/odoo/usage/install-module.html>`__ this module in a usual way

Usage
=====

* Go to ``[Settings] >> Users`` menu

* Open user form
* Open **Point of Sale** tab
* Uncheck ``[x] Allow change Qty for kitchen orders`` box
* Uncheck ``[x] Allow remove kitchen order line`` box
* Click ``[Save]``

* Go to ``[Point of Sale]`` menu
* Open POS session

* Add products allowed to be sent to kitchen
* Click ``[Order]``
* RESULT: Disabled ``Qty`` button
* Then set product quantity to ``0`` using ``Backspace`` button
* RESULT: Once the qty equals to 0, ``Backspace`` button is disabled

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions pos_disable_payment_restaurant/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from . import model
17 changes: 17 additions & 0 deletions pos_disable_payment_restaurant/models/model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Dinar Gabbasov <https://it-projects.info/team/GabbasovDinar>
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from odoo import fields, models, api


class ResUsers(models.Model):
_inherit = 'res.users'

allow_decrease_kitchen = fields.Boolean('Allow change Qty for kitchen orders', default=True)
allow_remove_kitchen_order_line = fields.Boolean('Allow remove kitchen order line', default=True)

@api.onchange('allow_delete_order_line')
def _onchange_allow_delete_order_line(self):
if self.allow_delete_order_line is False:
self.allow_remove_kitchen_order_line = False
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading