[FIX] Forgot to add pos_basewidget.js
bzr revid: fva@openerp.com-20120516130142-5u23uerr5s8y7ydq
This commit is contained in:
parent
834beae083
commit
313496382a
|
@ -48,7 +48,6 @@ access_account_analytic_line,account.analytic.line,analytic.model_account_analyt
|
|||
access_account_analytic_account,account.analytic.account,analytic.model_account_analytic_account,group_pos_user,1,1,1,0
|
||||
access_account_journal_column,account.journal.column,account.model_account_journal_column,group_pos_user,1,1,1,0
|
||||
access_account_journal_column_manager,account.journal.column manager,account.model_account_journal_column,group_pos_manager,1,0,0,0
|
||||
access_report_check_register,report.cash.register,model_report_cash_register,group_pos_manager,1,1,1,1
|
||||
access_ir_property_pos_manager,ir.property manager,base.model_ir_property,group_pos_manager,1,1,1,1
|
||||
access_account_bank_statement_line_manager,account.bank.statement.line manager,account.model_account_bank_statement_line,group_pos_manager,1,1,1,1
|
||||
access_account_invoice_manager,account.invoice manager,account.model_account_invoice,group_pos_manager,1,1,1,1
|
||||
|
|
|
|
@ -11,6 +11,22 @@
|
|||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.point-of-sale .loader{
|
||||
background-color: #222;
|
||||
position:absolute;
|
||||
left:0px;
|
||||
top:0px;
|
||||
width:100%;
|
||||
height:100%;
|
||||
z-index: 999;
|
||||
text-align: center;
|
||||
}
|
||||
.point-of-sale .loader img{
|
||||
position:absolute;
|
||||
top:50%;
|
||||
left:50%;
|
||||
}
|
||||
|
||||
.point-of-sale table {
|
||||
border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
function openerp_pos_basewidget(instance, module){ //module is instance.point_of_sale
|
||||
|
||||
// This is a base class for all Widgets in the POS. It exposes relevant data to the
|
||||
// templates :
|
||||
// - widget.currency : { symbol: '$' | '€' | ..., position: 'before' | 'after }
|
||||
// - widget.format_currency(amount) : this method returns a formatted string based on the
|
||||
// symbol, the position, and the amount of money.
|
||||
// if the PoS is not fully loaded when you instanciate the widget, the currency might not
|
||||
// yet have been initialized. Use __build_currency_template() to recompute with correct values
|
||||
// before rendering.
|
||||
|
||||
module.PosBaseWidget = instance.web.Widget.extend({
|
||||
init:function(parent,options){
|
||||
this._super(parent);
|
||||
options = options || {};
|
||||
this.pos = options.pos;
|
||||
this.build_currency_template();
|
||||
},
|
||||
build_currency_template: function(){
|
||||
|
||||
if(this.pos && this.pos.get('currency')){
|
||||
this.currency = this.pos.get('currency');
|
||||
}else{
|
||||
this.currency = {symbol: '$', position: 'after'};
|
||||
}
|
||||
|
||||
this.format_currency = function(amount){
|
||||
if(this.currency.position === 'after'){
|
||||
return Math.round(amount*100)/100 + ' ' + this.currency.symbol;
|
||||
}else{
|
||||
return this.currency.symbol + ' ' + Math.round(amount*100)/100;
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
}
|
|
@ -68,6 +68,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
'user': {},
|
||||
'orders': new module.OrderCollection(),
|
||||
'products': new module.ProductCollection(),
|
||||
'cashRegisters': [], //new module.CashRegisterCollection(this.pos.get('bank_statements'));
|
||||
'selectedOrder': undefined,
|
||||
});
|
||||
|
||||
|
@ -87,19 +88,39 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
|
||||
var session_def = fetch(
|
||||
'pos.session',
|
||||
['id', 'journal_ids'],
|
||||
['id', 'journal_ids','name','config_id','start_at','stop_at'],
|
||||
[['state', '=', 'opened'], ['user_id', '=', this.session.uid]]
|
||||
).then(function(result) {
|
||||
if( result.length !== 0 ) {
|
||||
console.log('pos_session:', result);
|
||||
var pos_session = result[0];
|
||||
console.log('pos_session:', pos_session);
|
||||
|
||||
self.set({'pos_session': pos_session});
|
||||
|
||||
var journal_def = fetch(
|
||||
'account.journal',
|
||||
['name'],
|
||||
[['id', 'in', result[0]['journal_ids']]]).then(function(inner_result) {
|
||||
self.set({'account_journals' : inner_result});
|
||||
});
|
||||
'account.journal',
|
||||
['name'],
|
||||
[['id', 'in', pos_session['journal_ids']]]
|
||||
).then(function(inner_result) {
|
||||
console.log('account_journals:',inner_result);
|
||||
return self.set({'account_journals' : inner_result});
|
||||
});
|
||||
|
||||
var pos_config_def = fetch(
|
||||
'pos.config',
|
||||
['name','journal_ids','shop_id','journal_id',
|
||||
'iface_self_checkout', 'iface_websql', 'iface_led', 'iface_cashdrawer',
|
||||
'iface_payment_terminal', 'iface_electronic_scale', 'iface_barscan', 'iface_vkeyboard',
|
||||
'iface_print_via_proxy','state','sequence_id','session_ids'],
|
||||
[['id','=', pos_session.config_id[0]]]
|
||||
).then(function(result){
|
||||
console.log('pos_config:',result[0]);
|
||||
return self.set({'pos_config': result[0]});
|
||||
});
|
||||
return $.when(journal_def, pos_config_def);
|
||||
}else{
|
||||
return self;
|
||||
}
|
||||
return self;
|
||||
});
|
||||
|
||||
var tax_def = fetch('account.tax', ['amount','price_include','type'])
|
||||
|
@ -112,6 +133,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
.pipe(_.bind(this.build_tree, this))
|
||||
.pipe(function(){
|
||||
self.set({'accountJournals' : new module.AccountJournalCollection(self.get('account_journals'))});
|
||||
console.log('accountJournals:',self.get('accountJournals'));
|
||||
self.ready.resolve();
|
||||
});
|
||||
|
||||
|
@ -263,6 +285,13 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
|||
model: module.AccountJournal,
|
||||
});
|
||||
|
||||
module.CashRegister = Backbone.Model.extend({
|
||||
});
|
||||
|
||||
module.CashRegisterCollection = Backbone.Collection.extend({
|
||||
model: module.CashRegister,
|
||||
});
|
||||
|
||||
module.Product = Backbone.Model.extend({
|
||||
});
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
|||
|
||||
this.current_client_screen = this.screen_set[this.default_client_screen];
|
||||
|
||||
this.current_cashier_screen = this.screen_set[this.default_client_screen];
|
||||
this.current_cashier_screen = this.screen_set[this.default_cashier_screen];
|
||||
|
||||
this.current_popup = null;
|
||||
|
||||
|
@ -40,7 +40,7 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
|||
this.current_screen = this.current_mode === 'client' ?
|
||||
this.current_client_screen:
|
||||
this.current_cashier_screen;
|
||||
|
||||
|
||||
var current = null;
|
||||
for(screen_name in this.screen_set){
|
||||
var screen = this.screen_set[screen_name];
|
||||
|
@ -73,11 +73,13 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
|||
this.screen_set[screen_name] = screen;
|
||||
return this;
|
||||
},
|
||||
show_popup: function(name){
|
||||
show_popup: function(name,message){
|
||||
console.log('show_popup:',message);
|
||||
if(this.current_popup){
|
||||
this.close_popup();
|
||||
}
|
||||
this.current_popup = this.popup_set[name];
|
||||
this.current_popup.set_message(message);
|
||||
this.current_popup.show();
|
||||
},
|
||||
close_popup: function(){
|
||||
|
@ -159,6 +161,10 @@ function openerp_pos_screens(instance, module){ //module is instance.point_of_sa
|
|||
this.$element.hide();
|
||||
}
|
||||
},
|
||||
set_message: function(message){
|
||||
this.message = message || '';
|
||||
this.renderElement();
|
||||
},
|
||||
});
|
||||
|
||||
module.HelpPopupWidget = module.PopUpWidget.extend({
|
||||
|
|
|
@ -64,13 +64,15 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
return (this.pos.get('selectedOrder')).addPaymentLine(accountJournal);
|
||||
},
|
||||
renderElement: function() {
|
||||
this.$element.empty();
|
||||
this._super();
|
||||
return (this.pos.get('accountJournals')).each(_.bind(function(accountJournal) {
|
||||
console.log('journal:',accountJournal);
|
||||
var button = new module.PaymentButtonWidget(this,{
|
||||
pos:this.pos,
|
||||
});
|
||||
button.model = accountJournal;
|
||||
button.appendTo(this.$element);
|
||||
console.log(this.$element);
|
||||
}, this));
|
||||
}
|
||||
});
|
||||
|
@ -793,10 +795,22 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
this.build_widgets();
|
||||
|
||||
instance.webclient.set_content_full_screen(true);
|
||||
if (!self.pos.get('account_journals') ||self.pos.get('account_journals').length === 0) {
|
||||
// TODO: Create a popup to inform there is no PoSSession for this user
|
||||
self.screen_selector.show_popup('error-session');
|
||||
|
||||
if (!self.pos.get('pos_session')) {
|
||||
self.screen_selector.show_popup('error',
|
||||
'Sorry, we could not create a user session');
|
||||
}else if (!self.pos.get('account_journals') || self.pos.get('account_journals').length === 0){
|
||||
self.screen_selector.show_popup('error',
|
||||
'Sorry, we could not find any accounting journals in the configuration');
|
||||
}else if(!self.pos.get('pos_config')){
|
||||
self.screen_selector.show_popup('error',
|
||||
'Sorry, we could not find any PoS Configuration for this session');
|
||||
}
|
||||
|
||||
|
||||
$('.loader').animate({opacity:0},3000,'swing',function(){$('.loader').hide();});
|
||||
$('.loader img').hide();
|
||||
|
||||
}, this));
|
||||
},
|
||||
|
||||
|
@ -891,7 +905,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
pos: this.pos,
|
||||
pos_widget: this,
|
||||
});
|
||||
this.paypad.replace($('placeholder-PaypadWidget'));
|
||||
this.paypad.replace($('#placeholder-PaypadWidget'));
|
||||
|
||||
this.numpad = new module.NumpadWidget(this);
|
||||
this.numpad.replace($('#placeholder-NumpadWidget'));
|
||||
|
@ -907,6 +921,10 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
});
|
||||
this.onscreen_keyboard.appendTo($(".point-of-sale #content"));
|
||||
|
||||
var self_checkout = this.pos.get('pos_config').iface_self_checkout;
|
||||
console.log('pos:',this.pos);
|
||||
console.log('self_checkout:',self_checkout);
|
||||
|
||||
this.screen_selector = new module.ScreenSelector({
|
||||
pos: this.pos,
|
||||
screen_set:{
|
||||
|
@ -928,7 +946,7 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
|
|||
},
|
||||
default_client_screen: 'welcome',
|
||||
default_cashier_screen: 'products',
|
||||
default_mode: 'client',
|
||||
default_mode: this.pos.get('pos_config').iface_self_checkout ? 'client' : 'cashier',
|
||||
});
|
||||
window.screen_selector = this.screen_selector;
|
||||
|
||||
|
|
|
@ -57,6 +57,9 @@
|
|||
<div id="rightpane">
|
||||
</div>
|
||||
</div>
|
||||
<div class="loader">
|
||||
<img src="/point_of_sale/static/src/img/loader.gif" />
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
|
@ -319,7 +322,7 @@
|
|||
<t t-name="ErrorPopupWidget">
|
||||
<div class="modal-dialog">
|
||||
<div class="popup popup-help">
|
||||
<p class="message">The scanned product was not recognized<br /> Please wait, a cashier is on the way</p>
|
||||
<p class="message"><t t-esc=" widget.message || 'Error.' " /></p>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
|
Loading…
Reference in New Issue