[REF] pos_hr: adapt code after jQuery update
Part of task 1896658 Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Christophe Matthieu <chm@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: David Monjoie <dmo@odoo.com> Co-authored-by: Martin Geubelle <mge@odoo.com> Co-authored-by: svs-odoo <svs@odoo.com> Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
This commit is contained in:
committed by
Aaron Bohy
co-authored by
Aaron Bohy
Christophe Matthieu
Mathieu Duckerts-Antoine
David Monjoie
Martin Geubelle
svs-odoo
parent
f414c9f3f8
commit
5f3b5f0a9d
@@ -16,7 +16,6 @@ gui.Gui.include({
|
||||
select_employee: function(options) {
|
||||
options = options || {};
|
||||
var self = this;
|
||||
var def = new $.Deferred();
|
||||
|
||||
var list = [];
|
||||
this.pos.employees.forEach(function(employee) {
|
||||
@@ -28,15 +27,19 @@ gui.Gui.include({
|
||||
}
|
||||
});
|
||||
|
||||
this.show_popup('selection', {
|
||||
title: options.title || _t('Select User'),
|
||||
list: list,
|
||||
confirm: function(employee){ def.resolve(employee); },
|
||||
cancel: function(){ def.reject(); },
|
||||
is_selected: function(employee){ return employee === self.pos.get_cashier(); },
|
||||
var prom = new Promise(function (resolve, reject) {
|
||||
this.show_popup('selection', {
|
||||
title: options.title || _t('Select User'),
|
||||
list: list,
|
||||
confirm: resolve,
|
||||
cancel: reject,
|
||||
is_selected: function (employee) {
|
||||
return employee === self.pos.get_cashier();
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
return def.then(function(employee){
|
||||
return prom.then(function (employee) {
|
||||
return self.ask_password(employee.pin).then(function(){
|
||||
return employee;
|
||||
});
|
||||
@@ -44,27 +47,28 @@ gui.Gui.include({
|
||||
},
|
||||
// Ask for a password, and checks if it this
|
||||
// the same as specified by the function call.
|
||||
// returns a deferred that resolves on success,
|
||||
// Returns a promise that resolves on success,
|
||||
// fails on failure.
|
||||
ask_password: function(password) {
|
||||
var self = this;
|
||||
var ret = new $.Deferred();
|
||||
if (password) {
|
||||
this.show_popup('password',{
|
||||
'title': _t('Password ?'),
|
||||
confirm: function(pw) {
|
||||
if (pw !== password) {
|
||||
self.show_popup('error',_t('Incorrect Password'));
|
||||
ret.reject();
|
||||
} else {
|
||||
ret.resolve();
|
||||
}
|
||||
},
|
||||
});
|
||||
} else {
|
||||
ret.resolve();
|
||||
}
|
||||
return ret;
|
||||
var prom = new Promise(function (resolve, reject) {
|
||||
if (password) {
|
||||
self.show_popup('password',{
|
||||
'title': _t('Password ?'),
|
||||
confirm: function (pw) {
|
||||
if (pw !== password) {
|
||||
self.show_popup('error', _t('Incorrect Password'));
|
||||
reject();
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
});
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
return prom;
|
||||
},
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user