Trợ giúp


Problem with Javascript

Christian Mepat

I have a piece of code that works in an instance of Odoo 11 and not in another.

In fact in POS, when the user wants to disconnect from the interface,  I check if there is one order in localstorage. And the rest of the behaviour depends on it.

Please any solution ?

see code below

var rpc = require('web.rpc');
var chrome = require('');

renderElement: function(){
var self = this;

function get_current_session(){
var current_session = 0;
return current_session;
function checkOrdersInLocalstorage(){
var local_storage = window.localStorage;
var keys = [];
for (var key in local_storage) keys.push(key)
var key_ = ""
for(var i=0; i<keys.length; i++){
if (keys[i].includes('orders') && !keys[i]\
                                    key_ = keys[i];}}

var list_empty = true;
if(key_ != ""){
var tmp = local_storage[key_];
var ordersList = tmp.split('[');
if(ordersList.length > 2){
list_empty = false;
return list_empty;

                // On vérifie si la liste n'est pas vide

self.gui.show_popup('error', {
'title': _t('Erreur de conformité'),
'body': _t('Veuillez vous rassurer que
vous navez pas de commande en attente!\n\nSi le problème persiste
veuillez contacter votre administrateur!'),

else {

rpc.query({//Appel de la méthode sur le serveur
model: 'pos.session',
method: 'set_field_can_be_closed',
args: [[], get_current_session()]
return true;

Ảnh đại diện
Huỷ bỏ