Python 如何设置';电子邮件';在author\u id中,继承Odoo上的mail.thread
我在Odoo12上继承了Python 如何设置';电子邮件';在author\u id中,继承Odoo上的mail.thread,python,odoo,message,Python,Odoo,Message,我在Odoo12上继承了mail.thread _inherit = ['mail.thread', 'mail.activity.mixin'] 并发布一条消息: msg = 'message test.' self.message_post(body=msg, email_from='Otro <otro@otro.com>', subtype='mail.mt_comment',) msg='messagetest' self.message\u post(body=msg
mail.thread
_inherit = ['mail.thread', 'mail.activity.mixin']
并发布一条消息:
msg = 'message test.'
self.message_post(body=msg, email_from='Otro <otro@otro.com>', subtype='mail.mt_comment',)
msg='messagetest'
self.message\u post(body=msg,email\u from='Otro',subtype='mail.mt\u comment',)
这些消息与管理员用户一起添加。如何将发送邮件的外部用户的邮件放置在字段
作者id
?尝试自我邮件发布(body=msg,email\u from='Otro',subtype='mail.mt\u comment',author\u id=False)
author\u id=False
将告诉Odoo以作者身份使用来自的电子邮件
我在这里找到了“窍门”:
author\u id=kwargs.get('author\u id'))
如果author_id为None:#保留假值
author\u id=self.env['mail.message']。\u获取\u默认\u author().id
半有价值的评论#保留假值
解决了大秘密;-)
使用None
时,将使用当前环境的用户。能否提供相关代码?您可以在任何地方使用sudo()
,这将环境用户更改为admin。您没有为message\u post()
提供作者id
,这将使Odoo将环境用户作为作者。@CZoellner问题在于,如何设置作者id=other@otro.com' ... 据我所知,author\u id需要一个id,但此消息的作者不在odoo数据库中。请尝试self.message\u post(body=msg,email\u from='Otro',subtype='mail.mt\u comment',author\u id=False)
@CZoellner。。。哦,谢谢!行得通