Browse Source

[8.0][ADD] New module to only load specific customers in POS. (#168)

* [ADD] New module to only load specific customers in POS.

* [FIX] Changes after review - renamed module to pos_restricted_customer_list.
pull/183/head
Ronald Portier 7 years ago
committed by Rafael Blasco
parent
commit
2097776649
  1. 69
      pos_restricted_customer_list/README.rst
  2. 4
      pos_restricted_customer_list/__init__.py
  3. 20
      pos_restricted_customer_list/__openerp__.py
  4. 4
      pos_restricted_customer_list/models/__init__.py
  5. 12
      pos_restricted_customer_list/models/res_partner.py
  6. 25
      pos_restricted_customer_list/static/src/js/pos_restricted_customer_list.js
  7. 18
      pos_restricted_customer_list/views/assets_backend.xml
  8. 18
      pos_restricted_customer_list/views/res_partner.xml

69
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 <https://github.com/OCA/web/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 <ronald@therp.nl>
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.

4
pos_restricted_customer_list/__init__.py

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# © 2017 Therp BV <https://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import models

20
pos_restricted_customer_list/__openerp__.py

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# © 2017 Therp BV <https://therp.nl>
# 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': [],
}

4
pos_restricted_customer_list/models/__init__.py

@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# © 2017 Therp BV <https://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import res_partner

12
pos_restricted_customer_list/models/res_partner.py

@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
# © 2017 Therp BV <https://therp.nl>
# 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',
)

25
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);
};
};

18
pos_restricted_customer_list/views/assets_backend.xml

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<template
id="assets_backend"
name="pos_restricted_customer_list assets"
inherit_id="web.assets_backend"
>
<xpath expr="." position="inside">
<script
type="text/javascript"
src="/pos_restricted_customer_list/static/src/js/pos_restricted_customer_list.js"
>
</script>
</xpath>
</template>
</data>
</openerp>

18
pos_restricted_customer_list/views/res_partner.xml

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp><data>
<record id="view_partner_form" model="ir.ui.view">
<field name="name">view.partner.form.pos.available</field>
<field name="model">res.partner</field>
<field
name="inherit_id"
ref="point_of_sale.view_partner_property_form"
/>
<field name="arch" type="xml">
<field name="ean13" position="before">
<field name="available_in_pos"/>
</field>
</field>
</record>
</data></openerp>
Loading…
Cancel
Save