PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, July 11, 2022

[FIXED] How to set 'email' in author_id inherit mail.thread on Odoo

 July 11, 2022     message, odoo, python     No comments   

Issue

I inherit mail.thread on Odoo12

_inherit = ['mail.thread', 'mail.activity.mixin']

and publish a message:

msg = 'message test.'
self.message_post(body=msg, email_from='Otro <otro@otro.com>', subtype='mail.mt_comment',)

image

These messages are added with the administrator user. How can I place the mail of the external user who sends the message in the field author_id?


Solution

Try out self.message_post(body=msg, email_from='Otro <otro@otro.com>', subtype='mail.mt_comment', author_id=False)

author_id=False will tell Odoo to use the email_from as author.

I've found that "trick" here:

    author_id = kwargs.get('author_id')
    if author_id is None:  # keep False values
        author_id = self.env['mail.message']._get_default_author().id

The semi-valuable comment # keep False values solved the big secret ;-)

With None the user of the current environment would be used.



Answered By - CZoellner
Answer Checked By - Marilyn (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing