|
|
@ -25,6 +25,141 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) |
|
|
|
|
|
|
|
var round_pr = utils.round_precision; |
|
|
|
|
|
|
|
screens.ScreenWidget.include({ |
|
|
|
|
|
|
|
show: function(){ |
|
|
|
var self = this; |
|
|
|
var queue = this.pos.proxy_queue; |
|
|
|
|
|
|
|
var container = this.gui.get_current_screen_param('container'); |
|
|
|
|
|
|
|
// format price
|
|
|
|
var scale_screen = this.gui.screen_instances['balancescale']; |
|
|
|
var price = scale_screen.format_price(scale_screen.get_product_price()); |
|
|
|
|
|
|
|
if (container) { |
|
|
|
// format tare
|
|
|
|
var tare = this.format_tare(container); |
|
|
|
queue.schedule(function () { |
|
|
|
return self.pos.proxy.scale_read_data_price_tare(price, tare).then(function (scale_answer) { |
|
|
|
self.set_weight(scale_answer.weight); |
|
|
|
|
|
|
|
if ((scale_answer.error === '30' || scale_answer.error === '31') && scale_answer.weight !== 0) { |
|
|
|
self.set_weight(0); |
|
|
|
self.pos.proxy.reset_tare(); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, {duration: 500, repeat: true}); |
|
|
|
|
|
|
|
} else { |
|
|
|
queue.schedule(function () { |
|
|
|
return self.pos.proxy.scale_read_data_price(price).then(function (scale_answer) { |
|
|
|
self.set_weight(scale_answer.weight); |
|
|
|
// self.set_price(scale_answer.price);
|
|
|
|
if ((scale_answer.error === '30' || scale_answer.error === '31') && scale_answer.weight !== 0) { |
|
|
|
self.set_weight(0); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, {duration: 500, repeat: true}); |
|
|
|
} |
|
|
|
|
|
|
|
this._super(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
format_tare: function (container) { |
|
|
|
var tare = (Math.abs(container.weight) * 1000).toString(); |
|
|
|
tare = ("0000" + tare).slice(-4); |
|
|
|
return tare; |
|
|
|
}, |
|
|
|
|
|
|
|
set_weight: function(weight){ |
|
|
|
var scale_screen = this.gui.screen_instances['balancescale']; |
|
|
|
scale_screen.weight = weight; |
|
|
|
scale_screen.$('.weight').text(scale_screen.get_product_weight_string()); |
|
|
|
scale_screen.$('.computed-price').text(scale_screen.format_currency(scale_screen.get_product_price() * 0)); |
|
|
|
scale_screen.$('.weight-brut').text('0.000 kg'); |
|
|
|
|
|
|
|
var container_text = '0.000 kg' |
|
|
|
scale_screen.$('.tare-container').text(container_text); |
|
|
|
}, |
|
|
|
|
|
|
|
set_price: function (price) { |
|
|
|
var scale_screen = this.gui.screen_instances['balancescale']; |
|
|
|
scale_screen.price = price; |
|
|
|
scale_screen.$('.computed-price').text(scale_screen.format_currency(0)); |
|
|
|
}, |
|
|
|
|
|
|
|
barcode_container_action: function(code){ |
|
|
|
var self = this; |
|
|
|
|
|
|
|
if (self.pos.scan_container(code)) { |
|
|
|
var order = this.pos.get_order(); |
|
|
|
var selected_orderline = order.get_selected_orderline(); |
|
|
|
var container = selected_orderline.get_container(); |
|
|
|
// Vérfification: est-ce qu'un container vient d'être utilisé dans l'heure
|
|
|
|
if (self.pos.scan_container_check(code)){ |
|
|
|
var transaction = self.pos.scan_container_check(code); |
|
|
|
this.gui.show_popup('doublon-barcode',{ |
|
|
|
title: _t('Contenu déjà enregistré récemment:'), |
|
|
|
transaction: transaction, |
|
|
|
confirm: function(){ |
|
|
|
var transaction = self.pos.scan_container_check(code) |
|
|
|
self.delete_selected_transaction(transaction, code); |
|
|
|
self.gui.show_screen('products', {container: container}); |
|
|
|
}, |
|
|
|
}); |
|
|
|
|
|
|
|
} else { |
|
|
|
self.gui.show_screen('products', {container: container}); |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
self.gui.show_screen('balancecontainerscale', {barcode: code.base_code}); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
delete_selected_transaction: function(transaction, barcode){ |
|
|
|
var self = this; |
|
|
|
|
|
|
|
if (!transaction.id){ |
|
|
|
self.deleted_transaction(transaction.container_ean13) |
|
|
|
} |
|
|
|
else { |
|
|
|
rpc.query({ |
|
|
|
model: 'pos.transaction', |
|
|
|
method: 'unlink', |
|
|
|
args: [transaction.id], |
|
|
|
}).then(function(){ |
|
|
|
self.deleted_transaction(transaction.container_ean13); |
|
|
|
},function(err,ev){ |
|
|
|
ev.preventDefault(); |
|
|
|
var error_body = _t('Your Internet connection is probably down.'); |
|
|
|
if (err.data) { |
|
|
|
var except = err.data; |
|
|
|
error_body = except.arguments && except.arguments[0] || except.message || error_body; |
|
|
|
} |
|
|
|
self.gui.show_popup('error',{ |
|
|
|
'title': _t('Error: Could not Save Changes'), |
|
|
|
'body': error_body, |
|
|
|
}); |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
}, |
|
|
|
deleted_transaction: function(barcode){ |
|
|
|
var self = this; |
|
|
|
this.pos.db.remove_transactions([barcode]); |
|
|
|
}, |
|
|
|
|
|
|
|
close: function(){ |
|
|
|
this._super(); |
|
|
|
|
|
|
|
this.pos.proxy_queue.clear(); |
|
|
|
}, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
var BalanceScaleScreenWidget = screens.ScaleScreenWidget.extend({ |
|
|
|
template: 'BalanceScaleScreenWidget', |
|
|
|
|
|
|
@ -398,141 +533,6 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
screens.ScreenWidget.include({ |
|
|
|
|
|
|
|
show: function(){ |
|
|
|
var self = this; |
|
|
|
var queue = this.pos.proxy_queue; |
|
|
|
|
|
|
|
var container = this.gui.get_current_screen_param('container'); |
|
|
|
|
|
|
|
// format price
|
|
|
|
var scale_screen = this.gui.screen_instances['balancescale']; |
|
|
|
var price = scale_screen.format_price(scale_screen.get_product_price()); |
|
|
|
|
|
|
|
if (container) { |
|
|
|
// format tare
|
|
|
|
var tare = this.format_tare(container); |
|
|
|
queue.schedule(function () { |
|
|
|
return self.pos.proxy.scale_read_data_price_tare(price, tare).then(function (scale_answer) { |
|
|
|
self.set_weight(scale_answer.weight); |
|
|
|
|
|
|
|
if ((scale_answer.error === '30' || scale_answer.error === '31') && scale_answer.weight !== 0) { |
|
|
|
self.set_weight(0); |
|
|
|
// self.pos.proxy.reset_tare();
|
|
|
|
} |
|
|
|
}); |
|
|
|
}, {duration: 500, repeat: true}); |
|
|
|
|
|
|
|
} else { |
|
|
|
queue.schedule(function () { |
|
|
|
return self.pos.proxy.scale_read_data_price(price).then(function (scale_answer) { |
|
|
|
self.set_weight(scale_answer.weight); |
|
|
|
// self.set_price(scale_answer.price);
|
|
|
|
if ((scale_answer.error === '30' || scale_answer.error === '31') && scale_answer.weight !== 0) { |
|
|
|
self.set_weight(0); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, {duration: 500, repeat: true}); |
|
|
|
} |
|
|
|
|
|
|
|
this._super(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
format_tare: function (container) { |
|
|
|
var tare = (Math.abs(container.weight) * 1000).toString(); |
|
|
|
tare = ("0000" + tare).slice(-4); |
|
|
|
return tare; |
|
|
|
}, |
|
|
|
|
|
|
|
set_weight: function(weight){ |
|
|
|
var scale_screen = this.gui.screen_instances['balancescale']; |
|
|
|
scale_screen.weight = weight; |
|
|
|
scale_screen.$('.weight').text(scale_screen.get_product_weight_string()); |
|
|
|
scale_screen.$('.computed-price').text(scale_screen.format_currency(scale_screen.get_product_price() * 0)); |
|
|
|
scale_screen.$('.weight-brut').text('0.000 kg'); |
|
|
|
|
|
|
|
var container_text = '0.000 kg' |
|
|
|
scale_screen.$('.tare-container').text(container_text); |
|
|
|
}, |
|
|
|
|
|
|
|
set_price: function (price) { |
|
|
|
var scale_screen = this.gui.screen_instances['balancescale']; |
|
|
|
scale_screen.price = price; |
|
|
|
scale_screen.$('.computed-price').text(scale_screen.format_currency(0)); |
|
|
|
}, |
|
|
|
|
|
|
|
barcode_container_action: function(code){ |
|
|
|
var self = this; |
|
|
|
|
|
|
|
if (self.pos.scan_container(code)) { |
|
|
|
var order = this.pos.get_order(); |
|
|
|
var selected_orderline = order.get_selected_orderline(); |
|
|
|
var container = selected_orderline.get_container(); |
|
|
|
// Vérfification: est-ce qu'un container vient d'être utilisé dans l'heure
|
|
|
|
if (self.pos.scan_container_check(code)){ |
|
|
|
var transaction = self.pos.scan_container_check(code); |
|
|
|
this.gui.show_popup('doublon-barcode',{ |
|
|
|
title: _t('Contenu déjà enregistré récemment:'), |
|
|
|
transaction: transaction, |
|
|
|
confirm: function(){ |
|
|
|
var transaction = self.pos.scan_container_check(code) |
|
|
|
self.delete_selected_transaction(transaction, code); |
|
|
|
self.gui.show_screen('products', {container: container}); |
|
|
|
}, |
|
|
|
}); |
|
|
|
|
|
|
|
} else { |
|
|
|
self.gui.show_screen('products', {container: container}); |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
self.gui.show_screen('balancecontainerscale', {barcode: code.base_code}); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
delete_selected_transaction: function(transaction, barcode){ |
|
|
|
var self = this; |
|
|
|
|
|
|
|
if (!transaction.id){ |
|
|
|
self.deleted_transaction(transaction.container_ean13) |
|
|
|
} |
|
|
|
else { |
|
|
|
rpc.query({ |
|
|
|
model: 'pos.transaction', |
|
|
|
method: 'unlink', |
|
|
|
args: [transaction.id], |
|
|
|
}).then(function(){ |
|
|
|
self.deleted_transaction(transaction.container_ean13); |
|
|
|
},function(err,ev){ |
|
|
|
ev.preventDefault(); |
|
|
|
var error_body = _t('Your Internet connection is probably down.'); |
|
|
|
if (err.data) { |
|
|
|
var except = err.data; |
|
|
|
error_body = except.arguments && except.arguments[0] || except.message || error_body; |
|
|
|
} |
|
|
|
self.gui.show_popup('error',{ |
|
|
|
'title': _t('Error: Could not Save Changes'), |
|
|
|
'body': error_body, |
|
|
|
}); |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
}, |
|
|
|
deleted_transaction: function(barcode){ |
|
|
|
var self = this; |
|
|
|
this.pos.db.remove_transactions([barcode]); |
|
|
|
}, |
|
|
|
|
|
|
|
close: function(){ |
|
|
|
this._super(); |
|
|
|
|
|
|
|
this.pos.proxy_queue.clear(); |
|
|
|
}, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
var ConfirmPopupWidgetPesee = popups.extend({ |
|
|
|
template: 'ConfirmPopupWidgetPesee', |
|
|
|
}); |
|
|
@ -606,18 +606,20 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) |
|
|
|
this.$('.next,.back-presentation').click(function(){ |
|
|
|
// self.set_weight(0);
|
|
|
|
self.set_price(0); |
|
|
|
self.pos.proxy.reset_tare(); |
|
|
|
self.gui.show_screen('presentation'); |
|
|
|
}); |
|
|
|
|
|
|
|
$("#pos-header-text-confirm").removeClass('oe_hidden'); |
|
|
|
|
|
|
|
// var container = this.gui.get_current_screen_param('container');
|
|
|
|
// if (container) {
|
|
|
|
// this.pos.proxy.reset_tare();
|
|
|
|
// }
|
|
|
|
var container = this.gui.get_current_screen_param('container'); |
|
|
|
if (container) { |
|
|
|
this.pos.proxy.reset_tare(); |
|
|
|
} |
|
|
|
|
|
|
|
setTimeout(function(){ |
|
|
|
self.set_price(0); |
|
|
|
self.pos.proxy.reset_tare(); |
|
|
|
self.gui.show_screen('presentation'); |
|
|
|
}, 5000); |
|
|
|
|
|
|
|