[MOV] (mass_)mail(_ing): move 'model_is_thread' field to mail
This field will be used to remove low-level asserts using existence of 'message_post' on a given model instead of correctly checking the inheritance on mail.thread. This is going to increase a bit query counters but those queries should be fast and have no real impact on performances. Task-2088884 (Mail: Use editable computed stored fields in composer) Part-of: odoo/odoo#107356
This commit is contained in:
@@ -149,6 +149,7 @@ class MailComposer(models.TransientModel):
|
||||
composition_batch = fields.Boolean(
|
||||
'Batch composition', compute='_compute_composition_batch') # more than 1 record (raw source)
|
||||
model = fields.Char('Related Document Model')
|
||||
model_is_thread = fields.Boolean('Thread-Enabled', compute='_compute_model_is_thread')
|
||||
res_ids = fields.Text('Related Document IDs')
|
||||
res_domain = fields.Text('Active domain')
|
||||
res_domain_user_id = fields.Many2one(
|
||||
@@ -227,6 +228,13 @@ class MailComposer(models.TransientModel):
|
||||
res_ids = composer._evaluate_res_ids()
|
||||
composer.composition_batch = len(res_ids) > 1 if res_ids else False
|
||||
|
||||
@api.depends('model')
|
||||
def _compute_model_is_thread(self):
|
||||
""" Determine if model is thread enabled. """
|
||||
for composer in self:
|
||||
model = self.env['ir.model']._get(composer.model)
|
||||
composer.model_is_thread = model.is_mail_thread
|
||||
|
||||
@api.depends('subtype_id')
|
||||
def _compute_subtype_is_log(self):
|
||||
""" In comment mode, tells whether the subtype is a note. Subtype has
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
<field name="lang" invisible="1"/>
|
||||
<field name="mail_server_id" invisible="1"/>
|
||||
<field name="model" invisible="1"/>
|
||||
<field name="model_is_thread" invisible="1"/>
|
||||
<field name="parent_id" invisible="1"/>
|
||||
<field name="record_name" invisible="1"/>
|
||||
<field name="render_model" invisible="1"/>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class MailComposeMessage(models.TransientModel):
|
||||
@@ -11,13 +11,6 @@ class MailComposeMessage(models.TransientModel):
|
||||
campaign_id = fields.Many2one('utm.campaign', string='Mass Mailing Campaign', ondelete='set null')
|
||||
mass_mailing_name = fields.Char(string='Mass Mailing Name', help='If set, a mass mailing will be created so that you can track its results in the Email Marketing app.')
|
||||
mailing_list_ids = fields.Many2many('mailing.list', string='Mailing List')
|
||||
model_is_thread = fields.Boolean(compute='_compute_model_is_thread')
|
||||
|
||||
@api.depends('model')
|
||||
def _compute_model_is_thread(self):
|
||||
for composer in self:
|
||||
model = self.env['ir.model']._get(composer.model)
|
||||
composer.model_is_thread = model.is_mail_thread
|
||||
|
||||
def _action_send_mail(self, auto_commit=False):
|
||||
""" Override to generate the mass mailing in case only the name was
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
<field name="inherit_id" ref="mail.email_compose_message_wizard_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='auto_delete_keep_log']" position="after">
|
||||
<field name="model_is_thread" invisible="1"/>
|
||||
<field name="campaign_id" groups="mass_mailing.group_mass_mailing_campaign"
|
||||
attrs="{'invisible': ['|', ('composition_mode', '!=', 'mass_mail'), ('model_is_thread', '!=', True)]}"/>
|
||||
<field name="mass_mailing_name"
|
||||
|
||||
Reference in New Issue
Block a user