[IMP] add record_id on mail.message to be able to access to the record

This commit is contained in:
Sébastien BEAU
2019-01-11 10:56:31 +01:00
parent fc45c44280
commit a2564f48a3
2 changed files with 19 additions and 0 deletions

View File

@@ -3,3 +3,4 @@
from . import mail
from . import tools
from . import mail_template
from . import mail_message

View File

@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Akretion (http://www.akretion.com).
# @author Sébastien BEAU <sebastien.beau@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp import api, fields, models
class MailMessage(models.Model):
_inherit = 'mail.message'
@property
def record_id(self):
# we do not use a reference field here as mail message
# are used everywhere and many model are not yet loaded
# so odoo raise exception
self.ensure_one()
return self.env[self.model].browse(self.res_id)