[WIP] point_of_sale: removing useless backbone models & making browser print work again

bzr revid: fva@openerp.com-20131216143559-6unghp0sza9ihs4r
This commit is contained in:
Frédéric van der Essen
2013-12-16 15:35:59 +01:00
parent 86bb946087
commit f8777d18db
7 changed files with 134 additions and 206 deletions
+19 -7
View File
@@ -589,6 +589,7 @@ td {
.pos .category-button .category-img img {
max-height: 100px;
max-width: 120px;
vertical-align: middle;
}
.pos .category-button .category-name {
@@ -640,6 +641,7 @@ td {
.pos .product .product-img img {
max-height: 100px;
max-width: 120px;
vertical-align: middle;
}
.pos .product .price-tag {
@@ -862,15 +864,25 @@ td {
}
@media print {
<<<<<<< TREE
.pos{
background: white !important;
}
.pos .pos-topheader, .pos .pos-leftpane {
.oe_leftbar,
.pos .pos-topheader,
.pos .pos-leftpane,
.pos .keyboard_frame {
display: none !important;
}
.pos .pos-content {
top: 0px !important;
.pos,
.pos .pos-content,
.pos .rightpane,
.pos .screen,
.pos .window,
.pos .window .subwindow,
.pos .subwindow .subwindow-container{
display: block;
position: static;
height: auto;
}
.pos{
background: white !important;
}
.pos .rightpane {
left: 0px !important;
+6 -30
View File
@@ -1,36 +1,12 @@
function openerp_pos_db(instance, module){
/* The db module was intended to be used to store all the data needed to run the Point
* of Sale in offline mode. (Products, Categories, Orders, ...) It would also use WebSQL
* or IndexedDB to make the searching and sorting products faster. It turned out not to be
* a so good idea after all.
*
* First it is difficult to make the Point of Sale truly independant of the server. A lot
* of functionality cannot realistically run offline, like generating invoices.
*
* IndexedDB turned out to be complicated and slow as hell, and loading all the data at the
* start made the point of sale take forever to load over small connections.
*
* LocalStorage has a hard 5.0MB on chrome. For those kind of sizes, it is just better
* to put the data in memory and it's not too big to download each time you launch the PoS.
*
* So at this point we are dropping the support for offline mode, and this module doesn't really
* make sense anymore. But if at some point you want to store millions of products and if at
* that point indexedDB has improved to the point it is usable, you can just implement this API.
*
* You would also need to change the way the models are loaded at the start to not reload all your
* product data.
*/
/* PosLS is a localstorage based implementation of the point of sale database.
* FIXME: The Products definitions and categories are stored on the locastorage even tough they're
* always reloaded at launch. This could induce a slowdown because the data needs to be reparsed from
* JSON before each operation. If you have a huge amount of products (around 25000) it can also
* blow the 5.0MB localstorage limit.
/* The PosDB holds reference to data that is either
* - static: does not change between pos reloads
* - persistent : must stay between reloads ( orders )
*/
module.PosLS = instance.web.Class.extend({
name: 'openerp_pos_ls', //the prefix of the localstorage data
module.PosDB = instance.web.Class.extend({
name: 'openerp_pos_db', //the prefix of the localstorage data
limit: 100, // the maximum number of results returned by a search
init: function(options){
options = options || {};
@@ -132,7 +108,7 @@ function openerp_pos_db(instance, module){
return this.cache[store];
}
var data = localStorage[this.name + '_' + store];
if(data !== undefined){
if(data !== undefined && data !== ""){
data = JSON.parse(data);
this.cache[store] = data;
return data;
+73 -124
View File
@@ -19,40 +19,35 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
Backbone.Model.prototype.initialize.call(this, attributes);
var self = this;
this.session = session;
this.ready = $.Deferred(); // used to notify the GUI that the PosModel has loaded all resources
this.flush_mutex = new $.Mutex(); // used to make sure the orders are sent to the server once at time
this.barcode_reader = new module.BarcodeReader({'pos': this}); // used to read barcodes
this.proxy = new module.ProxyDevice(); // used to communicate to the hardware devices via a local proxy
this.proxy_queue = new module.JobQueue(); // used to prevent parallels communications to the proxy
this.db = new module.PosLS(); // a database used to store the products and categories
this.db.clear('products','categories');
this.proxy_queue = new module.JobQueue(); // used to prevent parallels communications to the proxy
this.db = new module.PosDB(); // a local database used to search trough products and categories & store pending orders
this.debug = jQuery.deparam(jQuery.param.querystring()).debug !== undefined; //debug mode
// Business data; loaded from the server at launch
this.currency = null;
this.shop = null;
this.company = null;
this.user = null;
this.users = [];
this.partners = [];
this.cashier = null;
this.cashregisters = [];
this.bankstatements = [];
this.taxes = [];
this.pos_session = null;
this.config = null;
this.units = [];
this.units_by_id = {};
this.pricelist = null;
// default attributes values. If null, it will be loaded below.
// these dynamic attributes can be watched for change by other models or widgets
this.set({
'nbr_pending_operations': 0,
'currency': {symbol: '$', position: 'after'},
'shop': null,
'company': null,
'user': null, // the user that loaded the pos
'user_list': null, // list of all users
'partner_list': null, // list of all partners with an ean
'cashier': null, // the logged cashier, if different from user
'orders': new module.OrderCollection(),
//this is the product list as seen by the product list widgets, it will change based on the category filters
'cashRegisters': null,
'bank_statements': null,
'taxes': null,
'pos_session': null,
'pos_config': null,
'units': null,
'units_by_id': null,
'pricelist': null,
'selectedOrder': null,
});
@@ -63,15 +58,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
// We fetch the backend data on the server asynchronously. this is done only when the pos user interface is launched,
// Any change on this data made on the server is thus not reflected on the point of sale until it is relaunched.
// when all the data has loaded, we compute some stuff, and declare the Pos ready to be used.
$.when(this.load_server_data())
.done(function(){
//self.log_loaded_data(); //Uncomment if you want to log the data to the console for easier debugging
self.ready.resolve();
}).fail(function(){
//we failed to load some backend data, or the backend was badly configured.
//the error messages will be displayed in PosWidget
self.ready.reject();
});
this.ready = this.load_server_data();
},
// releases ressources holds by the model at the end of life of the posmodel
@@ -92,7 +79,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
var loaded = self.fetch('res.users',['name','company_id'],[['id','=',this.session.uid]])
.then(function(users){
self.set('user',users[0]);
self.user = users[0];
return self.fetch('res.company',
[
@@ -107,44 +94,40 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
],
[['id','=',users[0].company_id[0]]]);
}).then(function(companies){
self.set('company',companies[0]);
self.company = companies[0];
return self.fetch('res.partner',['contact_address'],[['id','=',companies[0].partner_id[0]]]);
}).then(function(company_partners){
self.get('company').contact_address = company_partners[0].contact_address;
self.company.contact_address = company_partners[0].contact_address;
return self.fetch('product.uom', null, null);
}).then(function(units){
self.set('units',units);
self.units = units;
var units_by_id = {};
for(var i = 0, len = units.length; i < len; i++){
units_by_id[units[i].id] = units[i];
}
self.set('units_by_id',units_by_id);
return self.fetch('product.packaging', null, null);
}).then(function(packagings){
self.set('product.packaging',packagings);
self.units_by_id = units_by_id;
return self.fetch('res.users', ['name','ean13'], [['ean13', '!=', false]]);
}).then(function(users){
self.set('user_list',users);
self.users = users;
return self.fetch('res.partner', ['name','ean13'], [['ean13', '!=', false]]);
}).then(function(partners){
self.set('partner_list',partners);
self.partners = partners;
return self.fetch('account.tax', ['amount', 'price_include', 'type']);
}).then(function(taxes){
self.set('taxes', taxes);
self.taxes = taxes;
return self.fetch(
'pos.session',
['id', 'journal_ids','name','user_id','config_id','start_at','stop_at'],
[['state', '=', 'opened'], ['user_id', '=', self.session.uid]]
);
}).then(function(sessions){
self.set('pos_session', sessions[0]);
}).then(function(pos_sessions){
self.pos_session = pos_sessions[0];
return self.fetch(
'pos.config',
@@ -153,30 +136,22 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
'iface_payment_terminal', 'iface_electronic_scale', 'iface_barscan', 'iface_vkeyboard',
'iface_print_via_proxy','iface_cashdrawer','iface_invoicing','iface_big_scrollbars',
'state','sequence_id','session_ids'],
[['id','=', self.get('pos_session').config_id[0]]]
[['id','=', self.pos_session.config_id[0]]]
);
}).then(function(configs){
var pos_config = configs[0];
self.set('pos_config', pos_config);
self.iface_electronic_scale = !!pos_config.iface_electronic_scale;
self.iface_print_via_proxy = !!pos_config.iface_print_via_proxy;
self.iface_vkeyboard = !!pos_config.iface_vkeyboard;
self.iface_self_checkout = !!pos_config.iface_self_checkout;
self.iface_cashdrawer = !!pos_config.iface_cashdrawer;
self.iface_invoicing = !!pos_config.iface_invoicing;
self.iface_big_scrollbars = !!pos_config.iface_big_scrollbars;
self.config = configs[0];
return self.fetch('stock.warehouse',[],[['id','=',pos_config.warehouse_id[0]]]);
return self.fetch('stock.warehouse',[],[['id','=', self.config.warehouse_id[0]]]);
}).then(function(shops){
self.set('shop',shops[0]);
self.shop = shops[0];
return self.fetch('product.pricelist',['currency_id'],[['id','=',self.get('pos_config').pricelist_id[0]]]);
return self.fetch('product.pricelist',['currency_id'],[['id','=',self.config.pricelist_id[0]]]);
}).then(function(pricelists){
self.set('pricelist',pricelists[0]);
self.pricelist = pricelists[0];
return self.fetch('res.currency',['symbol','position','rounding','accuracy'],[['id','=',self.get('pricelist').currency_id[0]]]);
return self.fetch('res.currency',['symbol','position','rounding','accuracy'],[['id','=',self.pricelist.currency_id[0]]]);
}).then(function(currencies){
self.set('currency',currencies[0]);
self.currency = currencies[0];
return self.fetch('product.packaging',['ean','product_id']);
}).then(function(packagings){
@@ -191,7 +166,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
['name', 'list_price','price','pos_categ_id', 'taxes_id', 'ean13', 'default_code',
'to_weight', 'uom_id', 'uos_id', 'uos_coeff', 'mes_type', 'description_sale', 'description'],
[['sale_ok','=',true],['available_in_pos','=',true]],
{pricelist: self.get('pricelist').id} // context for price
{pricelist: self.pricelist.id} // context for price
);
}).then(function(products){
self.db.add_products(products);
@@ -199,53 +174,35 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
return self.fetch(
'account.bank.statement',
['account_id','currency','journal_id','state','name','user_id','pos_session_id'],
[['state','=','open'],['pos_session_id', '=', self.get('pos_session').id]]
[['state','=','open'],['pos_session_id', '=', self.pos_session.id]]
);
}).then(function(bank_statements){
var journals = new Array();
_.each(bank_statements,function(statement) {
}).then(function(bankstatements){
var journals = [];
_.each(bankstatements,function(statement) {
journals.push(statement.journal_id[0])
});
self.set('bank_statements', bank_statements);
self.bankstatements = bankstatements;
return self.fetch('account.journal', undefined, [['id','in', journals]]);
}).then(function(journals){
self.set('journals',journals);
self.journals = journals;
// associate the bank statements with their journals.
var bank_statements = self.get('bank_statements');
for(var i = 0, ilen = bank_statements.length; i < ilen; i++){
var bankstatements = self.bankstatements
for(var i = 0, ilen = bankstatements.length; i < ilen; i++){
for(var j = 0, jlen = journals.length; j < jlen; j++){
if(bank_statements[i].journal_id[0] === journals[j].id){
bank_statements[i].journal = journals[j];
bank_statements[i].self_checkout_payment_method = journals[j].self_checkout_payment_method;
if(bankstatements[i].journal_id[0] === journals[j].id){
bankstatements[i].journal = journals[j];
bankstatements[i].self_checkout_payment_method = journals[j].self_checkout_payment_method;
}
}
}
self.set({'cashRegisters' : new module.CashRegisterCollection(self.get('bank_statements'))});
self.cashregisters = bankstatements;
console.log('cashregisters',self.cashregisters);
});
return loaded;
},
// logs the usefull posmodel data to the console for debug purposes
log_loaded_data: function(){
console.log('PosModel data has been loaded:');
console.log('PosModel: units:',this.get('units'));
console.log('PosModel: bank_statements:',this.get('bank_statements'));
console.log('PosModel: journals:',this.get('journals'));
console.log('PosModel: taxes:',this.get('taxes'));
console.log('PosModel: pos_session:',this.get('pos_session'));
console.log('PosModel: pos_config:',this.get('pos_config'));
console.log('PosModel: cashRegisters:',this.get('cashRegisters'));
console.log('PosModel: shop:',this.get('shop'));
console.log('PosModel: company:',this.get('company'));
console.log('PosModel: currency:',this.get('currency'));
console.log('PosModel: user_list:',this.get('user_list'));
console.log('PosModel: user:',this.get('user'));
console.log('PosModel.session:',this.session);
console.log('PosModel end of data log.');
},
// this is called when an order is removed from the order collection. It ensures that there is always an existing
// order and a valid selected order
on_removed_order: function(removed_order,index,reason){
@@ -453,13 +410,6 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
},
});
module.CashRegister = Backbone.Model.extend({
});
module.CashRegisterCollection = Backbone.Collection.extend({
model: module.CashRegister,
});
// An orderline represent one element of the content of a client's shopping cart.
// An orderline contains a product, its quantity, its price, discount. etc.
// An Order contains zero or more Orderlines.
@@ -538,7 +488,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
if(!this.pos){
return undefined;
}
return this.pos.get('units_by_id')[unit_id];
return this.pos.units_by_id[unit_id];
},
// return the product of this orderline
get_product: function(){
@@ -601,11 +551,11 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
this.trigger('change',this);
},
get_unit_price: function(){
var rounding = this.pos.get('currency').rounding;
var rounding = this.pos.currency.rounding;
return round_pr(this.price,rounding);
},
get_display_price: function(){
var rounding = this.pos.get('currency').rounding;
var rounding = this.pos.currency.rounding;
return round_pr(round_pr(this.get_unit_price() * this.get_quantity(),rounding) * (1- this.get_discount()/100.0),rounding);
},
get_price_without_tax: function(){
@@ -619,12 +569,11 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
},
get_all_prices: function(){
var self = this;
var currency_rounding = this.pos.get('currency').rounding;
var currency_rounding = this.pos.currency.rounding;
var base = round_pr(this.get_quantity() * this.get_unit_price() * (1.0 - (this.get_discount() / 100.0)), currency_rounding);
var totalTax = base;
var totalNoTax = base;
var product_list = this.pos.get('product_list');
var product = this.get_product();
var taxes_ids = product.taxes_id;
var taxes = self.pos.taxes;
@@ -673,8 +622,8 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
module.Paymentline = Backbone.Model.extend({
initialize: function(attributes, options) {
this.amount = 0;
this.cashregister = options.cashRegister;
this.name = this.cashregister.get('journal_id')[1];
this.cashregister = options.cashregister;
this.name = this.cashregister.journal_id[1];
this.selected = false;
},
//sets the amount of money on this payment line
@@ -692,14 +641,14 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
this.trigger('change:selected',this);
}
},
// returns the associated cashRegister
// returns the associated cashregister
//exports as JSON for server communication
export_as_JSON: function(){
return {
name: instance.web.datetime_to_str(new Date()),
statement_id: this.cashregister.get('id'),
account_id: (this.cashregister.get('account_id'))[0],
journal_id: (this.cashregister.get('journal_id'))[0],
statement_id: this.cashregister.id,
account_id: this.cashregister.account_id[0],
journal_id: this.cashregister.journal_id[0],
amount: this.get_amount()
};
},
@@ -707,7 +656,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
export_for_printing: function(){
return {
amount: this.get_amount(),
journal: this.cashregister.get('journal_id')[1],
journal: this.cashregister.journal_id[1],
};
},
});
@@ -771,10 +720,10 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
getLastOrderline: function(){
return this.get('orderLines').at(this.get('orderLines').length -1);
},
addPaymentline: function(cashRegister) {
addPaymentline: function(cashregister) {
var paymentLines = this.get('paymentLines');
var newPaymentline = new module.Paymentline({},{cashRegister:cashRegister});
if(cashRegister.get('journal').type !== 'cash'){
var newPaymentline = new module.Paymentline({},{cashregister:cashregister});
if(cashregister.journal.type !== 'cash'){
newPaymentline.set_amount( Math.max(this.getDueLeft(),0) );
}
paymentLines.add(newPaymentline);
@@ -872,9 +821,9 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
paymentlines.push(paymentline.export_for_printing());
});
var client = this.get('client');
var cashier = this.pos.get('cashier') || this.pos.get('user');
var company = this.pos.get('company');
var shop = this.pos.get('shop');
var cashier = this.pos.cashier || this.pos.user;
var company = this.pos.company;
var shop = this.pos.shop;
var date = new Date();
return {
@@ -911,7 +860,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
shop:{
name: shop.name,
},
currency: this.pos.get('currency'),
currency: this.pos.currency,
};
},
export_as_JSON: function() {
@@ -932,9 +881,9 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
amount_return: this.getChange(),
lines: orderLines,
statement_ids: paymentLines,
pos_session_id: this.pos.get('pos_session').id,
pos_session_id: this.pos.pos_session.id,
partner_id: this.get_client() ? this.get_client().id : false,
user_id: this.pos.get('cashier') ? this.pos.get('cashier').id : this.pos.get('user').id,
user_id: this.pos.cashier ? this.pos.cashier.id : this.pos.user.id,
uid: this.uid,
};
},
+15 -25
View File
@@ -182,10 +182,10 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
// - if there's a user with a matching ean, put it as the active 'cashier', go to cashier mode, and return true
// - else : do nothing and return false. You probably want to extend this to show and appropriate error popup...
barcode_cashier_action: function(code){
var users = this.pos.get('user_list');
var users = this.pos.users;
for(var i = 0, len = users.length; i < len; i++){
if(users[i].ean13 === code.code){
this.pos.set('cashier',users[i]);
this.pos.cashier = users[i];
this.pos_widget.username.refresh();
this.pos.proxy.cashier_mode_activated();
this.pos_widget.screen_selector.set_user_mode('cashier');
@@ -201,7 +201,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
// - if there's a user with a matching ean, put it as the active 'client' and return true
// - else : return false.
barcode_client_action: function(code){
var partners = this.pos.get('partner_list');
var partners = this.pos.partners;
for(var i = 0, len = partners.length; i < len; i++){
if(partners[i].ean13 === code.code){
this.pos.get('selectedOrder').set_client(partners[i]);
@@ -278,7 +278,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
this.pos_widget.set_left_action_bar_visible(this.show_leftpane && !this.cashier_mode);
this.pos_widget.set_cashier_controls_visible(this.cashier_mode);
if(this.cashier_mode && this.pos.iface_self_checkout){
if(this.cashier_mode && this.pos.config.iface_self_checkout){
this.pos_widget.client_button.show();
}else{
this.pos_widget.client_button.hide();
@@ -557,11 +557,11 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
},
get_product_name: function(){
var product = this.get_product();
return (product ? product.get('name') : undefined) || 'Unnamed Product';
return (product ? product.name : undefined) || 'Unnamed Product';
},
get_product_price: function(){
var product = this.get_product();
return (product ? product.get('price') : 0) || 0;
return (product ? product.price : 0) || 0;
},
set_weight: function(weight){
this.weight = weight;
@@ -628,14 +628,14 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
//we get the first cashregister marked as self-checkout
var selfCheckoutRegisters = [];
for(var i = 0; i < self.pos.get('cashRegisters').models.length; i++){
var cashregister = self.pos.get('cashRegisters').models[i];
for(var i = 0; i < self.pos.cashregisters.length; i++){
var cashregister = self.pos.cashregisters[i];
if(cashregister.self_checkout_payment_method){
selfCheckoutRegisters.push(cashregister);
}
}
var cashregister = selfCheckoutRegisters[0] || self.pos.get('cashRegisters').models[0];
var cashregister = selfCheckoutRegisters[0] || self.pos.cashregisters[0];
currentOrder.addPaymentline(cashregister);
self.pos.push_order(currentOrder)
currentOrder.destroy();
@@ -750,7 +750,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
this.product_list_widget = new module.ProductListWidget(this,{
click_product_action: function(product){
if(product.to_weight && self.pos.iface_electronic_scale){
if(product.to_weight && self.pos.config.iface_electronic_scale){
self.pos_widget.screen_selector.set_current_screen( self.cashier_mode ? self.scale_screen : self.client_scale_screen, {product: product});
}else{
self.pos.get('selectedOrder').addProduct(product);
@@ -790,7 +790,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
this.pos_widget.order_widget.set_editable(false);
if(this.pos.iface_vkeyboard && this.pos_widget.onscreen_keyboard){
if(this.pos.config.iface_vkeyboard && this.pos_widget.onscreen_keyboard){
this.pos_widget.onscreen_keyboard.hide();
}
},
@@ -802,15 +802,6 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
show_numpad: true,
show_leftpane: true,
init: function(parent, options) {
this._super(parent,options);
this.user = this.pos.get('user');
this.company = this.pos.get('company');
this.shop_obj = this.pos.get('shop');
},
renderElement: function() {
this._super();
},
show: function(){
this._super();
var self = this;
@@ -830,7 +821,6 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
this.refresh();
this.print();
// THIS IS THE HACK OF THE CENTURY
//
// The problem is that in chrome the print() is asynchronous and doesn't
// execute until all rpc are finished. So it conflicts with the rpc used
@@ -938,7 +928,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
document.body.addEventListener('keyup', this.hotkey_handler);
if( this.pos.iface_cashdrawer
if( this.pos.config.iface_cashdrawer
&& this.pos.get('selectedOrder').get('paymentLines').find( function(pl){
return pl.cashregister.get('journal').type === 'cash';
})){
@@ -963,7 +953,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
},
});
if( this.pos.iface_invoicing ){
if( this.pos.config.iface_invoicing ){
this.add_action_button({
label: 'Invoice',
name: 'invoice',
@@ -974,7 +964,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
});
}
if( this.pos.iface_cashdrawer ){
if( this.pos.config.iface_cashdrawer ){
this.add_action_button({
label: _t('Cash'),
name: 'cashbox',
@@ -1172,7 +1162,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
}else{
this.pos.push_order(currentOrder)
if(this.pos.iface_print_via_proxy){
if(this.pos.config.iface_print_via_proxy){
this.pos.proxy.print_receipt(currentOrder.export_for_printing());
this.pos.get('selectedOrder').destroy(); //finish order and go back to scan screen
}else{
@@ -19,8 +19,8 @@ function openerp_pos_basewidget(instance, module){ //module is instance.point_of
},
build_currency_template: function(){
if(this.pos && this.pos.get('currency')){
this.currency = this.pos.get('currency');
if(this.pos && this.pos.currency){
this.currency = this.pos.currency;
}else{
this.currency = {symbol: '$', position: 'after', rounding: 0.01};
}
+13 -12
View File
@@ -91,7 +91,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
},
});
// The paypad allows to select the payment method (cashRegisters)
// The paypad allows to select the payment method (cashregisters)
// used to pay the order.
module.PaypadWidget = module.PosBaseWidget.extend({
template: 'PaypadWidget',
@@ -99,11 +99,11 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
var self = this;
this._super();
this.pos.get('cashRegisters').each(function(cashRegister) {
_.each(this.pos.cashregisters,function(cashregister) {
var button = new module.PaypadButtonWidget(self,{
pos: self.pos,
pos_widget : self.pos_widget,
cashRegister: cashRegister,
cashregister: cashregister,
});
button.appendTo(self.$el);
});
@@ -114,7 +114,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
template: 'PaypadButtonWidget',
init: function(parent, options){
this._super(parent, options);
this.cashRegister = options.cashRegister;
this.cashregister = options.cashregister;
},
renderElement: function() {
var self = this;
@@ -125,7 +125,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
console.warn('TODO should not get there...?');
return;
}
self.pos.get('selectedOrder').addPaymentline(self.cashRegister);
self.pos.get('selectedOrder').addPaymentline(self.cashregister);
self.pos_widget.screen_selector.set_current_screen('payment');
});
},
@@ -523,7 +523,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
this.el.querySelector('.search-clear').addEventListener('click',this.clear_search_handler);
if(this.pos.iface_vkeyboard && this.pos_widget.onscreen_keyboard){
if(this.pos.config.iface_vkeyboard && this.pos_widget.onscreen_keyboard){
this.pos_widget.onscreen_keyboard.connect(this.$('.searchbox input'));
}
},
@@ -648,9 +648,9 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
get_name: function(){
var user;
if(this.mode === 'cashier'){
user = this.pos.get('cashier') || this.pos.get('user');
user = this.pos.cashier || this.pos.user;
}else{
user = this.pos.get('selectedOrder').get_client() || this.pos.get('user');
user = this.pos.get('selectedOrder').get_client() || this.pos.user;
}
if(user){
return user.name;
@@ -818,6 +818,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
template: 'PosWidget',
init: function() {
this._super(arguments[0],{});
console.log('UH');
instance.web.blockUI();
@@ -881,7 +882,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
self.build_widgets();
if(self.pos.iface_big_scrollbars){
if(self.pos.config.iface_big_scrollbars){
self.$el.addClass('big-scrollbars');
}
@@ -891,9 +892,9 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
instance.webclient.set_content_full_screen(true);
if (!self.pos.get('pos_session')) {
if (!self.pos.session) {
self.screen_selector.show_popup('error', 'Sorry, we could not create a user session');
}else if(!self.pos.get('pos_config')){
}else if(!self.pos.config){
self.screen_selector.show_popup('error', 'Sorry, we could not find any PoS Configuration for this session');
}
@@ -1035,7 +1036,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
},
default_client_screen: 'welcome',
default_cashier_screen: 'products',
default_mode: this.pos.iface_self_checkout ? 'client' : 'cashier',
default_mode: this.pos.config.iface_self_checkout ? 'client' : 'cashier',
});
if(this.pos.debug){
+6 -6
View File
@@ -569,8 +569,8 @@
</t>
<t t-name="PaypadButtonWidget">
<button class="paypad-button" t-att-cash-register-id="widget.cashRegister.get('id')">
<t t-esc="widget.cashRegister.get('journal').name"/>
<button class="paypad-button" t-att-cash-register-id="widget.cashregister.id">
<t t-esc="widget.cashregister.journal.name"/>
</button>
</t>
@@ -590,10 +590,10 @@
<div class="pos-center-align"><t t-esc="new Date().toString(Date.CultureInfo.formatPatterns.shortDate + ' ' +
Date.CultureInfo.formatPatterns.longTime)"/> <t t-esc="order.get('name')"/></div>
<br />
<t t-esc="widget.company.name"/><br />
Phone: <t t-esc="widget.company.phone || ''"/><br />
User: <t t-esc="widget.user.name"/><br />
Shop: <t t-esc="widget.shop_obj.name"/><br />
<t t-esc="widget.pos.company.name"/><br />
Phone: <t t-esc="widget.pos.company.phone || ''"/><br />
User: <t t-esc="widget.pos.user.name"/><br />
Shop: <t t-esc="widget.pos.shop.name"/><br />
<br />
<table>
<colgroup>