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 call function with self and many arguments from another class

S'inscrire

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

Cette question a été signalée
selfapi.multiodoo12
8 Réponses
13896 Vues
Avatar
Andrei Kuchuk

how to use the environment correctly, so that I can call the method sent_message and pass self as a recordset and the string "message". To avoid errors of lack of arguments
models.py

from odoo import models, fields, api
import logging
import skpy
import threading

_logger = logging.getLogger(__name__)
class skype_bot(models.AbstractModel):
_name ='my.skype'
_inherit =['mail.thread',]
_description ='My Skype'

    @api.multi
    def send_message(self, message):
_loger.info('==='*5)
partner_id = self.env['res.users'].search([('id','=',2)]).partner_id.id  self.env['mail.message'].create({'message_type':'notification','subtype': self.env.ref('mail.mt_comment').id,# subject type'body': message,'subject':'Message subject','partner_ids':[(4, partner_id),],# partner to whom you send notification})

classMySkype(skpy.SkypeEventLoop):
    def onEvent(self, event):
        if isinstance(event, skpy.SkypeNewMessageEvent):
  message =('New message from user {} at {}: \'{} \''.format(event.msg.userId,
event.msg.time.strftime('%H:%M dd. %d.%m.%Y'),
event.msg.content))
_logger.info('----'*5)
_logger.info(message)
_logger.info('----'*5)
skype_bot.send_message(message=message)

class MySkype(skpy.SkypeEventLoop) i start in thread from init.py, and when an event occurs, it should call skype_bot.send_message, but when it calling this fuc become an error missing 1 argument 'self'
init.py

sk = models.models.MySkype(user='', pwd='', autoAck=True)
thread = threading.Thread(target=sk.loop)
thread.start()
0
Avatar
Ignorer
Andrei Kuchuk
Auteur

if i use skype_bot.send_message(message) i get this

сту 25 13:23:55 PK odoo12[15652]: File "/opt/odoo12/odoo-custom-addons/skype_bot/models/models.py", line 42, in <module>

сту 25 13:23:55 PK odoo12[15652]: class MySkype(skpy.SkypeEventLoop):

сту 25 13:23:55 PK odoo12[15652]: File "/opt/odoo12/odoo-custom-addons/skype_bot/models/models.py", line 86, in MySkype

сту 25 13:23:55 PK odoo12[15652]: skype_bot.send_message(message)

сту 25 13:23:55 PK odoo12[15652]: TypeError: send_message() missing 1 required positional argument: 'message'

Andrei Kuchuk
Auteur

try to use recs as shown here https://www.linkedin.com/in/andrei-kuchuk-526412140/ it says me that model ha no method browes

Andrei Kuchuk
Auteur

sry wrong link https://www.odoo.com/documentation/12.0/reference/orm.html#environment

Andrei Kuchuk
Auteur

one person has told me that i need to initialize ODOO Environment, but i don't understand how to do it

Avatar
Ibrahim Boudmir
Meilleure réponse

Hi, 

I assume that skype_bot is an instance of my.skype object.
You only need to do this : skype_bot.send_message(message)

You can write back if this does not help.

0
Avatar
Ignorer
Avatar
Andrei Kuchuk
Auteur Meilleure réponse
if i use skype_bot.send_message(message) i get this
сту 25 13:23:55 PK odoo12[15652]:   File "/opt/odoo12/odoo-custom-addons/skype_bot/models/models.py", line 42, in <module>
сту 25 13:23:55 PK odoo12[15652]:     class MySkype(skpy.SkypeEventLoop):
сту 25 13:23:55 PK odoo12[15652]:   File "/opt/odoo12/odoo-custom-addons/skype_bot/models/models.py", line 86, in MySkype
сту 25 13:23:55 PK odoo12[15652]:     skype_bot.send_message(message)
сту 25 13:23:55 PK odoo12[15652]: TypeError: send_message() missing 1 required positional argument: 'message'
0
Avatar
Ignorer
Ibrahim Boudmir

Well then, i don't think skype_bot in an instance of the object my.skype

Can you print it and tell me the output ?

Andrei Kuchuk
Auteur

could you tell me more precisely what i need to print

Ibrahim Boudmir

print(skype_bot)

Andrei Kuchuk
Auteur

I print this code

_logger.info('================' * 10)

_logger.warning(print(skype_bot))

print(skype_bot)

_logger.warning(skype_bot)

_logger.info('================' * 10)

and get this

сту 25 14:40:54 PK odoo12[16879]: 2019-01-25 11:40:54,410 16879 INFO odoo12 odoo.addons.skype_bot.models.models: ==============================================

сту 25 14:40:54 PK odoo12[16879]: 2019-01-25 11:40:54,410 16879 WARNING odoo12 odoo.addons.skype_bot.models.models: None

сту 25 14:40:54 PK odoo12[16879]: 2019-01-25 11:40:54,410 16879 WARNING odoo12 odoo.addons.skype_bot.models.models: <class 'odoo.addons.skype_bot.models.models.skype_bot'>

сту 25 14:40:54 PK odoo12[16879]: 2019-01-25 11:40:54,411 16879 INFO odoo12 odoo.addons.skype_bot.models.models: =========================================================

Andrei Kuchuk
Auteur

i try to call func like: with api.Environment.manage(): , it's didn't help me too

Avatar
Caret IT Solutions Pvt. Ltd.
Meilleure réponse

Hi,

Call method with self.send_message(message)

-1
Avatar
Ignorer
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é
How to Pass Current ID to Wizard form in Odoo 12cc? Résolu
wizard account.move self odoo12
Avatar
Avatar
1
juin 19
9431
Odoo Mail Sending Limit Résolu
odoo12
Avatar
Avatar
Avatar
2
déc. 23
16568
(Document type: Invoice, Operation: write) - (Records: [], User: 2)
odoo12
Avatar
0
oct. 23
33
Error while importing data in Odoo12: An unknown issue occurred during import (possibly lost connection, data limit exceeded or memory limits exceeded)
odoo12
Avatar
Avatar
Avatar
Avatar
3
oct. 23
790
Remove duplicate record when importing data from excel to Odoo
odoo12
Avatar
Avatar
1
oct. 23
569
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