【发布时间】:2019-01-30 16:14:19
【问题描述】:
我继承了 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',)
这些消息是使用管理员用户添加的。如何将发送消息的外部用户的邮件放在字段author_id?
【问题讨论】:
-
能否提供周边代码?您可以在任何地方使用
sudo(),这会将环境用户更改为管理员。而且您没有为message_post()提供author_id,这将使Odoo 将环境用户作为作者。 -
@CZoellner 这就是问题所在,如何设置 author_id = 'other@otro.com' ...我的理解是 author_id 需要一个 id 但此消息的作者不在 odoo 数据库中.
-
试用
self.message_post(body=msg, email_from='Otro <otro@otro.com>', subtype='mail.mt_comment', author_id=False) -
@CZoellner ...哦,谢谢!有效