Skip to Content
Menu
This question has been flagged
3 Replies
6765 Views

Hello! I have a problem with 'self'.  When i try to sent message to user i recive this eror

сту 20 12:49:38 PK systemd[1]: Started Odoo12.
сту 20 12:49:39 PK odoo12[24014]: 2019-01-20 09:49:39,277 24014 INFO ? odoo: Odoo version 12.0
сту 20 12:49:39 PK odoo12[24014]: 2019-01-20 09:49:39,279 24014 INFO ? odoo: Using configuration file at /etc/odoo12.conf
сту 20 12:49:39 PK odoo12[24014]: 2019-01-20 09:49:39,279 24014 INFO ? odoo: addons paths: ['/opt/odoo12/.local/share/Odoo/addons/12.0', '/opt/odoo12/odoo/addons', '/opt/odoo12/odoo-custom-addons', '/opt/odo
сту 20 12:49:39 PK odoo12[24014]: 2019-01-20 09:49:39,280 24014 INFO ? odoo: database: odoo12@default:default
сту 20 12:49:39 PK odoo12[24014]: 2019-01-20 09:49:39,527 24014 INFO ? odoo.addons.base.models.ir_actions_report: Will use the Wkhtmltopdf binary at /usr/local/bin/wkhtmltopdf
сту 20 12:49:39 PK odoo12[24014]: 2019-01-20 09:49:39,803 24014 INFO ? odoo.service.server: HTTP service (werkzeug) running on PK:8069
сту 20 12:50:51 PK odoo12[24014]: 2019-01-20 09:50:51,840 24014 INFO ? odoo.http: HTTP Configuring static files
сту 20 12:50:51 PK odoo12[24014]: 2019-01-20 09:50:51,856 24014 INFO ? odoo.http: Generating nondb routing
сту 20 12:50:51 PK odoo12[24014]: 2019-01-20 09:50:51,874 24014 INFO ? werkzeug: 127.0.0.1 - - [20/Jan/2019 09:50:51] "GET / HTTP/1.1" 200 - 1 0.001 0.033
сту 20 12:50:52 PK odoo12[24014]: 2019-01-20 09:50:52,450 24014 INFO ? werkzeug: 127.0.0.1 - - [20/Jan/2019 09:50:52] "GET /web HTTP/1.1" 303 - 2 0.002 0.006
сту 20 12:50:52 PK odoo12[24014]: 2019-01-20 09:50:52,687 24014 INFO ? werkzeug: 127.0.0.1 - - [20/Jan/2019 09:50:52] "GET /web/database/selector HTTP/1.1" 200 - 2 0.002 0.202
сту 20 12:51:14 PK odoo12[24014]: 2019-01-20 09:51:14,448 24014 INFO None odoo.service.db: Create database `odoo12`.
сту 20 12:51:16 PK odoo12[24014]: 2019-01-20 09:51:16,057 24014 INFO odoo12 odoo.modules.loading: loading 1 modules...
сту 20 12:51:16 PK odoo12[24014]: 2019-01-20 09:51:16,213 24014 INFO odoo12 odoo.modules.registry: module base: creating or updating database tables
сту 20 12:51:17 PK odoo12[24014]: 2019-01-20 09:51:17,838 24014 INFO odoo12 odoo.models: Storing computed values of ir.model.fields.relation_field_id
сту 20 12:51:17 PK odoo12[24014]: 2019-01-20 09:51:17,842 24014 INFO odoo12 odoo.models: Storing computed values of ir.model.fields.related_field_id
сту 20 12:51:18 PK odoo12[24014]: 2019-01-20 09:51:18,017 24014 INFO odoo12 odoo.models: Storing computed values of ir.actions.server.model_name
сту 20 12:51:18 PK odoo12[24014]: 2019-01-20 09:51:18,091 24014 INFO odoo12 odoo.models: Storing computed values of ir.attachment.res_name
сту 20 12:51:18 PK odoo12[24014]: 2019-01-20 09:51:18,092 24014 INFO odoo12 odoo.models: Storing computed values of ir.attachment.res_model_name
сту 20 12:51:18 PK odoo12[24014]: 2019-01-20 09:51:18,112 24014 INFO odoo12 odoo.models: Storing computed values of ir.cron.cron_name
сту 20 12:51:18 PK odoo12[24014]: 2019-01-20 09:51:18,217 24014 INFO odoo12 odoo.models: Storing computed values of ir.rule.global
сту 20 12:51:18 PK odoo12[24014]: 2019-01-20 09:51:18,473 24014 INFO odoo12 odoo.models: Storing computed values of ir.module.module.menus_by_module
сту 20 12:51:18 PK odoo12[24014]: 2019-01-20 09:51:18,475 24014 INFO odoo12 odoo.models: Storing computed values of ir.module.module.reports_by_module
сту 20 12:51:18 PK odoo12[24014]: 2019-01-20 09:51:18,479 24014 INFO odoo12 odoo.models: Storing computed values of ir.module.module.views_by_module
сту 20 12:51:18 PK odoo12[24014]: 2019-01-20 09:51:18,775 24014 INFO odoo12 odoo.models: Storing computed values of res.partner.display_name
сту 20 12:51:18 PK odoo12[24014]: 2019-01-20 09:51:18,814 24014 INFO odoo12 odoo.models: Storing computed values of res.partner.partner_share
сту 20 12:51:18 PK odoo12[24014]: 2019-01-20 09:51:18,819 24014 INFO odoo12 odoo.models: Storing computed values of res.partner.commercial_partner_id
сту 20 12:51:18 PK odoo12[24014]: 2019-01-20 09:51:18,821 24014 INFO odoo12 odoo.models: Storing computed values of res.partner.commercial_company_name
сту 20 12:51:18 PK odoo12[24014]: 2019-01-20 09:51:18,873 24014 INFO odoo12 odoo.models: Storing computed values of res.partner.bank.sanitized_acc_number
сту 20 12:51:18 PK odoo12[24014]: 2019-01-20 09:51:18,943 24014 INFO odoo12 odoo.models: Storing computed values of res.currency.decimal_places
сту 20 12:51:18 PK odoo12[24014]: 2019-01-20 09:51:18,989 24014 INFO odoo12 odoo.models: Storing computed values of res.company.logo_web
сту 20 12:51:19 PK odoo12[24014]: 2019-01-20 09:51:19,007 24014 INFO odoo12 odoo.models: Storing computed values of res.company.email
сту 20 12:51:19 PK odoo12[24014]: 2019-01-20 09:51:19,009 24014 INFO odoo12 odoo.models: Storing computed values of res.company.phone
сту 20 12:51:19 PK odoo12[24014]: 2019-01-20 09:51:19,096 24014 INFO odoo12 odoo.models: Storing computed values of res.users.share
сту 20 12:51:19 PK odoo12[24014]: 2019-01-20 09:51:19,863 24014 INFO odoo12 odoo.modules.loading: loading base/data/res.lang.csv
сту 20 12:51:20 PK odoo12[24014]: 2019-01-20 09:51:20,059 24014 INFO odoo12 odoo.modules.loading: loading base/data/res_lang_data.xml
сту 20 12:51:20 PK odoo12[24014]: 2019-01-20 09:51:20,104 24014 INFO odoo12 odoo.modules.loading: loading base/data/res_partner_data.xml
сту 20 12:51:20 PK odoo12[24014]: 2019-01-20 09:51:20,387 24014 INFO odoo12 odoo.modules.loading: loading base/data/res_company_data.xml
сту 20 12:51:20 PK odoo12[24014]: 2019-01-20 09:51:20,419 24014 INFO odoo12 odoo.modules.loading: loading base/data/res_users_data.xml
сту 20 12:51:20 PK odoo12[24014]: 2019-01-20 09:51:20,943 24014 INFO odoo12 odoo.modules.loading: loading base/data/report_paperformat_data.xml
сту 20 12:51:20 PK odoo12[24014]: 2019-01-20 09:51:20,961 24014 INFO odoo12 odoo.modules.loading: loading base/data/res_currency_data.xml
сту 20 12:51:22 PK odoo12[24014]: 2019-01-20 09:51:22,040 24014 INFO odoo12 odoo.modules.loading: loading base/data/res_country_data.xml
сту 20 12:51:26 PK odoo12[24014]: 2019-01-20 09:51:26,238 24014 INFO odoo12 odoo.modules.loading: loading base/data/ir_demo_data.xml
сту 20 12:51:26 PK odoo12[24014]: 2019-01-20 09:51:26,285 24014 INFO odoo12 odoo.modules.loading: loading base/security/base_groups.xml
сту 20 12:51:26 PK odoo12[24014]: 2019-01-20 09:51:26,626 24014 INFO odoo12 odoo.modules.loading: loading base/security/base_security.xml
сту 20 12:51:26 PK odoo12[24014]: 2019-01-20 09:51:26,937 24014 INFO odoo12 odoo.modules.loading: loading base/views/base_menus.xml
...skipping...
лют 04 09:44:44 PK odoo12[11405]:     execute(self.server.app)
лют 04 09:44:44 PK odoo12[11405]:   File "/opt/odoo12/odoo-venv/lib/python3.6/site-packages/werkzeug/serving.py", line 193, in execute
лют 04 09:44:44 PK odoo12[11405]:     application_iter = app(environ, start_response)
лют 04 09:44:44 PK odoo12[11405]:   File "/opt/odoo12/odoo/odoo/service/server.py", line 350, in app
лют 04 09:44:44 PK odoo12[11405]:     return self.app(e, s)
лют 04 09:44:44 PK odoo12[11405]:   File "/opt/odoo12/odoo/odoo/service/wsgi_server.py", line 128, in application
лют 04 09:44:44 PK odoo12[11405]:     return application_unproxied(environ, start_response)
лют 04 09:44:44 PK odoo12[11405]:   File "/opt/odoo12/odoo/odoo/service/wsgi_server.py", line 117, in application_unproxied
лют 04 09:44:44 PK odoo12[11405]:     result = odoo.http.root(environ, start_response)
лют 04 09:44:44 PK odoo12[11405]:   File "/opt/odoo12/odoo/odoo/http.py", line 1318, in __call__
лют 04 09:44:44 PK odoo12[11405]:     return self.dispatch(environ, start_response)
лют 04 09:44:44 PK odoo12[11405]:   File "/opt/odoo12/odoo/odoo/http.py", line 1291, in __call__
лют 04 09:44:44 PK odoo12[11405]:     return self.app(environ, start_wrapped)
лют 04 09:44:44 PK odoo12[11405]:   File "/opt/odoo12/odoo-venv/lib/python3.6/site-packages/werkzeug/wsgi.py", line 599, in __call__
лют 04 09:44:44 PK odoo12[11405]:     return self.app(environ, start_response)
лют 04 09:44:44 PK odoo12[11405]:   File "/opt/odoo12/odoo/odoo/http.py", line 1469, in dispatch
лют 04 09:44:44 PK odoo12[11405]:     odoo.registry(db).check_signaling()
лют 04 09:44:44 PK odoo12[11405]:   File "/opt/odoo12/odoo/odoo/__init__.py", line 81, in registry
лют 04 09:44:44 PK odoo12[11405]:     return modules.registry.Registry(database_name)
лют 04 09:44:44 PK odoo12[11405]:   File "/opt/odoo12/odoo/odoo/modules/registry.py", line 62, in __new__
лют 04 09:44:44 PK odoo12[11405]:     return cls.new(db_name)
лют 04 09:44:44 PK odoo12[11405]:   File "/opt/odoo12/odoo/odoo/modules/registry.py", line 86, in new
лют 04 09:44:44 PK odoo12[11405]:     odoo.modules.load_modules(registry._db, force_demo, status, update_module)
лют 04 09:44:44 PK odoo12[11405]:   File "/opt/odoo12/odoo/odoo/modules/loading.py", line 417, in load_modules
лют 04 09:44:44 PK odoo12[11405]:     force, status, report, loaded_modules, update_module, models_to_check)
лют 04 09:44:44 PK odoo12[11405]:   File "/opt/odoo12/odoo/odoo/modules/loading.py", line 313, in load_marked_modules
лют 04 09:44:44 PK odoo12[11405]:     perform_checks=perform_checks, models_to_check=models_to_check
лют 04 09:44:44 PK odoo12[11405]:   File "/opt/odoo12/odoo/odoo/modules/loading.py", line 179, in load_module_graph
лют 04 09:44:44 PK odoo12[11405]:     load_openerp_module(package.name)
лют 04 09:44:44 PK odoo12[11405]:   File "/opt/odoo12/odoo/odoo/modules/module.py", line 368, in load_openerp_module
лют 04 09:44:44 PK odoo12[11405]:     __import__('odoo.addons.' + module_name)
лют 04 09:44:44 PK odoo12[11405]:   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
лют 04 09:44:44 PK odoo12[11405]:     
лют 04 09:44:44 PK odoo12[11405]:   File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
лют 04 09:44:44 PK odoo12[11405]:     
лют 04 09:44:44 PK odoo12[11405]:   File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
лют 04 09:44:44 PK odoo12[11405]:     
лют 04 09:44:44 PK odoo12[11405]:   File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
лют 04 09:44:44 PK odoo12[11405]:     
лют 04 09:44:44 PK odoo12[11405]:   File "/opt/odoo12/odoo/odoo/modules/module.py", line 82, in load_module
лют 04 09:44:44 PK odoo12[11405]:     exec(open(modfile, 'rb').read(), new_mod.__dict__)
лют 04 09:44:44 PK odoo12[11405]:   File "<string>", line 11, in <module>
лют 04 09:44:44 PK odoo12[11405]:     
лют 04 09:44:44 PK odoo12[11405]:   File "/opt/odoo12/odoo-custom-addons/skype_bot/skype_model.py", line 11, in <module>
лют 04 09:44:44 PK odoo12[11405]:     class SkypeBot(models.Model):
лют 04 09:44:44 PK odoo12[11405]:   File "/opt/odoo12/odoo-custom-addons/skype_bot/skype_model.py", line 20, in SkypeBot
лют 04 09:44:44 PK odoo12[11405]:     self.message_subscribe_users(user_id=(2,))
лют 04 09:44:44 PK odoo12[11405]: NameError: name 'self' is not defined - - -


my code

import logging
from odoo import models, fields, api

_logger = logging.getLogger(__name__)



class SkypeBot(models.Model):
_name = 'my.skype'
_inherit = ['mail.thread', 'mail.activity']
_description = 'My Skype'
_logger.warning('$$$$'* 5 + "Init" + 5 * '$$$$')

# _logger.info('******' * 10)
# _logger.warning(self)
# _logger.info('******' * 10)
self.message_subscribe_users(user_id=(2,))
self.message_post('Hello')
self.message_post('Hello Adgain!', subject='Hello', subtype='mail.mt_comment')


what am I doing wrong? 

i have try to make function for sending  message like it :


@api.model

def send_message(self, message):
self.ensure_one()
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
})




but when i try to call it i recive missing 1 argument 'self'
What should I do in order for self to become a necessary part of the code and I could send a message to the user
Avatar
Discard
Author

for subbarao: yes, i have upgraded my module after code changed

Author

for odoo tools: i just try to use @api.multi but it didn't help me

Best Answer

Hi,

you use the decorator @api.model. In this decorator ids is not defined as params. Thus, self.ensure_one() doesn't make any sense.

Try to use the decorator @api.multi.


Besides, have a look at the method message_post of mail.thread. Although it doesn't relate to to your question, I guess, it might be of help for you. It seems more rational to use ready ORM method instead of creating message manually.

Avatar
Discard
Best Answer

Hello,

Have you upgrade the module after code change

Avatar
Discard
Related Posts Replies Views Activity
0
Mar 24
275
0
Oct 22
1521
0
Sep 22
666
1
Jul 22
4090
0
Jun 22
836