diff --git a/pos_traceability_validation/__manifest__.py b/pos_traceability_validation/__manifest__.py index 3596ec29c..20fc39333 100644 --- a/pos_traceability_validation/__manifest__.py +++ b/pos_traceability_validation/__manifest__.py @@ -21,7 +21,7 @@ { 'name': 'POS Serial Number Validator', - 'version': '13.0.1.0.0', + 'version': '13.0.1.0.1', 'author': 'Cybrosys Techno Solutions', 'company': 'Cybrosys Techno Solutions', 'website': 'https://www.cybrosys.com', diff --git a/pos_traceability_validation/static/src/js/pos_models.js b/pos_traceability_validation/static/src/js/pos_models.js index 6cbd74215..892ca7c8e 100644 --- a/pos_traceability_validation/static/src/js/pos_models.js +++ b/pos_traceability_validation/static/src/js/pos_models.js @@ -1,17 +1,16 @@ odoo.define('pos_traceability_validation.models', function (require) { "use strict"; - var PosModel = require('point_of_sale.models'); var PosPopups = require('point_of_sale.popups'); var gui = require('point_of_sale.gui'); var rpc = require('web.rpc'); var PackLotLinePopupWidget = PosPopups.extend({ template: 'PackLotLinePopupWidget', - events: _.extend({}, PopupWidget.prototype.events, { + events: _.extend({}, PosPopups.prototype.events, { 'click .remove-lot': 'remove_lot', 'keydown': 'add_lot', - 'blur .packlot-line-input': 'lose_input_focus' + 'blur .packlot-line-input': 'lose_input_focus', }), /*making sure we didn't used same key already in the order*/ @@ -47,7 +46,7 @@ odoo.define('pos_traceability_validation.models', function (require) { method: 'validate_lots', args: [lot_names] }).then(function(result){ - + if(result != true){ var current_id = lot_cid[result[1]]; var pack_line = pack_lot_lines.get({cid: current_id}); @@ -63,7 +62,6 @@ odoo.define('pos_traceability_validation.models', function (require) { } } else{ - pack_lot_lines.s(); pack_lot_lines.set_quantity_by_lot(); self.options.order.save_to_db(); self.options.order_line.trigger( @@ -74,6 +72,23 @@ odoo.define('pos_traceability_validation.models', function (require) { } }); }, + add_lot: function(ev) { + if (ev.keyCode === $.ui.keyCode.ENTER && this.options.order_line.product.tracking == 'serial') { + var pack_lot_lines = this.options.pack_lot_lines, + $input = $(ev.target), + cid = $input.attr('cid'), + lot_name = $input.val(); + var lot_model = pack_lot_lines.get({ cid: cid }); + lot_model.set_lot_name(lot_name); // First set current model then add new one + if (!pack_lot_lines.get_empty_model()) { + var new_lot_model = lot_model.add(); + this.focus_model = new_lot_model; + } + pack_lot_lines.set_quantity_by_lot(); + this.renderElement(); + this.focus(); + } + }, remove_lot: function(ev){ var pack_lot_lines = this.options.pack_lot_lines, $input = $(ev.target).prev(), @@ -82,10 +97,21 @@ odoo.define('pos_traceability_validation.models', function (require) { lot_model.remove(); pack_lot_lines.set_quantity_by_lot(); this.renderElement(); - } - - + }, + lose_input_focus: function(ev) { + var $input = $(ev.target), + cid = $input.attr('cid'); + var lot_model = this.options.pack_lot_lines.get({ cid: cid }); + lot_model.set_lot_name($input.val()); + }, + focus: function() { + this.$("input[autofocus]").focus(); + this.focus_model = false; + }, }); gui.define_popup({name:'packlotline', widget: PackLotLinePopupWidget}); }); + + +