[PoS] Merged the PosModel and Shop classes
bzr revid: fva@openerp.com-20120424172047-1wz31qi2hih3decs
This commit is contained in:
parent
bbbf338436
commit
e8e7304723
|
@ -62,7 +62,11 @@ function pos_models(module, instance){
|
||||||
'currency': {symbol: '$', position: 'after'},
|
'currency': {symbol: '$', position: 'after'},
|
||||||
'shop': {},
|
'shop': {},
|
||||||
'company': {},
|
'company': {},
|
||||||
'user': {}
|
'user': {},
|
||||||
|
'orders': new module.OrderCollection(),
|
||||||
|
'products': new module.ProductCollection(),
|
||||||
|
//'cashRegisters': [], // new module.CashRegisterCollection(this.pos.get('bank_statements')),
|
||||||
|
'selectedOrder': undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
var cat_def = fetch('pos.category', ['name', 'parent_id', 'child_id'])
|
var cat_def = fetch('pos.category', ['name', 'parent_id', 'child_id'])
|
||||||
|
@ -92,7 +96,23 @@ function pos_models(module, instance){
|
||||||
});
|
});
|
||||||
|
|
||||||
$.when(cat_def,prod_def,bank_def,tax_def,this.get_app_data(), this.flush())
|
$.when(cat_def,prod_def,bank_def,tax_def,this.get_app_data(), this.flush())
|
||||||
.pipe(_.bind(this.build_tree, this));
|
.pipe(_.bind(this.build_tree, this))
|
||||||
|
.pipe(function(){
|
||||||
|
self.set({'cashRegisters': new module.CashRegisterCollection(self.get('bank_statements')) });
|
||||||
|
self.ready.resolve();
|
||||||
|
});
|
||||||
|
|
||||||
|
return (this.get('orders')).bind('remove', _.bind( function(removedOrder) {
|
||||||
|
if ((this.get('orders')).isEmpty()) {
|
||||||
|
this.addAndSelectOrder(new module.Order({pos: self}));
|
||||||
|
}
|
||||||
|
if ((this.get('selectedOrder')) === removedOrder) {
|
||||||
|
return this.set({
|
||||||
|
selectedOrder: (this.get('orders')).last()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, this));
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
get_app_data: function() {
|
get_app_data: function() {
|
||||||
|
@ -119,6 +139,12 @@ function pos_models(module, instance){
|
||||||
return self.flush();
|
return self.flush();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
addAndSelectOrder: function(newOrder) {
|
||||||
|
(this.get('orders')).add(newOrder);
|
||||||
|
return this.set({
|
||||||
|
selectedOrder: newOrder
|
||||||
|
});
|
||||||
|
},
|
||||||
flush: function() {
|
flush: function() {
|
||||||
return this.flush_mutex.exec(_.bind(function() {
|
return this.flush_mutex.exec(_.bind(function() {
|
||||||
return this._int_flush();
|
return this._int_flush();
|
||||||
|
@ -197,7 +223,6 @@ function pos_models(module, instance){
|
||||||
return _results;
|
return _results;
|
||||||
}).call(this)
|
}).call(this)
|
||||||
};
|
};
|
||||||
return this.ready.resolve();
|
|
||||||
},
|
},
|
||||||
build_ancestors: function(parent) {
|
build_ancestors: function(parent) {
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
|
@ -217,6 +242,36 @@ function pos_models(module, instance){
|
||||||
return _results;
|
return _results;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
/*
|
||||||
|
module.Shop = Backbone.Model.extend({
|
||||||
|
initialize: function(attributes) {
|
||||||
|
var self = this;
|
||||||
|
this.set({
|
||||||
|
orders: new module.OrderCollection(),
|
||||||
|
products: new module.ProductCollection(),
|
||||||
|
});
|
||||||
|
this.pos = attributes.pos;
|
||||||
|
this.set({
|
||||||
|
cashRegisters: new module.CashRegisterCollection(this.pos.get('bank_statements')),
|
||||||
|
});
|
||||||
|
return (this.get('orders')).bind('remove', _.bind( function(removedOrder) {
|
||||||
|
if ((this.get('orders')).isEmpty()) {
|
||||||
|
this.addAndSelectOrder(new module.Order({pos: self.pos}));
|
||||||
|
}
|
||||||
|
if ((this.get('selectedOrder')) === removedOrder) {
|
||||||
|
return this.set({
|
||||||
|
selectedOrder: (this.get('orders')).last()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, this));
|
||||||
|
},
|
||||||
|
addAndSelectOrder: function(newOrder) {
|
||||||
|
(this.get('orders')).add(newOrder);
|
||||||
|
return this.set({
|
||||||
|
selectedOrder: newOrder
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});*/
|
||||||
|
|
||||||
module.CashRegister = Backbone.Model.extend({
|
module.CashRegister = Backbone.Model.extend({
|
||||||
});
|
});
|
||||||
|
@ -245,7 +300,7 @@ function pos_models(module, instance){
|
||||||
discount: 0
|
discount: 0
|
||||||
},
|
},
|
||||||
initialize: function(attributes) {
|
initialize: function(attributes) {
|
||||||
this.posmodel = attributes.posmodel;
|
this.pos = attributes.pos;
|
||||||
Backbone.Model.prototype.initialize.apply(this, arguments);
|
Backbone.Model.prototype.initialize.apply(this, arguments);
|
||||||
this.bind('change:quantity', function(unused, qty) {
|
this.bind('change:quantity', function(unused, qty) {
|
||||||
if (qty == 0)
|
if (qty == 0)
|
||||||
|
@ -272,10 +327,10 @@ function pos_models(module, instance){
|
||||||
var totalTax = base;
|
var totalTax = base;
|
||||||
var totalNoTax = base;
|
var totalNoTax = base;
|
||||||
|
|
||||||
var product_list = self.posmodel.get('product_list');
|
var product_list = self.pos.get('product_list');
|
||||||
var product = _.detect(product_list, function(el) {return el.id === self.get('id');});
|
var product = _.detect(product_list, function(el) {return el.id === self.get('id');});
|
||||||
var taxes_ids = product.taxes_id;
|
var taxes_ids = product.taxes_id;
|
||||||
var taxes = self.posmodel.get('taxes');
|
var taxes = self.pos.get('taxes');
|
||||||
var taxtotal = 0;
|
var taxtotal = 0;
|
||||||
_.each(taxes_ids, function(el) {
|
_.each(taxes_ids, function(el) {
|
||||||
var tax = _.detect(taxes, function(t) {return t.id === el;});
|
var tax = _.detect(taxes, function(t) {return t.id === el;});
|
||||||
|
@ -362,7 +417,7 @@ function pos_models(module, instance){
|
||||||
paymentLines: new module.PaymentlineCollection(),
|
paymentLines: new module.PaymentlineCollection(),
|
||||||
name: "Order " + this.generateUniqueId(),
|
name: "Order " + this.generateUniqueId(),
|
||||||
});
|
});
|
||||||
this.posmodel = attributes.posmodel; //TODO put that in set and remember to use 'get' to read it ...
|
this.pos = attributes.pos; //TODO put that in set and remember to use 'get' to read it ...
|
||||||
this.bind('change:validated', this.validatedChanged);
|
this.bind('change:validated', this.validatedChanged);
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
@ -384,7 +439,7 @@ function pos_models(module, instance){
|
||||||
existing.incrementQuantity();
|
existing.incrementQuantity();
|
||||||
} else {
|
} else {
|
||||||
var attr = product.toJSON();
|
var attr = product.toJSON();
|
||||||
attr.posmodel = this.posmodel;
|
attr.pos = this.pos;
|
||||||
var line = new module.Orderline(attr);
|
var line = new module.Orderline(attr);
|
||||||
this.get('orderLines').add(line);
|
this.get('orderLines').add(line);
|
||||||
line.bind('killme', function() {
|
line.bind('killme', function() {
|
||||||
|
@ -456,35 +511,6 @@ function pos_models(module, instance){
|
||||||
model: module.Order,
|
model: module.Order,
|
||||||
});
|
});
|
||||||
|
|
||||||
module.Shop = Backbone.Model.extend({
|
|
||||||
initialize: function(attributes) {
|
|
||||||
var self = this;
|
|
||||||
this.set({
|
|
||||||
orders: new module.OrderCollection(),
|
|
||||||
products: new module.ProductCollection(),
|
|
||||||
});
|
|
||||||
this.posmodel = attributes.posmodel;
|
|
||||||
this.set({
|
|
||||||
cashRegisters: new module.CashRegisterCollection(this.posmodel.get('bank_statements')),
|
|
||||||
});
|
|
||||||
return (this.get('orders')).bind('remove', _.bind( function(removedOrder) {
|
|
||||||
if ((this.get('orders')).isEmpty()) {
|
|
||||||
this.addAndSelectOrder(new module.Order({posmodel: self.posmodel}));
|
|
||||||
}
|
|
||||||
if ((this.get('selectedOrder')) === removedOrder) {
|
|
||||||
return this.set({
|
|
||||||
selectedOrder: (this.get('orders')).last()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, this));
|
|
||||||
},
|
|
||||||
addAndSelectOrder: function(newOrder) {
|
|
||||||
(this.get('orders')).add(newOrder);
|
|
||||||
return this.set({
|
|
||||||
selectedOrder: newOrder
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The numpad handles both the choice of the property currently being modified
|
The numpad handles both the choice of the property currently being modified
|
||||||
|
@ -553,29 +579,27 @@ function pos_models(module, instance){
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
namespace.App = (function() {
|
module.App = (function() {
|
||||||
|
|
||||||
function App($element, posmodel) {
|
function App($element, pos) {
|
||||||
this.initialize($element, posmodel);
|
this.initialize($element, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
App.prototype.initialize = function($element, posmodel) {
|
App.prototype.initialize = function($element, pos) {
|
||||||
this.posmodel = posmodel;
|
this.pos = pos;
|
||||||
this.shop = new namespace.Shop({'posmodel': posmodel});
|
this.shopView = new module.ShopWidget(null, {
|
||||||
this.shopView = new namespace.ShopWidget(null, {
|
'pos': pos,
|
||||||
shop: this.shop,
|
|
||||||
'posmodel': posmodel,
|
|
||||||
});
|
});
|
||||||
this.shopView.$element = $element;
|
this.shopView.$element = $element;
|
||||||
this.shopView.start();
|
this.shopView.start();
|
||||||
this.categoryView = new namespace.CategoryWidget(null, {element_id: 'products-screen-categories', posmodel: posmodel} );
|
this.categoryView = new module.CategoryWidget(null, {element_id: 'products-screen-categories', pos: pos} );
|
||||||
this.categoryView.on_change_category.add_last(_.bind(this.category, this));
|
this.categoryView.on_change_category.add_last(_.bind(this.category, this));
|
||||||
this.category();
|
this.category();
|
||||||
|
|
||||||
this.onscreenKeyboard = new namespace.OnscreenKeyboardWidget(null,{keyboard_model:'simple'});
|
this.onscreenKeyboard = new module.OnscreenKeyboardWidget(null,{keyboard_model:'simple'});
|
||||||
this.onscreenKeyboard.appendTo($(".point-of-sale #content"));
|
this.onscreenKeyboard.appendTo($(".point-of-sale #content"));
|
||||||
|
|
||||||
this.actionBar = new namespace.ActionbarWidget(null);
|
this.actionBar = new module.ActionbarWidget(null);
|
||||||
this.actionBar.appendTo($(".point-of-sale #content"));
|
this.actionBar.appendTo($(".point-of-sale #content"));
|
||||||
|
|
||||||
this.actionBar.addNewButton('left',{
|
this.actionBar.addNewButton('left',{
|
||||||
|
@ -665,21 +689,21 @@ function pos_models(module, instance){
|
||||||
|
|
||||||
id = !id ? 0 : id;
|
id = !id ? 0 : id;
|
||||||
|
|
||||||
c = this.posmodel.categories[id];
|
c = this.pos.categories[id];
|
||||||
this.categoryView.ancestors = c.ancestors;
|
this.categoryView.ancestors = c.ancestors;
|
||||||
this.categoryView.children = c.children;
|
this.categoryView.children = c.children;
|
||||||
this.categoryView.renderElement();
|
this.categoryView.renderElement();
|
||||||
this.categoryView.start();
|
this.categoryView.start();
|
||||||
|
|
||||||
allProducts = this.posmodel.get('product_list');
|
allProducts = this.pos.get('product_list');
|
||||||
|
|
||||||
allPackages = this.posmodel.get('product.packaging');
|
allPackages = this.pos.get('product.packaging');
|
||||||
|
|
||||||
product_list = this.posmodel.get('product_list').filter( function(p) {
|
product_list = this.pos.get('product_list').filter( function(p) {
|
||||||
var _ref;
|
var _ref;
|
||||||
return _ref = p.pos_categ_id[0], _.indexOf(c.subtree, _ref) >= 0;
|
return _ref = p.pos_categ_id[0], _.indexOf(c.subtree, _ref) >= 0;
|
||||||
});
|
});
|
||||||
(this.shop.get('products')).reset(product_list);
|
(this.pos.get('products')).reset(product_list);
|
||||||
|
|
||||||
var codeNumbers = [];
|
var codeNumbers = [];
|
||||||
|
|
||||||
|
@ -716,7 +740,7 @@ function pos_models(module, instance){
|
||||||
title: "Warning",
|
title: "Warning",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
var selectedOrder = self.shop.get('selectedOrder');
|
var selectedOrder = self.pos.get('selectedOrder');
|
||||||
var scannedProductModel = App.getProductByEAN(codeNumbers.join(''),allPackages,allProducts);
|
var scannedProductModel = App.getProductByEAN(codeNumbers.join(''),allPackages,allProducts);
|
||||||
if (scannedProductModel === undefined) {
|
if (scannedProductModel === undefined) {
|
||||||
// product not recognized, raise warning
|
// product not recognized, raise warning
|
||||||
|
@ -734,7 +758,7 @@ function pos_models(module, instance){
|
||||||
}*/
|
}*/
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
selectedOrder.addProduct(new namespace.Product(scannedProductModel));
|
selectedOrder.addProduct(new module.Product(scannedProductModel));
|
||||||
}
|
}
|
||||||
|
|
||||||
codeNumbers = [];
|
codeNumbers = [];
|
||||||
|
@ -757,10 +781,10 @@ function pos_models(module, instance){
|
||||||
m = product_list;
|
m = product_list;
|
||||||
$('.search-clear').fadeOut();
|
$('.search-clear').fadeOut();
|
||||||
}
|
}
|
||||||
return (self.shop.get('products')).reset(m);
|
return (self.pos.get('products')).reset(m);
|
||||||
});
|
});
|
||||||
return $('.search-clear').click( function() {
|
return $('.search-clear').click( function() {
|
||||||
(self.shop.get('products')).reset(product_list);
|
(self.pos.get('products')).reset(product_list);
|
||||||
$('.searchbox input').val('').focus();
|
$('.searchbox input').val('').focus();
|
||||||
return $('.search-clear').fadeOut();
|
return $('.search-clear').fadeOut();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
function pos_widgets(module, instance){
|
function pos_widgets(module, instance){
|
||||||
var QWeb = instance.web.qweb;
|
var QWeb = instance.web.qweb;
|
||||||
|
|
||||||
var qweb_template = function(template,posmodel){
|
var qweb_template = function(template,pos){
|
||||||
return function(ctx){
|
return function(ctx){
|
||||||
if(!posmodel){ //this is a huge hack that needs to be removed ... TODO
|
if(!pos){ //this is a huge hack that needs to be removed ... TODO
|
||||||
var HackPosModel = Backbone.Model.extend({
|
var HackPosModel = Backbone.Model.extend({
|
||||||
initialize:function(){
|
initialize:function(){
|
||||||
this.set({
|
this.set({
|
||||||
|
@ -11,15 +11,15 @@ function pos_widgets(module, instance){
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
posmodel = new HackPosModel();
|
pos = new HackPosModel();
|
||||||
}
|
}
|
||||||
return QWeb.render(template, _.extend({}, ctx,{
|
return QWeb.render(template, _.extend({}, ctx,{
|
||||||
'currency': posmodel.get('currency'),
|
'currency': pos.get('currency'),
|
||||||
'format_amount': function(amount) {
|
'format_amount': function(amount) {
|
||||||
if (posmodel.get('currency').position == 'after') {
|
if (pos.get('currency').position == 'after') {
|
||||||
return amount + ' ' + posmodel.get('currency').symbol;
|
return amount + ' ' + pos.get('currency').symbol;
|
||||||
} else {
|
} else {
|
||||||
return posmodel.get('currency').symbol + ' ' + amount;
|
return pos.get('currency').symbol + ' ' + amount;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
@ -66,28 +66,28 @@ function pos_widgets(module, instance){
|
||||||
module.PaypadWidget = instance.web.OldWidget.extend({
|
module.PaypadWidget = instance.web.OldWidget.extend({
|
||||||
init: function(parent, options) {
|
init: function(parent, options) {
|
||||||
this._super(parent);
|
this._super(parent);
|
||||||
this.shop = options.shop;
|
this.pos = options.pos;
|
||||||
},
|
},
|
||||||
start: function() {
|
start: function() {
|
||||||
this.$element.find('button').click(_.bind(this.performPayment, this));
|
this.$element.find('button').click(_.bind(this.performPayment, this));
|
||||||
},
|
},
|
||||||
performPayment: function(event) {
|
performPayment: function(event) {
|
||||||
if (this.shop.get('selectedOrder').get('step') === 'receipt')
|
if (this.pos.get('selectedOrder').get('step') === 'receipt')
|
||||||
return;
|
return;
|
||||||
var cashRegister, cashRegisterCollection, cashRegisterId;
|
var cashRegister, cashRegisterCollection, cashRegisterId;
|
||||||
/* set correct view */
|
/* set correct view */
|
||||||
this.shop.get('selectedOrder').set({'step': 'payment'});
|
this.pos.get('selectedOrder').set({'step': 'payment'});
|
||||||
|
|
||||||
cashRegisterId = event.currentTarget.attributes['cash-register-id'].nodeValue;
|
cashRegisterId = event.currentTarget.attributes['cash-register-id'].nodeValue;
|
||||||
cashRegisterCollection = this.shop.get('cashRegisters');
|
cashRegisterCollection = this.pos.get('cashRegisters');
|
||||||
cashRegister = cashRegisterCollection.find(_.bind( function(item) {
|
cashRegister = cashRegisterCollection.find(_.bind( function(item) {
|
||||||
return (item.get('id')) === parseInt(cashRegisterId, 10);
|
return (item.get('id')) === parseInt(cashRegisterId, 10);
|
||||||
}, this));
|
}, this));
|
||||||
return (this.shop.get('selectedOrder')).addPaymentLine(cashRegister);
|
return (this.pos.get('selectedOrder')).addPaymentLine(cashRegister);
|
||||||
},
|
},
|
||||||
renderElement: function() {
|
renderElement: function() {
|
||||||
this.$element.empty();
|
this.$element.empty();
|
||||||
return (this.shop.get('cashRegisters')).each(_.bind( function(cashRegister) {
|
return (this.pos.get('cashRegisters')).each(_.bind( function(cashRegister) {
|
||||||
var button = new module.PaymentButtonWidget();
|
var button = new module.PaymentButtonWidget();
|
||||||
button.model = cashRegister;
|
button.model = cashRegister;
|
||||||
button.appendTo(this.$element);
|
button.appendTo(this.$element);
|
||||||
|
@ -116,15 +116,15 @@ function pos_widgets(module, instance){
|
||||||
module.StepSwitcher = instance.web.OldWidget.extend({
|
module.StepSwitcher = instance.web.OldWidget.extend({
|
||||||
init: function(parent, options) {
|
init: function(parent, options) {
|
||||||
this._super(parent);
|
this._super(parent);
|
||||||
this.shop = options.shop;
|
this.pos = options.pos;
|
||||||
this.change_order();
|
this.change_order();
|
||||||
this.shop.bind('change:selectedOrder', this.change_order, this);
|
this.pos.bind('change:selectedOrder', this.change_order, this);
|
||||||
},
|
},
|
||||||
change_order: function() {
|
change_order: function() {
|
||||||
if (this.selected_order) {
|
if (this.selected_order) {
|
||||||
this.selected_order.unbind('change:step', this.change_step);
|
this.selected_order.unbind('change:step', this.change_step);
|
||||||
}
|
}
|
||||||
this.selected_order = this.shop.get('selectedOrder');
|
this.selected_order = this.pos.get('selectedOrder');
|
||||||
if (this.selected_order) {
|
if (this.selected_order) {
|
||||||
this.selected_order.bind('change:step', this.change_step, this);
|
this.selected_order.bind('change:step', this.change_step, this);
|
||||||
}
|
}
|
||||||
|
@ -183,9 +183,9 @@ function pos_widgets(module, instance){
|
||||||
module.OrderWidget = instance.web.OldWidget.extend({
|
module.OrderWidget = instance.web.OldWidget.extend({
|
||||||
init: function(parent, options) {
|
init: function(parent, options) {
|
||||||
this._super(parent);
|
this._super(parent);
|
||||||
this.shop = options.shop;
|
this.pos = options.pos;
|
||||||
this.setNumpadState(options.numpadState);
|
this.setNumpadState(options.numpadState);
|
||||||
this.shop.bind('change:selectedOrder', this.changeSelectedOrder, this);
|
this.pos.bind('change:selectedOrder', this.changeSelectedOrder, this);
|
||||||
this.bindOrderLineEvents();
|
this.bindOrderLineEvents();
|
||||||
},
|
},
|
||||||
setNumpadState: function(numpadState) {
|
setNumpadState: function(numpadState) {
|
||||||
|
@ -201,11 +201,11 @@ function pos_widgets(module, instance){
|
||||||
setValue: function(val) {
|
setValue: function(val) {
|
||||||
var param = {};
|
var param = {};
|
||||||
param[this.numpadState.get('mode')] = val;
|
param[this.numpadState.get('mode')] = val;
|
||||||
var order = this.shop.get('selectedOrder');
|
var order = this.pos.get('selectedOrder');
|
||||||
if (order.get('orderLines').length !== 0) {
|
if (order.get('orderLines').length !== 0) {
|
||||||
order.selected.set(param);
|
order.selected.set(param);
|
||||||
} else {
|
} else {
|
||||||
this.shop.get('selectedOrder').destroy();
|
this.pos.get('selectedOrder').destroy();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
changeSelectedOrder: function() {
|
changeSelectedOrder: function() {
|
||||||
|
@ -214,14 +214,14 @@ function pos_widgets(module, instance){
|
||||||
this.renderElement();
|
this.renderElement();
|
||||||
},
|
},
|
||||||
bindOrderLineEvents: function() {
|
bindOrderLineEvents: function() {
|
||||||
this.currentOrderLines = (this.shop.get('selectedOrder')).get('orderLines');
|
this.currentOrderLines = (this.pos.get('selectedOrder')).get('orderLines');
|
||||||
this.currentOrderLines.bind('add', this.addLine, this);
|
this.currentOrderLines.bind('add', this.addLine, this);
|
||||||
this.currentOrderLines.bind('remove', this.renderElement, this);
|
this.currentOrderLines.bind('remove', this.renderElement, this);
|
||||||
},
|
},
|
||||||
addLine: function(newLine) {
|
addLine: function(newLine) {
|
||||||
var line = new module.OrderlineWidget(null, {
|
var line = new module.OrderlineWidget(null, {
|
||||||
model: newLine,
|
model: newLine,
|
||||||
order: this.shop.get('selectedOrder')
|
order: this.pos.get('selectedOrder')
|
||||||
});
|
});
|
||||||
line.on_selected.add(_.bind(this.selectedLine, this));
|
line.on_selected.add(_.bind(this.selectedLine, this));
|
||||||
this.selectedLine();
|
this.selectedLine();
|
||||||
|
@ -230,10 +230,10 @@ function pos_widgets(module, instance){
|
||||||
},
|
},
|
||||||
selectedLine: function() {
|
selectedLine: function() {
|
||||||
var reset = false;
|
var reset = false;
|
||||||
if (this.currentSelected !== this.shop.get('selectedOrder').selected) {
|
if (this.currentSelected !== this.pos.get('selectedOrder').selected) {
|
||||||
reset = true;
|
reset = true;
|
||||||
}
|
}
|
||||||
this.currentSelected = this.shop.get('selectedOrder').selected;
|
this.currentSelected = this.pos.get('selectedOrder').selected;
|
||||||
if (reset && this.numpadState)
|
if (reset && this.numpadState)
|
||||||
this.numpadState.reset();
|
this.numpadState.reset();
|
||||||
this.updateSummary();
|
this.updateSummary();
|
||||||
|
@ -243,7 +243,7 @@ function pos_widgets(module, instance){
|
||||||
this.currentOrderLines.each(_.bind( function(orderLine) {
|
this.currentOrderLines.each(_.bind( function(orderLine) {
|
||||||
var line = new module.OrderlineWidget(null, {
|
var line = new module.OrderlineWidget(null, {
|
||||||
model: orderLine,
|
model: orderLine,
|
||||||
order: this.shop.get('selectedOrder')
|
order: this.pos.get('selectedOrder')
|
||||||
});
|
});
|
||||||
line.on_selected.add(_.bind(this.selectedLine, this));
|
line.on_selected.add(_.bind(this.selectedLine, this));
|
||||||
line.appendTo(this.$element);
|
line.appendTo(this.$element);
|
||||||
|
@ -252,7 +252,7 @@ function pos_widgets(module, instance){
|
||||||
},
|
},
|
||||||
updateSummary: function() {
|
updateSummary: function() {
|
||||||
var currentOrder, tax, total, totalTaxExcluded;
|
var currentOrder, tax, total, totalTaxExcluded;
|
||||||
currentOrder = this.shop.get('selectedOrder');
|
currentOrder = this.pos.get('selectedOrder');
|
||||||
total = currentOrder.getTotal();
|
total = currentOrder.getTotal();
|
||||||
totalTaxExcluded = currentOrder.getTotalTaxExcluded();
|
totalTaxExcluded = currentOrder.getTotalTaxExcluded();
|
||||||
tax = currentOrder.getTax();
|
tax = currentOrder.getTax();
|
||||||
|
@ -268,7 +268,7 @@ function pos_widgets(module, instance){
|
||||||
module.CategoryWidget = instance.web.OldWidget.extend({
|
module.CategoryWidget = instance.web.OldWidget.extend({
|
||||||
init: function(parent, options){
|
init: function(parent, options){
|
||||||
this._super(parent,options.element_id);
|
this._super(parent,options.element_id);
|
||||||
this.posmodel = options.posmodel;
|
this.pos = options.pos;
|
||||||
},
|
},
|
||||||
start: function() {
|
start: function() {
|
||||||
this.$element.find(".oe-pos-categories-list a").click(_.bind(this.changeCategory, this));
|
this.$element.find(".oe-pos-categories-list a").click(_.bind(this.changeCategory, this));
|
||||||
|
@ -283,7 +283,7 @@ function pos_widgets(module, instance){
|
||||||
_results = [];
|
_results = [];
|
||||||
for (_i = 0, _len = self.ancestors.length; _i < _len; _i++) {
|
for (_i = 0, _len = self.ancestors.length; _i < _len; _i++) {
|
||||||
c = self.ancestors[_i];
|
c = self.ancestors[_i];
|
||||||
_results.push(self.posmodel.categories[c]);
|
_results.push(self.pos.categories[c]);
|
||||||
}
|
}
|
||||||
return _results;
|
return _results;
|
||||||
})(),
|
})(),
|
||||||
|
@ -292,7 +292,7 @@ function pos_widgets(module, instance){
|
||||||
_results = [];
|
_results = [];
|
||||||
for (_i = 0, _len = self.children.length; _i < _len; _i++) {
|
for (_i = 0, _len = self.children.length; _i < _len; _i++) {
|
||||||
c = self.children[_i];
|
c = self.children[_i];
|
||||||
_results.push(self.posmodel.categories[c]);
|
_results.push(self.pos.categories[c]);
|
||||||
}
|
}
|
||||||
return _results;
|
return _results;
|
||||||
})()
|
})()
|
||||||
|
@ -311,7 +311,7 @@ function pos_widgets(module, instance){
|
||||||
init: function(parent, options) {
|
init: function(parent, options) {
|
||||||
this._super(parent);
|
this._super(parent);
|
||||||
this.model = options.model;
|
this.model = options.model;
|
||||||
this.shop = options.shop;
|
this.pos = options.pos;
|
||||||
},
|
},
|
||||||
start: function(options) {
|
start: function(options) {
|
||||||
$("a", this.$element).click(_.bind(this.addToOrder, this));
|
$("a", this.$element).click(_.bind(this.addToOrder, this));
|
||||||
|
@ -319,7 +319,7 @@ function pos_widgets(module, instance){
|
||||||
addToOrder: function(event) {
|
addToOrder: function(event) {
|
||||||
/* Preserve the category URL */
|
/* Preserve the category URL */
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return (this.shop.get('selectedOrder')).addProduct(this.model);
|
return (this.pos.get('selectedOrder')).addProduct(this.model);
|
||||||
},
|
},
|
||||||
renderElement: function() {
|
renderElement: function() {
|
||||||
this.$element.addClass("product");
|
this.$element.addClass("product");
|
||||||
|
@ -332,15 +332,15 @@ function pos_widgets(module, instance){
|
||||||
init: function(parent, options) {
|
init: function(parent, options) {
|
||||||
this._super(parent);
|
this._super(parent);
|
||||||
this.model = options.model;
|
this.model = options.model;
|
||||||
this.shop = options.shop;
|
this.pos = options.pos;
|
||||||
this.shop.get('products').bind('reset', this.renderElement, this);
|
this.pos.get('products').bind('reset', this.renderElement, this);
|
||||||
},
|
},
|
||||||
renderElement: function() {
|
renderElement: function() {
|
||||||
this.$element.empty();
|
this.$element.empty();
|
||||||
(this.shop.get('products')).each(_.bind( function(product) {
|
(this.pos.get('products')).each(_.bind( function(product) {
|
||||||
var p = new module.ProductWidget(null, {
|
var p = new module.ProductWidget(null, {
|
||||||
model: product,
|
model: product,
|
||||||
shop: this.shop
|
pos: this.pos
|
||||||
});
|
});
|
||||||
p.appendTo(this.$element);
|
p.appendTo(this.$element);
|
||||||
}, this));
|
}, this));
|
||||||
|
@ -389,9 +389,8 @@ function pos_widgets(module, instance){
|
||||||
init: function(parent, options) {
|
init: function(parent, options) {
|
||||||
this._super(parent);
|
this._super(parent);
|
||||||
this.model = options.model;
|
this.model = options.model;
|
||||||
this.shop = options.shop;
|
this.pos = options.pos;
|
||||||
this.posmodel = options.posmodel;
|
this.pos.bind('change:selectedOrder', this.changeSelectedOrder, this);
|
||||||
this.shop.bind('change:selectedOrder', this.changeSelectedOrder, this);
|
|
||||||
this.bindPaymentLineEvents();
|
this.bindPaymentLineEvents();
|
||||||
this.bindOrderLineEvents();
|
this.bindOrderLineEvents();
|
||||||
},
|
},
|
||||||
|
@ -403,13 +402,13 @@ function pos_widgets(module, instance){
|
||||||
$('.oe-back-to-products', this.$element).click(_.bind(this.back, this));
|
$('.oe-back-to-products', this.$element).click(_.bind(this.back, this));
|
||||||
},
|
},
|
||||||
back: function() {
|
back: function() {
|
||||||
this.shop.get('selectedOrder').set({"step": "products"});
|
this.pos.get('selectedOrder').set({"step": "products"});
|
||||||
},
|
},
|
||||||
validateCurrentOrder: function() {
|
validateCurrentOrder: function() {
|
||||||
var callback, currentOrder;
|
var callback, currentOrder;
|
||||||
currentOrder = this.shop.get('selectedOrder');
|
currentOrder = this.pos.get('selectedOrder');
|
||||||
$('button#validate-order', this.$element).attr('disabled', 'disabled');
|
$('button#validate-order', this.$element).attr('disabled', 'disabled');
|
||||||
this.posmodel.push_order(currentOrder.exportAsJSON()).then(_.bind(function() {
|
this.pos.push_order(currentOrder.exportAsJSON()).then(_.bind(function() {
|
||||||
$('button#validate-order', this.$element).removeAttr('disabled');
|
$('button#validate-order', this.$element).removeAttr('disabled');
|
||||||
return currentOrder.set({
|
return currentOrder.set({
|
||||||
validated: true
|
validated: true
|
||||||
|
@ -417,13 +416,13 @@ function pos_widgets(module, instance){
|
||||||
}, this));
|
}, this));
|
||||||
},
|
},
|
||||||
bindPaymentLineEvents: function() {
|
bindPaymentLineEvents: function() {
|
||||||
this.currentPaymentLines = (this.shop.get('selectedOrder')).get('paymentLines');
|
this.currentPaymentLines = (this.pos.get('selectedOrder')).get('paymentLines');
|
||||||
this.currentPaymentLines.bind('add', this.addPaymentLine, this);
|
this.currentPaymentLines.bind('add', this.addPaymentLine, this);
|
||||||
this.currentPaymentLines.bind('remove', this.renderElement, this);
|
this.currentPaymentLines.bind('remove', this.renderElement, this);
|
||||||
this.currentPaymentLines.bind('all', this.updatePaymentSummary, this);
|
this.currentPaymentLines.bind('all', this.updatePaymentSummary, this);
|
||||||
},
|
},
|
||||||
bindOrderLineEvents: function() {
|
bindOrderLineEvents: function() {
|
||||||
this.currentOrderLines = (this.shop.get('selectedOrder')).get('orderLines');
|
this.currentOrderLines = (this.pos.get('selectedOrder')).get('orderLines');
|
||||||
this.currentOrderLines.bind('all', this.updatePaymentSummary, this);
|
this.currentOrderLines.bind('all', this.updatePaymentSummary, this);
|
||||||
},
|
},
|
||||||
changeSelectedOrder: function() {
|
changeSelectedOrder: function() {
|
||||||
|
@ -452,7 +451,7 @@ function pos_widgets(module, instance){
|
||||||
},
|
},
|
||||||
updatePaymentSummary: function() {
|
updatePaymentSummary: function() {
|
||||||
var currentOrder, dueTotal, paidTotal, remaining, remainingAmount;
|
var currentOrder, dueTotal, paidTotal, remaining, remainingAmount;
|
||||||
currentOrder = this.shop.get('selectedOrder');
|
currentOrder = this.pos.get('selectedOrder');
|
||||||
paidTotal = currentOrder.getPaidTotal();
|
paidTotal = currentOrder.getPaidTotal();
|
||||||
dueTotal = currentOrder.getTotal();
|
dueTotal = currentOrder.getTotal();
|
||||||
this.$element.find('#payment-due-total').html(dueTotal.toFixed(2));
|
this.$element.find('#payment-due-total').html(dueTotal.toFixed(2));
|
||||||
|
@ -486,14 +485,14 @@ function pos_widgets(module, instance){
|
||||||
init: function(parent, options) {
|
init: function(parent, options) {
|
||||||
this._super(parent);
|
this._super(parent);
|
||||||
this.model = options.model;
|
this.model = options.model;
|
||||||
this.shop = options.shop;
|
this.pos = options.pos;
|
||||||
this.posmodel = options.posmodel;
|
this.pos = options.pos;
|
||||||
this.user = this.posmodel.get('user');
|
this.user = this.pos.get('user');
|
||||||
this.company = this.posmodel.get('company');
|
this.company = this.pos.get('company');
|
||||||
this.shop_obj = this.posmodel.get('shop');
|
this.shop_obj = this.pos.get('shop');
|
||||||
},
|
},
|
||||||
start: function() {
|
start: function() {
|
||||||
this.shop.bind('change:selectedOrder', this.changeSelectedOrder, this);
|
this.pos.bind('change:selectedOrder', this.changeSelectedOrder, this);
|
||||||
this.changeSelectedOrder();
|
this.changeSelectedOrder();
|
||||||
},
|
},
|
||||||
renderElement: function() {
|
renderElement: function() {
|
||||||
|
@ -505,23 +504,23 @@ function pos_widgets(module, instance){
|
||||||
window.print();
|
window.print();
|
||||||
},
|
},
|
||||||
finishOrder: function() {
|
finishOrder: function() {
|
||||||
this.shop.get('selectedOrder').destroy();
|
this.pos.get('selectedOrder').destroy();
|
||||||
},
|
},
|
||||||
changeSelectedOrder: function() {
|
changeSelectedOrder: function() {
|
||||||
if (this.currentOrderLines)
|
if (this.currentOrderLines)
|
||||||
this.currentOrderLines.unbind();
|
this.currentOrderLines.unbind();
|
||||||
this.currentOrderLines = (this.shop.get('selectedOrder')).get('orderLines');
|
this.currentOrderLines = (this.pos.get('selectedOrder')).get('orderLines');
|
||||||
this.currentOrderLines.bind('add', this.refresh, this);
|
this.currentOrderLines.bind('add', this.refresh, this);
|
||||||
this.currentOrderLines.bind('change', this.refresh, this);
|
this.currentOrderLines.bind('change', this.refresh, this);
|
||||||
this.currentOrderLines.bind('remove', this.refresh, this);
|
this.currentOrderLines.bind('remove', this.refresh, this);
|
||||||
if (this.currentPaymentLines)
|
if (this.currentPaymentLines)
|
||||||
this.currentPaymentLines.unbind();
|
this.currentPaymentLines.unbind();
|
||||||
this.currentPaymentLines = (this.shop.get('selectedOrder')).get('paymentLines');
|
this.currentPaymentLines = (this.pos.get('selectedOrder')).get('paymentLines');
|
||||||
this.currentPaymentLines.bind('all', this.refresh, this);
|
this.currentPaymentLines.bind('all', this.refresh, this);
|
||||||
this.refresh();
|
this.refresh();
|
||||||
},
|
},
|
||||||
refresh: function() {
|
refresh: function() {
|
||||||
this.currentOrder = this.shop.get('selectedOrder');
|
this.currentOrder = this.pos.get('selectedOrder');
|
||||||
$('.pos-receipt-container', this.$element).html(qweb_template('pos-ticket')({widget:this}));
|
$('.pos-receipt-container', this.$element).html(qweb_template('pos-ticket')({widget:this}));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -532,13 +531,13 @@ function pos_widgets(module, instance){
|
||||||
init: function(parent, options) {
|
init: function(parent, options) {
|
||||||
this._super(parent);
|
this._super(parent);
|
||||||
this.order = options.order;
|
this.order = options.order;
|
||||||
this.shop = options.shop;
|
this.pos = options.pos;
|
||||||
this.order.bind('destroy', _.bind( function() {
|
this.order.bind('destroy', _.bind( function() {
|
||||||
this.destroy();
|
this.destroy();
|
||||||
}, this));
|
}, this));
|
||||||
this.shop.bind('change:selectedOrder', _.bind( function(shop) {
|
this.pos.bind('change:selectedOrder', _.bind( function(pos) {
|
||||||
var selectedOrder;
|
var selectedOrder;
|
||||||
selectedOrder = shop.get('selectedOrder');
|
selectedOrder = pos.get('selectedOrder');
|
||||||
if (this.order === selectedOrder) {
|
if (this.order === selectedOrder) {
|
||||||
this.setButtonSelected();
|
this.setButtonSelected();
|
||||||
}
|
}
|
||||||
|
@ -549,7 +548,7 @@ function pos_widgets(module, instance){
|
||||||
$('button.close-order', this.$element).click(_.bind(this.closeOrder, this));
|
$('button.close-order', this.$element).click(_.bind(this.closeOrder, this));
|
||||||
},
|
},
|
||||||
selectOrder: function(event) {
|
selectOrder: function(event) {
|
||||||
this.shop.set({
|
this.pos.set({
|
||||||
selectedOrder: this.order
|
selectedOrder: this.order
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -830,22 +829,21 @@ function pos_widgets(module, instance){
|
||||||
module.ShopWidget = instance.web.OldWidget.extend({
|
module.ShopWidget = instance.web.OldWidget.extend({
|
||||||
init: function(parent, options) {
|
init: function(parent, options) {
|
||||||
this._super(parent);
|
this._super(parent);
|
||||||
this.shop = options.shop;
|
this.pos = options.pos;
|
||||||
this.posmodel = options.posmodel;
|
|
||||||
},
|
},
|
||||||
start: function() {
|
start: function() {
|
||||||
$('button#neworder-button', this.$element).click(_.bind(this.createNewOrder, this));
|
$('button#neworder-button', this.$element).click(_.bind(this.createNewOrder, this));
|
||||||
|
|
||||||
(this.shop.get('orders')).bind('add', this.orderAdded, this);
|
(this.pos.get('orders')).bind('add', this.orderAdded, this);
|
||||||
(this.shop.get('orders')).add(new module.Order({'posmodel':this.posmodel}));
|
(this.pos.get('orders')).add(new module.Order({'pos':this.pos}));
|
||||||
this.productListView = new module.ProductListWidget(null, {
|
this.productListView = new module.ProductListWidget(null, {
|
||||||
shop: this.shop
|
pos: this.pos,
|
||||||
});
|
});
|
||||||
this.productListView.$element = $("#products-screen-ol");
|
this.productListView.$element = $("#products-screen-ol");
|
||||||
this.productListView.renderElement();
|
this.productListView.renderElement();
|
||||||
this.productListView.start();
|
this.productListView.start();
|
||||||
this.paypadView = new module.PaypadWidget(null, {
|
this.paypadView = new module.PaypadWidget(null, {
|
||||||
shop: this.shop
|
pos: this.pos
|
||||||
});
|
});
|
||||||
this.paypadView.$element = $('#paypad');
|
this.paypadView.$element = $('#paypad');
|
||||||
this.paypadView.renderElement();
|
this.paypadView.renderElement();
|
||||||
|
@ -854,31 +852,29 @@ function pos_widgets(module, instance){
|
||||||
this.numpadView.$element = $('#numpad');
|
this.numpadView.$element = $('#numpad');
|
||||||
this.numpadView.start();
|
this.numpadView.start();
|
||||||
this.orderView = new module.OrderWidget(null, {
|
this.orderView = new module.OrderWidget(null, {
|
||||||
shop: this.shop,
|
pos: this.pos,
|
||||||
});
|
});
|
||||||
this.orderView.$element = $('#current-order-content');
|
this.orderView.$element = $('#current-order-content');
|
||||||
this.orderView.start();
|
this.orderView.start();
|
||||||
this.paymentView = new module.PaymentWidget(null, {
|
this.paymentView = new module.PaymentWidget(null, {
|
||||||
shop: this.shop,
|
pos: this.pos,
|
||||||
posmodel: this.posmodel,
|
|
||||||
});
|
});
|
||||||
this.paymentView.$element = $('#payment-screen');
|
this.paymentView.$element = $('#payment-screen');
|
||||||
this.paymentView.renderElement();
|
this.paymentView.renderElement();
|
||||||
this.paymentView.start();
|
this.paymentView.start();
|
||||||
this.receiptView = new module.ReceiptWidget(null, {
|
this.receiptView = new module.ReceiptWidget(null, {
|
||||||
shop: this.shop,
|
pos: this.pos,
|
||||||
posmodel: this.posmodel,
|
|
||||||
});
|
});
|
||||||
this.receiptView.replace($('#receipt-screen'));
|
this.receiptView.replace($('#receipt-screen'));
|
||||||
this.stepSwitcher = new module.StepSwitcher(this, {shop: this.shop});
|
this.stepSwitcher = new module.StepSwitcher(this, {pos: this.pos});
|
||||||
this.shop.bind('change:selectedOrder', this.changedSelectedOrder, this);
|
this.pos.bind('change:selectedOrder', this.changedSelectedOrder, this);
|
||||||
this.changedSelectedOrder();
|
this.changedSelectedOrder();
|
||||||
},
|
},
|
||||||
createNewOrder: function() {
|
createNewOrder: function() {
|
||||||
var newOrder;
|
var newOrder;
|
||||||
newOrder = new module.Order({'posmodel': this.posmodel});
|
newOrder = new module.Order({'pos': this.pos});
|
||||||
(this.shop.get('orders')).add(newOrder);
|
(this.pos.get('orders')).add(newOrder);
|
||||||
this.shop.set({
|
this.pos.set({
|
||||||
selectedOrder: newOrder
|
selectedOrder: newOrder
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -886,7 +882,7 @@ function pos_widgets(module, instance){
|
||||||
var newOrderButton;
|
var newOrderButton;
|
||||||
newOrderButton = new module.OrderButtonWidget(null, {
|
newOrderButton = new module.OrderButtonWidget(null, {
|
||||||
order: newOrder,
|
order: newOrder,
|
||||||
shop: this.shop
|
pos: this.pos
|
||||||
});
|
});
|
||||||
newOrderButton.appendTo($('#orders'));
|
newOrderButton.appendTo($('#orders'));
|
||||||
newOrderButton.selectOrder();
|
newOrderButton.selectOrder();
|
||||||
|
@ -895,7 +891,7 @@ function pos_widgets(module, instance){
|
||||||
if (this.currentOrder) {
|
if (this.currentOrder) {
|
||||||
this.currentOrder.unbind('change:step', this.changedStep);
|
this.currentOrder.unbind('change:step', this.changedStep);
|
||||||
}
|
}
|
||||||
this.currentOrder = this.shop.get('selectedOrder');
|
this.currentOrder = this.pos.get('selectedOrder');
|
||||||
this.currentOrder.bind('change:step', this.changedStep, this);
|
this.currentOrder.bind('change:step', this.changedStep, this);
|
||||||
this.changedStep();
|
this.changedStep();
|
||||||
},
|
},
|
||||||
|
@ -911,7 +907,7 @@ function pos_widgets(module, instance){
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
namespace.SynchNotification = instance.web.OldWidget.extend({
|
module.SynchNotification = instance.web.OldWidget.extend({
|
||||||
template: "pos-synch-notification",
|
template: "pos-synch-notification",
|
||||||
init: function() {
|
init: function() {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
|
@ -928,32 +924,32 @@ function pos_widgets(module, instance){
|
||||||
on_synch: function() {}
|
on_synch: function() {}
|
||||||
});
|
});
|
||||||
|
|
||||||
namespace.POSWidget = instance.web.OldWidget.extend({
|
module.POSWidget = instance.web.OldWidget.extend({
|
||||||
init: function() {
|
init: function() {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
|
|
||||||
this.posmodel = new namespace.PosModel(this.session);
|
this.pos = new module.PosModel(this.session);
|
||||||
|
|
||||||
},
|
},
|
||||||
start: function() {
|
start: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
return self.posmodel.ready.then(_.bind(function() {
|
return self.pos.ready.then(_.bind(function() {
|
||||||
this.renderElement();
|
this.renderElement();
|
||||||
this.synch_notification = new namespace.SynchNotification(this);
|
this.synch_notification = new module.SynchNotification(this);
|
||||||
this.synch_notification.replace($('.oe_pos_synch-notification', this.$element));
|
this.synch_notification.replace($('.oe_pos_synch-notification', this.$element));
|
||||||
this.synch_notification.on_synch.add(_.bind(self.posmodel.flush, self.posmodel));
|
this.synch_notification.on_synch.add(_.bind(self.pos.flush, self.pos));
|
||||||
|
|
||||||
self.posmodel.bind('change:nbr_pending_operations', this.changed_pending_operations, this);
|
self.pos.bind('change:nbr_pending_operations', this.changed_pending_operations, this);
|
||||||
this.changed_pending_operations();
|
this.changed_pending_operations();
|
||||||
|
|
||||||
this.$element.find("#loggedas button").click(function() {
|
this.$element.find("#loggedas button").click(function() {
|
||||||
self.try_close();
|
self.try_close();
|
||||||
});
|
});
|
||||||
|
|
||||||
self.posmodel.app = new namespace.App(self.$element, self.posmodel);
|
self.pos.app = new module.App(self.$element, self.pos);
|
||||||
instance.webclient.set_content_full_screen(true);
|
instance.webclient.set_content_full_screen(true);
|
||||||
|
|
||||||
if (self.posmodel.get('bank_statements').length === 0)
|
if (self.pos.get('bank_statements').length === 0)
|
||||||
return new instance.web.Model("ir.model.data").get_func("search_read")([['name', '=', 'action_pos_open_statement']], ['res_id']).pipe(
|
return new instance.web.Model("ir.model.data").get_func("search_read")([['name', '=', 'action_pos_open_statement']], ['res_id']).pipe(
|
||||||
_.bind(function(res) {
|
_.bind(function(res) {
|
||||||
return this.rpc('/web/action/load', {'action_id': res[0]['res_id']}).pipe(_.bind(function(result) {
|
return this.rpc('/web/action/load', {'action_id': res[0]['res_id']}).pipe(_.bind(function(result) {
|
||||||
|
@ -968,13 +964,13 @@ function pos_widgets(module, instance){
|
||||||
},
|
},
|
||||||
changed_pending_operations: function () {
|
changed_pending_operations: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.synch_notification.on_change_nbr_pending(self.posmodel.get('nbr_pending_operations').length);
|
this.synch_notification.on_change_nbr_pending(self.pos.get('nbr_pending_operations').length);
|
||||||
},
|
},
|
||||||
try_close: function() {
|
try_close: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
self.posmodel.flush().then(_.bind(function() {
|
self.pos.flush().then(_.bind(function() {
|
||||||
var close = _.bind(this.close, this);
|
var close = _.bind(this.close, this);
|
||||||
if (self.posmodel.get('nbr_pending_operations').length > 0) {
|
if (self.pos.get('nbr_pending_operations').length > 0) {
|
||||||
var confirm = false;
|
var confirm = false;
|
||||||
$(QWeb.render('pos-close-warning')).dialog({
|
$(QWeb.render('pos-close-warning')).dialog({
|
||||||
resizable: false,
|
resizable: false,
|
||||||
|
@ -1015,7 +1011,7 @@ function pos_widgets(module, instance){
|
||||||
},
|
},
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
instance.webclient.set_content_full_screen(false);
|
instance.webclient.set_content_full_screen(false);
|
||||||
self.posmodel = undefined;
|
self.pos = undefined;
|
||||||
this._super();
|
this._super();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue