如何在Odoo的create方法中在chatter中发布消息?

时间:2023-01-31 20:23:40

I was writing create method for my own custom module.

我正在为自己的自定义模块编写create方法。

def create(self, cr, uid,ids, context=None):
        self.message_post(cr, uid, ids, body=_("Form Page created"), context=None)

but i am getting the following error when saving AssertionError: Invalid thread_id; should be 0, False, an ID or a list with one ID

但是在保存AssertionError时出现以下错误:无效的thread_id;应为0,False,ID或具有一个ID的列表

or sometimes

或者有时候

TypeError: create() got multiple values for keyword argument 'context'

TypeError:create()为关键字参数'context'获取了多个值

i just want to post a message when it is created

我只想在创建消息时发布消息

1 个解决方案

#1


2  

Openerp 7 Create Method

Openerp 7创建方法

def create(self, cr, uid, vals, context=None):
     new_id = super(CRM_Lead, self).create(cr, uid, vals, context=context)
     return new_id

odoo 8 Create Method:

odoo 8创建方法:

class ClassName(models.Model): _inherit = "model.name"

class ClassName(models.Model):_ inherit =“model.name”

@api.model
def create(self, vals):
    rec = super(ClassName, self).create(vals)
    # ...        
    return rec

Make sure you use the exact name of the python class in the super function and also that you return the same object you get from it.

确保在超级函数中使用python类的确切名称,并且还返回从中获取的相同对象。

Track Visibility

跟踪可见性

You can set a mail.message.subtype that depends on an other to act through a relation field.

您可以设置依赖于其他人的mail.message.subtype来通过关系字段进行操作。

For better understanding track visibilty Refer This Link

为了更好地理解跟踪可见性,请参阅此链接

There is two type fileds of track visibility

轨道可见性有两种类型

track_visibility='always' 
track_visibility='onchange' 

#1


2  

Openerp 7 Create Method

Openerp 7创建方法

def create(self, cr, uid, vals, context=None):
     new_id = super(CRM_Lead, self).create(cr, uid, vals, context=context)
     return new_id

odoo 8 Create Method:

odoo 8创建方法:

class ClassName(models.Model): _inherit = "model.name"

class ClassName(models.Model):_ inherit =“model.name”

@api.model
def create(self, vals):
    rec = super(ClassName, self).create(vals)
    # ...        
    return rec

Make sure you use the exact name of the python class in the super function and also that you return the same object you get from it.

确保在超级函数中使用python类的确切名称,并且还返回从中获取的相同对象。

Track Visibility

跟踪可见性

You can set a mail.message.subtype that depends on an other to act through a relation field.

您可以设置依赖于其他人的mail.message.subtype来通过关系字段进行操作。

For better understanding track visibilty Refer This Link

为了更好地理解跟踪可见性,请参阅此链接

There is two type fileds of track visibility

轨道可见性有两种类型

track_visibility='always' 
track_visibility='onchange'