Pular para o conteúdo
Odoo Menu
  • Entrar
  • Experimente grátis
  • Aplicativos
    Finanças
    • Financeiro
    • Faturamento
    • Despesas
    • Planilhas (BI)
    • Documentos
    • Assinar Documentos
    Vendas
    • CRM
    • Vendas
    • PDV Loja
    • PDV Restaurantes
    • Assinaturas
    • Locação
    Websites
    • Criador de Sites
    • e-Commerce
    • Blog
    • Fórum
    • Chat ao Vivo
    • e-Learning
    Cadeia de mantimentos
    • Inventário
    • Fabricação
    • PLM - Ciclo de Vida do Produto
    • Compras
    • Manutenção
    • Qualidade
    Recursos Humanos
    • Funcionários
    • Recrutamento
    • Folgas
    • Avaliações
    • Indicações
    • Frota
    Marketing
    • Redes Sociais
    • Marketing por E-mail
    • Marketing por SMS
    • Eventos
    • Automação de Marketing
    • Pesquisas
    Serviços
    • Projeto
    • Planilhas de Horas
    • Serviço de Campo
    • Central de Ajuda
    • Planejamento
    • Compromissos
    Produtividade
    • Mensagens
    • Aprovações
    • Internet das Coisas
    • VoIP
    • Conhecimento
    • WhatsApp
    Aplicativos de terceiros Odoo Studio Plataforma Odoo Cloud
  • Setores
    Varejo
    • Loja de livros
    • Loja de roupas
    • Loja de móveis
    • Mercearia
    • Loja de ferramentas
    • Loja de brinquedos
    Comida e hospitalidade
    • Bar e Pub
    • Restaurante
    • Fast Food
    • Hospedagem
    • Distribuidor de bebidas
    • Hotel
    Imóveis
    • Imobiliária
    • Escritório de arquitetura
    • Construção
    • Administração de propriedades
    • Jardinagem
    • Associação de proprietários de imóveis
    Consultoria
    • Escritório de Contabilidade
    • Parceiro Odoo
    • Agência de marketing
    • Escritório de advocacia
    • Aquisição de talentos
    • Auditoria e Certificação
    Fabricação
    • Têxtil
    • Metal
    • Móveis
    • Alimentação
    • Cervejaria
    • Presentes corporativos
    Saúde e Boa forma
    • Clube esportivo
    • Loja de óculos
    • Academia
    • Profissionais de bem-estar
    • Farmácia
    • Salão de cabeleireiro
    Comércio
    • Handyman
    • Hardware e Suporte de TI
    • Sistemas de energia solar
    • Sapataria
    • Serviços de limpeza
    • Serviços de climatização
    Outros
    • Organização sem fins lucrativos
    • Agência Ambiental
    • Aluguel de outdoors
    • Fotografia
    • Aluguel de bicicletas
    • Revendedor de software
    Navegar por todos os setores
  • Comunidade
    Aprenda
    • Tutoriais
    • Documentação
    • Certificações
    • Treinamento
    • Blog
    • Podcast
    Empodere a Educação
    • Programa de educação
    • Scale Up! Jogo de Negócios
    • Visite a Odoo
    Obtenha o Software
    • Baixar
    • Comparar edições
    • Releases
    Colaborar
    • Github
    • Fórum
    • Eventos
    • Traduções
    • Torne-se um parceiro
    • Serviços para parceiros
    • Cadastre seu escritório contábil
    Obtenha os serviços
    • Encontre um parceiro
    • Encontre um Contador
    • Conheça um consultor
    • Serviços de Implementação
    • Referências de Clientes
    • Suporte
    • Upgrades
    Github YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Faça uma demonstração
  • Preços
  • Ajuda

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

  • CRM
  • e-Commerce
  • Financeiro
  • Inventário
  • PoS
  • Projeto
  • MRP
All apps
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
Ajuda

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

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
point_of_saleodoo12
4856 Visualizações
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
Cancelar
Está gostando da discussão? Não fique apenas lendo, participe!

Crie uma conta hoje mesmo para aproveitar os recursos exclusivos e interagir com nossa incrível comunidade!

Inscreva-se
Publicações relacionadas Respostas Visualizações Atividade
"AttributeError: 'bool' object has no attribute 'date'" when trying to access the point of sale module. Resolvido
bugs point_of_sale odoo12
Avatar
Avatar
2
mai. 23
11948
Why POS is making this error?
js point_of_sale odoo12
Avatar
0
jun. 22
2517
Point of sale access error
point_of_sale ErrorTraceback odoo12
Avatar
2
jun. 20
4371
Point of sale access error
point_of_sale access_error odoo12
Avatar
0
jun. 20
3209
Configuring Advanced Rights to Hide 'Cost' on POS Screen for Employees
point_of_sale
Avatar
Avatar
1
jul. 25
2707
Comunidade
  • Tutoriais
  • Documentação
  • Fórum
Open Source
  • Baixar
  • Github
  • Runbot
  • Traduções
Serviços
  • Odoo.sh Hosting
  • Suporte
  • Upgrade
  • Desenvolvimentos personalizados
  • Educação
  • Encontre um Contador
  • Encontre um parceiro
  • Torne-se um parceiro
Sobre nós
  • Nossa empresa
  • Ativos da marca
  • Contato
  • Empregos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidade
  • Segurança
الْعَرَبيّة 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 é um conjunto de aplicativos de negócios em código aberto que cobre todas as necessidades de sua empresa: CRM, comércio eletrônico, contabilidade, estoque, ponto de venda, gerenciamento de projetos, etc.

A proposta de valor exclusiva Odoo é ser, ao mesmo tempo, muito fácil de usar e totalmente integrado.

Site feito com

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