Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyectos
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

odoo 12 custom pos lock screen module this.pos is null

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
point_of_saleodoo12
4819 Vistas
Avatar
akram sahbi

Hello, i made a module for odoo 12 to lock the pos screen. in the models.js, i want to switch the orders of different cashiers but this.pos is not initialized, what should i do so that it becomes initialized?
here is my code:

odoo.define('pos_user_lock.models',

//['point_of_sale.models','point_of_sale.screens','point_of_sale.chrome'

//,'web.ajax','web.core'], 

function (require) {

"use strict";


var ajax = require('web.ajax');

var screens = require('point_of_sale.screens');

var models = require('point_of_sale.models');

var chrome = require('point_of_sale.chrome');

var core = require('web.core');

var QWeb = core.qweb;

var _t = core._t;





models.Order = models.Order.extend({

    initialize: function(attributes,options){

        var order =  models.Order.__super__.initialize.call(this,attributes,options);

        if (!this.cashier)

        {

            this.cashier = this.pos.cashier || this.pos.user;

        }

        

        

        this.is_last_selected = (this.is_last_selected === undefined) ? false:this.is_last_selected;

        return order;

    },

    finalize: function() {

        var res =  models.Order.__super__.finalize.call(this);

        this.pos.lock_user_screen();

    },

    init_from_JSON: function(json) {

        var user = this.get_user_by_id(json.user_id);

        if (user)

            this.cashier = user;

        this.is_last_selected = json.is_last_selected;

        models.Order.__super__.init_from_JSON.call(this, json);

    },

    export_as_JSON: function() {

        var res =  models.Order.__super__.export_as_JSON.call(this);

        if (this.cashier)

            res.user_id = this.cashier.id ;

        if(this.pos && this.pos.get_cashier())

            res.user_id = this.pos.get_cashier().id ;

        res.is_last_selected = this.is_last_selected;

        return res;

    },

    get_user_by_id: function(id) {

        var users = this.pos.users;

        for (var i = 0; i < users.length; i++) {

            var user = users[i];

            if (user.id == id)

                return user;

        }

    },


});


models.PosModel = models.PosModel.extend({

    initialize: function(session, attributes) {

        models.PosModel.__super__.initialize.call(this, session, attributes);

        

        var self = this;

        alert(JSON.stringify(attributes.pos));

        this.ready.then(function(){

            if (self.config.auto_push_order)

                self.config.iface_precompute_cash = true;

        });

    },

    is_locked: function(){

        if (

            this.gui.current_popup 

            && this.gui.current_popup.template == 'PasswordPinPopupWidget'

        ){

            return true;

        }

        return false;

    },

    unlock: function(){

        if (this.is_locked()){

            this.gui.close_popup();

        }

    },

    lock_user_screen: function(){

        var self = this;

        if (!this.config.lock_users) return;

        this.gui.show_popup('passwordPin',{

            'title': _t('Insert password or scan your barcode'),

        });

    },

    get_last_order: function(){

        var orders = this.get_order_list();

        for (var i = 0; i < orders.length; i++) {

            if (orders[i].is_last_selected) {

                return orders[i];

            }

        }

        return null;

    },

    set_last_order: function(order){

        var orders = this.get_order_list();

        for (var i = 0; i < orders.length; i++) {

            if (orders[i].uid == order.uid) {

                orders[i].is_last_selected = true;

            }else{

                orders[i].is_last_selected = false;

            }

        }

        return null;

    },

    set_order: function(order){

        models.PosModel.__super__.set_order.call(this, order);

        this.set_last_order(order);

    },

    get_order_list: function(){

        var orders = models.PosModel.__super__.get_order_list.call(this);

        var c_orders = [];

        var cashier = this.cashier || this.user;

        for (var i = 0; i < orders.length; i++) {

            if (cashier && orders[i].cashier.id === cashier.id) {

                c_orders.push(orders[i]);

            }

        }

        return c_orders;

    },

    switch_order: function(){

        var self = this;

        if(self.pos)

        {

        }

        else

        {

            alert("self.pos is null");

        }

        if(self !== undefined && self != null && self.pos !== undefined && self.pos.currency != null)

        {

            alert("in switch order");

            //console.log(this.pos.currency);

                if (!self.config.lock_users) return;

                var user = self.pos.get_cashier() || self.user;

                

                var orders = self.get_order_list();

                

                var last_order = self.get_last_order() || orders[0];

                

                if (orders.length) {

                    

                    self.set_order(last_order);

                    

                } 

                else {

                    

                    self.add_new_order();

                    

                }

                        

        }

        

    },

    set_cashier: function(user){

        models.PosModel.__super__.set_cashier.call(this,user);

        if(this.pos)

        {

            alert("this.pos is not null in set_cashier");

        }

        else

        {

            alert("this.pos is null in set_cashier");

        }

        this.switch_order(this);

        if (!this.table && this.config.iface_floorplan)

            this.set_table(null);

    },



});

return models;


});

0
Avatar
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
"AttributeError: 'bool' object has no attribute 'date'" when trying to access the point of sale module. Resuelto
bugs point_of_sale odoo12
Avatar
Avatar
2
may 23
11916
Why POS is making this error?
js point_of_sale odoo12
Avatar
0
jun 22
2510
Point of sale access error
point_of_sale ErrorTraceback odoo12
Avatar
2
jun 20
4354
Point of sale access error
point_of_sale access_error odoo12
Avatar
0
jun 20
3188
Configuring Advanced Rights to Hide 'Cost' on POS Screen for Employees
point_of_sale
Avatar
Avatar
1
jul 25
2688
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now