Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • होटल
    रियल एस्टेट
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    कंसल्टिंग
    • अकाउंटिंग फ़र्म
    • Odoo पार्टनर
    • मार्केटिंग एजेंसी
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • टेक्सटाइल
    • Metal
    • फ़र्नीचर
    • फ़ूड
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    अन्य
    • Nonprofit Organization
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    Browse all Industries
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • Odoo के ऑफ़िस में आएं
    सॉफ़्टवेयर पाएं
    • डाउनलोड
    • वर्शन की तुलना करें
    • रिलीज़
    साथ मिलकर काम करें
    • Github
    • फ़ोरम
    • इवेंट
    • अनुवाद
    • पार्टनर बनें
    • Services for Partners
    • अपना अकाउंटिंग फ़र्म रजिस्टर करें
    सेवाएं पाएं
    • पार्टनर ढूंढें
    • अकाउंटेंट खोजें
    • सलाहकार की मदद लें
    • इम्प्लिमेंटेशन सेवाएं
    • कस्टमर रेफ़रेंस
    • सहायता
    • अपग्रेड
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    डेमो देखें
  • कीमत
  • सहायता

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

  • सीआरएम
  • e-Commerce
  • लेखांकन
  • इन्वेंटरी
  • PoS
  • प्रोजेक्ट
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
Help

How to call function with self and many arguments from another class

Subscribe

Get notified when there's activity on this post

This question has been flagged
selfapi.multiodoo12
8 Replies
13905 Views
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
Discard
Andrei Kuchuk
Author

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
Author

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
Author

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

Andrei Kuchuk
Author

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

Avatar
Ibrahim Boudmir
Best Answer

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
Discard
Avatar
Andrei Kuchuk
Author Best Answer
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
Discard
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
Author

could you tell me more precisely what i need to print

Ibrahim Boudmir

print(skype_bot)

Andrei Kuchuk
Author

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
Author

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

Avatar
Caret IT Solutions Pvt. Ltd.
Best Answer

Hi,

Call method with self.send_message(message)

-1
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

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

Sign up
Related Posts Replies Views Activity
How to Pass Current ID to Wizard form in Odoo 12cc? Solved
wizard account.move self odoo12
Avatar
Avatar
1
जून 19
9444
Odoo Mail Sending Limit Solved
odoo12
Avatar
Avatar
Avatar
2
दिस॰ 23
16614
(Document type: Invoice, Operation: write) - (Records: [], User: 2)
odoo12
Avatar
0
अक्तू॰ 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
अक्तू॰ 23
790
Remove duplicate record when importing data from excel to Odoo
odoo12
Avatar
Avatar
1
अक्तू॰ 23
569
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة 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, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

Odoo की सबसे बड़ी खासियत है कि यह इस्तेमाल करने में बहुत आसान है और यह पूरी तरह से इंटिग्रेट किया हुआ है.

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