Files
odoo_source/addons/mail/populate/mail_message.py
T
Sébastien Theys 90cb44e1e1 [REF] mail, *: rename mail.channel to discuss.channel
* = bus, calendar, crm_livechat, hr, hr_holidays, im_livechat, mail_bot,
    mass_mailing, privacy_lookup, test_discuss_full, test_mail,
    test_mail_full, website_crm_livechat, website_livechat, base

In preparation of splitting discuss and mail modules.

Part of task-3265211

closes odoo/odoo#118354

Related: odoo/upgrade#4553
Related: odoo/enterprise#39661
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-04-21 02:21:53 +02:00

24 lines
1018 B
Python

# -*- coding: utf-8 -*-
from odoo import models
from odoo.tools import populate
class Message(models.Model):
_inherit = 'mail.message'
_populate_dependencies = ['discuss.channel', 'discuss.channel.member', 'res.partner']
_populate_sizes = {'small': 1000, 'medium': 10000, 'large': 500000}
def _populate_factories(self):
channel_ids = self.env.registry.populated_models['discuss.channel']
def get_author_id(values, counter, random):
channel = self.env[values['model']].browse(values['res_id'])
channel_member_ids = [channel['id'] for channel in channel.channel_member_ids.read(['id'])]
return random.choice(channel_member_ids)
return [
('body', populate.constant('message_body_{counter}')),
('message_type', populate.constant('comment')), ('model', populate.constant('discuss.channel')),
('res_id', populate.randomize(channel_ids)),
('author_id', populate.compute(get_author_id)),
]