Skip to content

Commit

Permalink
[ADD] simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
legalsylvain committed Sep 25, 2018
1 parent 43eca98 commit 3defe39
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions addons/l10n_fr_pos_cert/static/src/js/l10n_fr_pos_cert.js
Expand Up @@ -137,29 +137,26 @@ odoo.define('l10n_fr_pos_cert.models', function (require) {
}

return PosModelParent._save_to_server.apply(this, arguments).then(function(server_ids) {
if (server_ids) {
if (server_ids.length > 0){
// Try to get hash of saved orders, if required
var posOrderModel = new DataModel('pos.order');
return posOrderModel.call(
'get_certification_information', [server_ids], false
).then(function (results) {
var hash = false;
_.each(results, function(result){
if (result.pos_reference.indexOf(current_order.uid) > 0) {
hash = result.l10n_fr_hash;
current_order.set_hash(hash, setting);
}
});
certification_deferred.resolve(hash);
return server_ids;
}).fail(function (error, event){
certification_deferred.reject();
return server_ids;
if (server_ids.length) {
// Try to get hash of saved orders, if required
var posOrderModel = new DataModel('pos.order');
return posOrderModel.call(
'get_certification_information', [server_ids], false
).then(function (results) {
var hash = false;
_.each(results, function(result){
if (result.pos_reference.indexOf(current_order.uid) > 0) {
hash = result.l10n_fr_hash;
current_order.set_hash(hash, setting);
return server_ids;
}
});
}
certification_deferred.resolve(false);
return server_ids;
certification_deferred.resolve(hash);
return server_ids;
}).fail(function (error, event){
certification_deferred.reject();
return server_ids;
});
}
certification_deferred.reject();
}, function error() {
Expand Down

0 comments on commit 3defe39

Please sign in to comment.