François Honoré
4 years ago
10 changed files with 68 additions and 61 deletions
-
31pos_restricted_customer_list/__openerp__.py
-
15pos_restricted_customer_list/models/res_partner.py
-
48pos_restricted_customer_list/static/src/js/pos_restricted_customer_list.js
-
14pos_restricted_customer_list/views/assets_backend.xml
-
9pos_restricted_customer_list/views/res_partner.xml
-
2setup/.setuptools-odoo-make-default-ignore
-
2setup/README
-
1setup/pos_restricted_customer_list/odoo_addons/__init__.py
-
1setup/pos_restricted_customer_list/odoo_addons/pos_restricted_customer_list
-
6setup/pos_restricted_customer_list/setup.py
@ -1,24 +1,17 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright 2017-2019 Therp BV <https://therp.nl> |
|||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). |
|||
|
|||
{ |
|||
'name': "POS: restricted customer list", |
|||
'version': '9.0.1.0.0', |
|||
'development_status': "Production/Stable", |
|||
'category': "Point Of Sale"'', |
|||
'summary': "This module will limit the download of customer data to " |
|||
"only those customers where this has been specifically " |
|||
"requested.", |
|||
'author': "Therp BV, Odoo Community Association (OCA)", |
|||
'website': "https://github.com/OCA/pos/tree/9.0/" |
|||
"pos_restricted_customer_list", |
|||
'license': "AGPL-3", |
|||
'depends': [ |
|||
'point_of_sale', |
|||
], |
|||
'data': [ |
|||
'views/assets_backend.xml', |
|||
'views/res_partner.xml', |
|||
], |
|||
"name": "POS: restricted customer list", |
|||
"version": "9.0.1.0.0", |
|||
"development_status": "Production/Stable", |
|||
"category": "Point Of Sale" "", |
|||
"summary": "This module will limit the download of customer data to " |
|||
"only those customers where this has been specifically " |
|||
"requested.", |
|||
"author": "Therp BV, Odoo Community Association (OCA)", |
|||
"website": "https://github.com/OCA/pos/tree/9.0/" "pos_restricted_customer_list", |
|||
"license": "AGPL-3", |
|||
"depends": ["point_of_sale",], |
|||
"data": ["views/assets_backend.xml", "views/res_partner.xml",], |
|||
} |
@ -1,51 +1,55 @@ |
|||
odoo.define('pos_restricted_customer_list.point_of_sale.models', function (require) { |
|||
'use strict'; |
|||
odoo.define("pos_restricted_customer_list.point_of_sale.models", function(require) { |
|||
"use strict"; |
|||
|
|||
var Model = require('web.DataModel'); |
|||
var PosModels = require('point_of_sale.models'); |
|||
var Model = require("web.DataModel"); |
|||
var PosModels = require("point_of_sale.models"); |
|||
var PosModel = PosModels.PosModel; |
|||
var PosModelSuper = PosModel.prototype; |
|||
|
|||
PosModels.PosModel = PosModel.extend({ |
|||
initialize: function (session, attributes) { |
|||
initialize: function(session, attributes) { |
|||
var self = this; |
|||
for (var i = 0; i < self.models.length; i++) { |
|||
var model = self.models[i]; |
|||
var model_name = model.model; |
|||
|
|||
if (model_name === 'res.partner') { |
|||
if (model_name === "res.partner") { |
|||
model.domain = self.prepare_load_new_partners_domain(); |
|||
} |
|||
} |
|||
return PosModelSuper.initialize.call(self, session, attributes); |
|||
}, |
|||
prepare_load_new_partners_domain: function () { |
|||
prepare_load_new_partners_domain: function() { |
|||
return [ |
|||
['customer', '=', true], |
|||
['available_in_pos', '=', true], |
|||
["customer", "=", true], |
|||
["available_in_pos", "=", true], |
|||
]; |
|||
}, |
|||
load_new_partners: function () { |
|||
load_new_partners: function() { |
|||
var self = this; |
|||
var def = new $.Deferred(); |
|||
var fields = _.find(this.models, function (model) { |
|||
return model.model === 'res.partner'; |
|||
var fields = _.find(this.models, function(model) { |
|||
return model.model === "res.partner"; |
|||
}).fields; |
|||
var domain = self.prepare_load_new_partners_domain(); |
|||
new Model('res.partner') |
|||
new Model("res.partner") |
|||
.query(fields) |
|||
.filter(domain) |
|||
.all({'timeout': 3000, 'shadow': true}) |
|||
.then(function (partners) { |
|||
if (self.db.add_partners(partners)) { // check if the partners we got were real updates
|
|||
def.resolve(); |
|||
} else { |
|||
.all({timeout: 3000, shadow: true}) |
|||
.then( |
|||
function(partners) { |
|||
if (self.db.add_partners(partners)) { |
|||
// Check if the partners we got were real updates
|
|||
def.resolve(); |
|||
} else { |
|||
def.reject(); |
|||
} |
|||
}, |
|||
function(err, event) { |
|||
event.preventDefault(); |
|||
def.reject(); |
|||
} |
|||
}, function (err, event) { |
|||
event.preventDefault(); |
|||
def.reject(); |
|||
}); |
|||
); |
|||
return def; |
|||
}, |
|||
}); |
|||
|
@ -1,11 +1,17 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<?xml version="1.0" encoding="utf-8" ?> |
|||
<!-- Copyright 2017-2019 Therp BV <https://therp.nl> |
|||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> |
|||
|
|||
<odoo> |
|||
<template id="assets_backend" name="pos_restricted_customer_list assets" inherit_id="web.assets_backend"> |
|||
<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 |
|||
type="text/javascript" |
|||
src="/pos_restricted_customer_list/static/src/js/pos_restricted_customer_list.js" |
|||
> |
|||
</script> |
|||
</xpath> |
|||
</template> |
|||
|
@ -1,19 +1,16 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<?xml version="1.0" encoding="utf-8" ?> |
|||
<!-- Copyright 2017-2019 Therp BV <https://therp.nl> |
|||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> |
|||
|
|||
<odoo> |
|||
|
|||
<!--FORM view--> |
|||
<record id="view_partner_form" model="ir.ui.view"> |
|||
<field name="name">view.partner.form (in pos_restricted_customer_list)</field> |
|||
<field name="model">res.partner</field> |
|||
<field name="inherit_id" ref="point_of_sale.view_partner_property_form"/> |
|||
<field name="inherit_id" ref="point_of_sale.view_partner_property_form" /> |
|||
<field name="arch" type="xml"> |
|||
<field name="barcode" position="before"> |
|||
<field name="available_in_pos"/> |
|||
<field name="available_in_pos" /> |
|||
</field> |
|||
</field> |
|||
</record> |
|||
|
|||
</odoo> |
@ -0,0 +1,2 @@ |
|||
# addons listed in this file are ignored by |
|||
# setuptools-odoo-make-default (one addon per line) |
@ -0,0 +1,2 @@ |
|||
To learn more about this directory, please visit |
|||
https://pypi.python.org/pypi/setuptools-odoo |
@ -0,0 +1 @@ |
|||
__import__('pkg_resources').declare_namespace(__name__) |
@ -0,0 +1 @@ |
|||
../../../pos_restricted_customer_list |
@ -0,0 +1,6 @@ |
|||
import setuptools |
|||
|
|||
setuptools.setup( |
|||
setup_requires=['setuptools-odoo'], |
|||
odoo_addon=True, |
|||
) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue