Browse Source

[FIX] Bug Fixed 'pos_traceability_validation'

pull/165/head
Ajmal JK 5 years ago
parent
commit
99e2a00f28
  1. 2
      pos_traceability_validation/__manifest__.py
  2. 40
      pos_traceability_validation/static/src/js/pos_models.js

2
pos_traceability_validation/__manifest__.py

@ -21,7 +21,7 @@
{ {
'name': 'POS Serial Number Validator', 'name': 'POS Serial Number Validator',
'version': '13.0.1.0.0', 'version': '13.0.1.0.1',
'author': 'Cybrosys Techno Solutions', 'author': 'Cybrosys Techno Solutions',
'company': 'Cybrosys Techno Solutions', 'company': 'Cybrosys Techno Solutions',
'website': 'https://www.cybrosys.com', 'website': 'https://www.cybrosys.com',

40
pos_traceability_validation/static/src/js/pos_models.js

@ -1,17 +1,16 @@
odoo.define('pos_traceability_validation.models', function (require) { odoo.define('pos_traceability_validation.models', function (require) {
"use strict"; "use strict";
var PosModel = require('point_of_sale.models'); var PosModel = require('point_of_sale.models');
var PosPopups = require('point_of_sale.popups'); var PosPopups = require('point_of_sale.popups');
var gui = require('point_of_sale.gui'); var gui = require('point_of_sale.gui');
var rpc = require('web.rpc'); var rpc = require('web.rpc');
var PackLotLinePopupWidget = PosPopups.extend({ var PackLotLinePopupWidget = PosPopups.extend({
template: 'PackLotLinePopupWidget', template: 'PackLotLinePopupWidget',
events: _.extend({}, PopupWidget.prototype.events, { events: _.extend({}, PosPopups.prototype.events, {
'click .remove-lot': 'remove_lot', 'click .remove-lot': 'remove_lot',
'keydown': 'add_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*/ /*making sure we didn't used same key already in the order*/
@ -63,7 +62,6 @@ odoo.define('pos_traceability_validation.models', function (require) {
} }
} }
else{ else{
pack_lot_lines.s();
pack_lot_lines.set_quantity_by_lot(); pack_lot_lines.set_quantity_by_lot();
self.options.order.save_to_db(); self.options.order.save_to_db();
self.options.order_line.trigger( self.options.order_line.trigger(
@ -73,6 +71,23 @@ odoo.define('pos_traceability_validation.models', function (require) {
self.gui.close_popup(); self.gui.close_popup();
} }
}); });
},
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){ remove_lot: function(ev){
var pack_lot_lines = this.options.pack_lot_lines, var pack_lot_lines = this.options.pack_lot_lines,
@ -82,10 +97,21 @@ odoo.define('pos_traceability_validation.models', function (require) {
lot_model.remove(); lot_model.remove();
pack_lot_lines.set_quantity_by_lot(); pack_lot_lines.set_quantity_by_lot();
this.renderElement(); 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}); gui.define_popup({name:'packlotline', widget: PackLotLinePopupWidget});
}); });

Loading…
Cancel
Save