diff --git a/pos_tare/static/src/js/screens.js b/pos_tare/static/src/js/screens.js index ff7a4ed64b..494984d8d8 100644 --- a/pos_tare/static/src/js/screens.js +++ b/pos_tare/static/src/js/screens.js @@ -36,6 +36,8 @@ odoo.define('pos_tare.screens', function (require) { }, }); + var _super_ScaleScreenWidget_order_product = screens.ScaleScreenWidget.prototype.order_product; + screens.ScaleScreenWidget.include({ // ///////////////////////////// @@ -74,12 +76,34 @@ odoo.define('pos_tare.screens', function (require) { }, order_product: function () { + var self = this; if (this.tare === undefined) { this.gui.show_popup('error', { 'title': _t('Incorrect Tare Value'), 'body': _t('Please set a numeric value' + ' in the tare field, or let empty.'), }); + } else if (isNaN(this.gross_weight)) { + this.gui.show_popup('error', { + 'title': _t('Incorrect Gross Weight Value'), + 'body': _t('Please set a numeric value' + + ' in the gross weight field.'), + }); + } else if (this.weight <= 0) { + this.gui.show_popup('confirm', { + title: _t('Quantity lower or equal to zero'), + body: _t( + "The quantity is lower or equal to" + + " zero. Are you sure you want to continue ?"), + confirm: function() { + _super_ScaleScreenWidget_order_product.apply(self); + if (self.tare > 0.0) { + var order = self.pos.get_order(); + var orderline = order.get_last_orderline(); + orderline.set_tare(self.tare, false); + } + }, + }); } else { this._super(); if (this.tare > 0.0) { @@ -133,31 +157,6 @@ odoo.define('pos_tare.screens', function (require) { }); - screens.PaymentScreenWidget.include({ - validate_order: function(options) { - var order = this.pos.get_order(); - var orderlines = Array.from(order.get_orderlines()); - - if (orderlines.some(leq_zero_qty)) { - var _super_validate_order = this._super.bind(this); - var wrong_orderline = orderlines.find(leq_zero_qty); - var wrong_product = wrong_orderline.get_product().display_name; - this.gui.show_popup('confirm', { - title: _t('Quantity lower or equal to zero'), - body: _.str.sprintf( - _t("The quantity for \"%s\" is lower or equal to" + - " zero. Call for help unless you're perfectly" + - " sure you are doing right."), wrong_product), - confirm: function() { - _super_validate_order(); - }, - }); - return; - } - return this._super(options); - }, - }); - screens.OrderWidget.include({ set_value: function (val) { var order = this.pos.get_order(); @@ -180,7 +179,7 @@ odoo.define('pos_tare.screens', function (require) { } else if (mode === 'tare') { if (this.pos.config.iface_tare_method === 'barcode') { this.gui.show_popup('error', - {'title': _t('Incorrect Tare Value'), + {'title': _t('Feature Disabled'), 'body': _t('You can not set the tare.' + ' To be able to set the tare manually' + ' you have to change the tare input method' +