Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

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

Odoberať

Get notified when there's activity on this post

This question has been flagged
point_of_saleodoo12
4827 Zobrazenia
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
Zrušiť
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrácia
Related Posts Replies Zobrazenia Aktivita
"AttributeError: 'bool' object has no attribute 'date'" when trying to access the point of sale module. Solved
bugs point_of_sale odoo12
Avatar
Avatar
2
máj 23
11925
Why POS is making this error?
js point_of_sale odoo12
Avatar
0
jún 22
2511
Point of sale access error
point_of_sale ErrorTraceback odoo12
Avatar
2
jún 20
4356
Point of sale access error
point_of_sale access_error odoo12
Avatar
0
jún 20
3190
Configuring Advanced Rights to Hide 'Cost' on POS Screen for Employees
point_of_sale
Avatar
Avatar
1
júl 25
2691
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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