Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

How to include some functions in PosModel?

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
javascriptposinheritancejssurrogate
1 Répondre
8600 Vues
Avatar
Anabela Damas

Hi,

 I want to add some features to POS but I'm not familiar to js. 

So for PaymentScreenWidget I was able to add some new functions and to change others, like this :

function openerp_vi_pos_print_invoice(instance, module){
var QWeb = instance.web.qweb;
var _t = instance.web._t;
console.log('print_');
console.log(module);
module.PaymentScreenWidget.include({
init: function(parent, options) {
var self = this;
this._super(parent,options);
//console.log('Init!!!!');
},
show: function(){
this._super();
var self = this;
this.add_action_button({
label: _t('Print Inv.'),
name: 'b_invoice',
icon: '/vi_pos/static/src/img/icons/print.png',
click: function(){
self.print_invoice_func({invoice_vi: true, invoice:true});
},
});
this.update_payment_summary();
},
print_invoice_func: function(options) {
var self = this;
options = options || {};
var currentOrder = this.pos.get('selectedOrder');
//console.log(options.invoice_vi && options.invoice);
if (options.invoice_vi && options.invoice) {
self.validate_order({invoice: options.invoice, invoice_vi:options.invoice_vi});
}
},
update_payment_summary: function() {
this._super();
if(this.pos_widget.action_bar){
this.pos_widget.action_bar.set_button_disabled('b_invoice', !this.is_paid());
}
},
 });
}


But when I tried to the same to PosModel:

function openerp_vi_pos_models(instance, module){ //module is instance.point_of_sale
var QWeb = instance.web.qweb;
var _t = instance.web._t;
module.PosModel.include({

new_func: function(order){
var self = this;
var invoiced = new $.Deferred();
if(!order.get_client()){
invoiced.reject('error-no-client');
return invoiced;
}
var order_id = this.db.add_order(order.export_as_JSON());
            ....
             ....
},
});
}


I get an error Uncaught TypeError: module.PosModel.include is not a function

So I print the variable module through console.log(module); and I notice that "PaymentScreenWidget" it has defined the include function and the "prototype" is Class and in PosModel we don't have the function include and the prototype is Surrogate.

If I don't have the include function how do I add a function to PosModel?

Thanks 



0
Avatar
Ignorer
Avatar
Axel Mendoza
Meilleure réponse

Please refers to this answers for examples of how to do it for get your code called:

https://www.odoo.com/forum/help-1/question/how-to-modify-the-behavior-of-the-enter-key-in-the-pos-interface-93881#answer_93884

https://www.odoo.com/forum/help-1/question/how-to-choose-different-pos-xml-according-to-login-user-or-company-81025#answer_91974

Also notice that module.PosModel is a Backbone Model so it don't have include like the rest of Odoo classes, try to extending using the Backbone set function or directly manipulating the object prototype, as Backbone docs says it's ok to do it

0
Avatar
Ignorer
Anabela Damas
Auteur

The links that you gave are all related to module.PaymentScreenWidget.include, in this case I know how to do it... I just don't know how to do it for PosModel...

Axel Mendoza

What I try to show you is that maybe you need to change the file declaration to get your code called by Odoo

Axel Mendoza

I update my answer with other tips

Axel Mendoza

if you solve it, please share the results so others could find it useful

Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Inheriting NumberBuffercof pos to add 1000; 5000;10000 in PaymentScreen Résolu
javascript pos inheritance
Avatar
Avatar
Avatar
2
juil. 24
3359
Trouble Importing JavaScript Between Custom Odoo Modules
javascript inheritance js
Avatar
0
mai 24
3323
inheritance of PosModel in POS models.js file Résolu
pos inheritance js
Avatar
Avatar
Avatar
Avatar
5
sept. 20
33954
What Javascript code is required to open POS cash box (No POSBOX)? v12
javascript pos js cashbox
Avatar
0
août 19
7823
Proper JS Object Import in Odoo v16: Modifying Visibility in POS Popup
javascript pos js Point Of Sale odoo16features
Avatar
Avatar
1
déc. 23
3003
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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