You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
555 B

  1. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  2. from odoo import api, models
  3. class ResPartner(models.Model):
  4. _inherit = 'res.partner'
  5. @api.returns('self', lambda value: value.id)
  6. def message_post(self, *args, **kwargs):
  7. """Change user who is posting the message if set by context."""
  8. if self.env.context.get('message_post_user'):
  9. obj = self.sudo(self.env.context['message_post_user'])
  10. else:
  11. obj = self
  12. return super(ResPartner, obj).message_post(*args, **kwargs)