@ -13,7 +13,6 @@ odoo.define("pos_lot_selection.chrome", function (require) {
// Add events over instanced popup
// Add events over instanced popup
var events = {
var events = {
"change .packlot-line-select" : "lot_to_input" ,
"change .packlot-line-select" : "lot_to_input" ,
"click .lot-clone" : "clone_input" ,
} ;
} ;
packlotline . events = Object . assign (
packlotline . events = Object . assign (
packlotline . events , events
packlotline . events , events
@ -21,39 +20,18 @@ odoo.define("pos_lot_selection.chrome", function (require) {
// Add methods over instanced popup
// Add methods over instanced popup
// Write the value in the corresponding input
// Write the value in the corresponding input
packlotline . lot_to_input = function ( event ) {
packlotline . lot_to_input = function ( event ) {
var $select = this . $ ( "select.packlot-line-select" ) ;
var $select = $ ( event . target ) ;
var $option = this . $ ( "select.packlot-line-select option" ) ;
var $option = this . $ ( "select.packlot-line-select option" ) ;
var $input = this . $el . find ( "input[cid='" + this . active_cid + "'] " ) ;
var $input = this . $el . find ( "input" ) ;
if ( $input . length ) {
if ( $input . length ) {
$input [ 0 ] . value = $select [ 0 ] . value ;
$input [ 0 ] . value = $select [ 0 ] . value ;
$input . blur ( ) ;
$input . focus ( ) ;
$input . focus ( ) ;
}
}
$option . prop ( 'selected' , function ( ) {
$option . prop ( 'selected' , function ( ) {
return this . defaultSelected ;
return this . defaultSelected ;
} ) ;
} ) ;
} ;
} ;
// Tracks the last selected input
packlotline . lose_input_focus = function ( event ) {
var $input = $ ( event . target ) ,
cid = $input . attr ( 'cid' ) ;
this . active_cid = cid ;
var lot_model = this . options . pack_lot_lines . get ( { cid : cid } ) ;
lot_model . set_lot_name ( $input . val ( ) ) ;
} ;
// Clones content of input to all the others
packlotline . clone_input = function ( event ) {
var $input = $ ( event . target ) . prev ( ) . prev ( ) ,
cid = $input . attr ( 'cid' ) ;
var $clone_input = this . $el . find ( "input" ) ;
if ( $clone_input . length > 1 ) {
for ( var i = 0 ; i < $clone_input . length ; i ++ ) {
if ( $clone_input [ i ] . getAttribute ( 'cid' ) != cid ) {
$clone_input [ i ] . value = $input . val ( ) ;
$clone_input [ i ] . blur ( ) ;
}
}
}
} ;
this . gui . popup_instances . packlotline = packlotline ;
this . gui . popup_instances . packlotline = packlotline ;
return res ;
return res ;
} ,
} ,