diff --git a/__manifest__.py b/__manifest__.py index 79ec3f6..39161d7 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -1,7 +1,7 @@ { "name": "VRACOOP - POS Free Balance V2", "summary": "VRACOOP - POS Free Balance V2", - "version": "12.1.0.0", + "version": "12.2.0.1", "development_status": "Beta", "author": "Le Filament", "maintainers": ["remi-filament"], diff --git a/static/src/js/container.js b/static/src/js/container.js index f84d06a..8fe483a 100644 --- a/static/src/js/container.js +++ b/static/src/js/container.js @@ -107,7 +107,9 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) self.gui.show_screen('balancecontainerscale', {barcode: code.base_code}); } } - this._super(code); + else { + this._super(code); + } }, delete_selected_transaction: function(transaction, barcode){ @@ -374,7 +376,7 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) var pricelist = this._get_active_pricelist(); fields['price_product'] = (product ? product.get_price(pricelist, this.weight) : 0) || 0; - fields['price_net'] = fields['weight_net'] * fields['price_product']; + fields['price_net'] = (fields['weight_net'] * fields['price_product']).toFixed(2); fields.name = product.display_name; @@ -526,6 +528,7 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) }, set_weight: function(weight){ + this.weight = weight; var scale_screen = this.gui.screen_instances['balancescale']; var container = this.gui.get_current_screen_param('container'); @@ -556,12 +559,33 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) click_product: function(product) { var scale_screen = this.gui.screen_instances['balancescale']; - if (scale_screen.weight != 0) { this.create_transaction(product); } }, + order_product: function(product, container){ + // Replace the orderline if the product is the placeholder + // container product. + if (container){ + var order = this.pos.get_order(); + order.add_product(product,{ quantity: this.weight, price: 0.0 }); + var orderline = order.get_selected_orderline(); + orderline.set_container(container); + var old_orderline = this.gui.get_current_screen_param( + 'old_orderline'); + if (old_orderline){ + order.remove_orderline(old_orderline); + } + orderline.set_quantity(this.weight); + orderline.set_gross_weight(this.weight + container.weight); + orderline.set_tare_mode('AUTO'); + orderline.trigger('change', orderline); + } else { + this._super(); + } + }, + show: function(reset){ this._super(); if (reset) { @@ -618,19 +642,31 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) var pricelist = scale_screen._get_active_pricelist(); fields['price_product'] = (product ? product.get_price(pricelist, scale_screen.weight) : 0) || 0; - fields['price_net'] = fields['weight_net'] * fields['price_product']; + fields['price_net'] = (fields['weight_net'] * fields['price_product']).toFixed(2); fields.name = product.display_name; this.pos.push_transaction(fields).then( - this.pushed_transaction(fields["ean13"], product, container) + this.pushed_transaction(fields["ean13"], product, container, fields) ); }, - pushed_transaction: function(barcode, product, container){ + pushed_transaction: function(barcode, product, container, transaction){ var self = this; - this.gui.show_screen('confirmation',{product: product, container: container}); +// Add product on order + this.order_product(product, container); +// Push order + var order = this.pos.get_order(); + order.initialize_validation_date(); + order.finalized = true; + this.pos.push_order(order); + this.pos.add_new_order(); + + this.gui.show_screen( + 'confirmation', + {product: product, container: container, transaction: transaction}); + }, close: function(){ @@ -736,11 +772,6 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) }, pushed_container: function(barcode,container){ var self = this; - - var selected_order = this.pos.get_order(); - - selected_order.add_container(container); - if (this.pos.config.is_comptoir) { self.gui.show_screen(self.next_screen); } @@ -857,11 +888,13 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) this.pos.proxy.reset_tare(); } - setTimeout(function(){ - self.set_price(0); - self.pos.proxy.reset_tare(); - self.gui.show_screen('presentation'); - }, 5000); + // A remettre + // setTimeout(function(){ + // self.set_price(0); + // self.pos.proxy.reset_tare(); + // self.gui.show_screen('presentation'); + // }, 5000); + // A remettre }, @@ -999,7 +1032,7 @@ odoo.define('vracoop_pos_free_balance_v2.container_balance', function (require) this.name = options.transaction.name ; this.weight_net = options.transaction.weight_net.toFixed(3) ; this.price_product = options.transaction.price_product.toFixed(2); - this.price_net = options.transaction.price_net.toFixed(2); + this.price_net = options.transaction.price_net; this._super(options); diff --git a/static/src/js/models_and_db.js b/static/src/js/models_and_db.js index ff972b0..e9282bc 100644 --- a/static/src/js/models_and_db.js +++ b/static/src/js/models_and_db.js @@ -29,9 +29,9 @@ odoo.define('vracoop_pos_free_balance_v2.models_and_db_balance', function (requi var container = this.db.get_container_by_barcode( parsed_code.base_code); - var selected_order = this.get_order(); + // var selected_order = this.get_order(); - selected_order.add_container(container); + // selected_order.add_container(container); var today = new Date(); var date = today.getFullYear() + '-' + (today.getMonth()+1) + '-' + today.getDate();