S
S
Sabrjkee2019-01-29 20:16:13
linux
Sabrjkee, 2019-01-29 20:16:13

How to initialize Environment in Odoo12?

I'm trying to run the code (below), but do not work out api how to connect environments to work them out?

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

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

    message = fields.Char()

    @api.multi
    @api.onchange('message')
    def send_message(self):
        _logger.info('................' * 10)
        _logger.warning(self)
        _logger.info('................' * 10)
        self.env['mail.message'].create({'message_type': 'notification',
                                         'subtype': self.env.ref('mail.mt_comment').id,  # subject type
                                         'body': skype_bot.message,
                                         'subject': 'Message subject',
                                         'partner_ids': [(4, partner_id), ],
                                         # partner to whom you send notification
                                         })

class MySkype(skpy.SkypeEventLoop):
    _logger.info('Init Skype Class')
    def onEvent(self, event):
        _logger.info('================' * 10)
        _logger.warning(skype_bot)
        _logger.warning(skype_bot.send_message)
        _logger.info('================' * 10)



    skype_bot.message = "test 123"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sabrjkee, 2019-04-10
@Sabrjkee

registry = odoo.modules.registry.Registry.new(DB_NAME)
CR = registry.cursor()
ENV = odoo.api.Environment(CR, UID, {})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question