Browse Source

Pb Tare contenant

12.0
Juliana 4 years ago
parent
commit
c0239928d8
  1. 94
      static/src/js/container.js

94
static/src/js/container.js

@ -379,28 +379,53 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require)
var self = this;
var queue = this.pos.proxy_queue;
var scale_screen = this.gui.screen_instances['balancescale'];
this.set_weight(0);
// this.set_price(0);
scale_screen.renderElement();
// queue.schedule(function () {
// return self.pos.proxy.reset_weight().then(function () {
// self.set_weight(0);
// // self.set_price(0);
// });
// }, {duration: 500});
queue.schedule(function(){
return self.pos.proxy.scale_read().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);
}
var container = this.gui.get_current_screen_param('container');
queue.schedule(function () {
return self.pos.proxy.reset_weight().then(function () {
self.set_weight(0);
self.set_price(0);
});
},{duration:500, repeat: true});
}, {duration: 500});
// 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){
@ -420,7 +445,9 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require)
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);
@ -430,12 +457,12 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require)
confirm: function(){
var transaction = self.pos.scan_container_check(code)
self.delete_selected_transaction(transaction, code);
self.gui.show_screen('products');
self.gui.show_screen('products', {container: container});
},
});
} else {
self.gui.show_screen('products');
self.gui.show_screen('products', {container: container});
}
} else {
@ -569,9 +596,7 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require)
set_weight: function(weight){
var scale_screen = this.gui.screen_instances['balancescale'];
var order = this.pos.get_order();
var selected_orderline = order.get_selected_orderline();
var container = selected_orderline.get_container();
var container = this.gui.get_current_screen_param('container');
scale_screen.weight_container = container.weight;
scale_screen.weight = weight;
@ -676,7 +701,7 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require)
previous_screen: 'presentation',
show: function(){
this._super();
var self = this;
@ -710,9 +735,7 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require)
set_weight: function(weight){
var scale_screen = this.gui.screen_instances['balancescale'];
var order = this.pos.get_order();
var selected_orderline = order.get_selected_orderline();
var container = selected_orderline.get_container();
var container = this.gui.get_current_screen_param('container');
scale_screen.weight_container = container.weight;
scale_screen.weight = weight;
@ -741,9 +764,10 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require)
create_transaction: function(product){
var self = this;
var fields = {};
var order = this.pos.get_order();
var selected_orderline = order.get_selected_orderline();
var container = selected_orderline.get_container();
// var order = this.pos.get_order();
// var selected_orderline = order.get_selected_orderline();
// var container = selected_orderline.get_container();
var container = this.gui.get_current_screen_param('container');
var scale_screen = this.gui.screen_instances['balancescale'];
// var product = this.get_product();
@ -789,14 +813,14 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require)
fields.name = product.display_name;
this.pos.push_transaction(fields).then(
this.pushed_transaction(fields["ean13"], product)
this.pushed_transaction(fields["ean13"], product, container)
);
},
pushed_transaction: function(barcode, product){
pushed_transaction: function(barcode, product, container){
var self = this;
this.gui.show_screen('confirmation',{product: product});
this.gui.show_screen('confirmation',{product: product, container: container});
},
close: function(){

Loading…
Cancel
Save