Skip to content

Commit

Permalink
🎉1️⃣0️⃣ pos_disable_payment_restaurant module (#941)
Browse files Browse the repository at this point in the history
* [10.0][NEW] pos_disable_payment_restaurant module (it-projects-llc/addons-dev#394)

* [REF] remove old code

* [10.0][NEW] Disable payments in Restaurant

* [10.0][FIX] pos_disable_payment_restaurant: line is undefined (it-projects-llc/addons-dev#404)

* [DOC] pos_disable_payment_restaurant description (it-projects-llc/addons-dev#401)

* [DOC] pos_disable_payment_restaurant description

* 🚑 pos_disable_payment_resturant: the options work correctly now (it-projects-llc/addons-dev#595)

* 📖 pos_disable_payment_restaurant (it-projects-llc/addons-dev#593)

* [10.0][NEW] pos_disable_payment_restaurant module (it-projects-llc/addons-dev#394)

* [REF] remove old code

* [10.0][NEW] Disable payments in Restaurant

* [DOC] pos_disable_payment_restaurant description

* [10.0][FIX] pos_disable_payment_restaurant: line is undefined (it-projects-llc/addons-dev#404)

* 📖 pos_disable_payment_restaurant module

* 📖 pos_disable_payment_restaurant: update for the docs

* 🛡️ added ci tests

* 🛡️ fix tests

* 🛡️ pos_disable_payment_restaurant: fixes for ci tests (it-projects-llc/addons-dev#615)

* 🛡️ pos_disable_payment_restaurant: ci tests

* 🛡️ fix tests

* 🛡️ new fix

* 🛡️ update for tests; 📖 update for docs

* 📖 update for description

* 🛡️ fixes for test

* 🛡️ minor fix

* 🌹 pos_disable_payment: changelog

* 🌹 fix version

* 🌹 version
  • Loading branch information
ilmir-k committed Apr 8, 2019
1 parent 8ca3dab commit 25b8b40
Show file tree
Hide file tree
Showing 26 changed files with 575 additions and 43 deletions.
2 changes: 1 addition & 1 deletion pos_disable_payment/__manifest__.py
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
Expand Up @@ -3,6 +3,12 @@
Updates
=======

`3.7.0`
-------

**Improvement:** New option "Disable customer selection"
**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
@@ -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
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
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
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
@@ -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
@@ -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
@@ -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
@@ -0,0 +1,4 @@
`1.0.0`
-------

- Init version
29 changes: 29 additions & 0 deletions pos_disable_payment_restaurant/doc/index.rst
@@ -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

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
@@ -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
@@ -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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 25b8b40

Please sign in to comment.