diff --git a/pos_restricted_customer_list/README.rst b/pos_restricted_customer_list/README.rst new file mode 100644 index 00000000..0e0e94e0 --- /dev/null +++ b/pos_restricted_customer_list/README.rst @@ -0,0 +1,69 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +============================ +POS Restricted Customer List +============================ + +In the point of sale, many installations work with cash registers with +anonymous customers. In that case, loading thousands, or even tens of +thousands of customers to each cash register is completely useless, and also +a huge danger for leaking privacy sensible data. + +This module will limit the download of customer data to only those customers +where this has been specifically requested. + +Technical information +===================== + +The module will add a flag 'available_in_pos' to res.partner. It will override +to domain of customers downloaded with pos to only download the partners +where this flag has been set. + +Roadmap +======= + +I see two obvious extensions to the functionality already developed: +1. Add back on demand customer lookup (only when online); +2. Make customers available to pos, dependent on the pos session or user. + In pos.config or res.users (or both) there could be a selection field + customer_loading with values: + - 'no_one': disable customer loading. + (usefull for self service pos, without customer feature) + - 'selection': the feature now implemented. + (load only checked customers). (default value). + - 'all': for super cashier, (after sale PoS), etc. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and +welcomed feedback. + + +Credits +======= + +Contributors +------------ + +* Ronald Portier + + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/pos_restricted_customer_list/__init__.py b/pos_restricted_customer_list/__init__.py new file mode 100644 index 00000000..d1501cd1 --- /dev/null +++ b/pos_restricted_customer_list/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# © 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import models diff --git a/pos_restricted_customer_list/__openerp__.py b/pos_restricted_customer_list/__openerp__.py new file mode 100644 index 00000000..1310e8f2 --- /dev/null +++ b/pos_restricted_customer_list/__openerp__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# © 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + 'name': 'POS with limited list of customers downloaded', + 'version': '8.0.0.1.0', + 'category': 'Point Of Sale', + 'summary': 'Optimise load time for POS where customer data not needed', + 'author': 'Therp BV, Odoo Community Association (OCA)', + 'website': 'https://therp.nl', + 'license': 'AGPL-3', + 'depends': [ + 'point_of_sale', + ], + 'data': [ + 'views/assets_backend.xml', + 'views/res_partner.xml', + ], + 'qweb': [], +} diff --git a/pos_restricted_customer_list/models/__init__.py b/pos_restricted_customer_list/models/__init__.py new file mode 100644 index 00000000..68369fda --- /dev/null +++ b/pos_restricted_customer_list/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# © 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from . import res_partner diff --git a/pos_restricted_customer_list/models/res_partner.py b/pos_restricted_customer_list/models/res_partner.py new file mode 100644 index 00000000..8d04f734 --- /dev/null +++ b/pos_restricted_customer_list/models/res_partner.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# © 2017 Therp BV +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from openerp import fields, models + + +class ResPartner(models.Model): + _inherit = 'res.partner' + + available_in_pos = fields.Boolean( + string='Available for POS', + ) diff --git a/pos_restricted_customer_list/static/src/js/pos_restricted_customer_list.js b/pos_restricted_customer_list/static/src/js/pos_restricted_customer_list.js new file mode 100644 index 00000000..23dc2f19 --- /dev/null +++ b/pos_restricted_customer_list/static/src/js/pos_restricted_customer_list.js @@ -0,0 +1,25 @@ +'use strict'; + +openerp.pos_restricted_customer_list = function (instance) { + var module = instance.point_of_sale; + + // we can't extend it because self.pos not ready yet + var _initializePosModel_ = module.PosModel.prototype.initialize; + module.PosModel.prototype.initialize = function(session, attributes){ + // override domain for res.partner to limit customers loaded + this.models.some(function (m, idx) { + if (m.model !== 'res.partner') + return false; + // check if not already done by someone else + for(var i = 0; i < m.domain.length; i++) { + var domain_tuple = m.domain[i]; + if (domain_tuple[0] === 'available_in_pos') { + return true; // domain already added + } + } + m.domain.push(['available_in_pos','=',true]); + return true; // no need to continue + }); + return _initializePosModel_.call(this, session, attributes); + }; +}; diff --git a/pos_restricted_customer_list/views/assets_backend.xml b/pos_restricted_customer_list/views/assets_backend.xml new file mode 100644 index 00000000..d35737f5 --- /dev/null +++ b/pos_restricted_customer_list/views/assets_backend.xml @@ -0,0 +1,18 @@ + + + + + + diff --git a/pos_restricted_customer_list/views/res_partner.xml b/pos_restricted_customer_list/views/res_partner.xml new file mode 100644 index 00000000..efa51849 --- /dev/null +++ b/pos_restricted_customer_list/views/res_partner.xml @@ -0,0 +1,18 @@ + + + + + view.partner.form.pos.available + res.partner + + + + + + + + +