[IMP] mass_mailing: hide name field on the mailing and always display subject
This commit hides the field "name" of the mailing.mailing model. Instead of having both fields "name" and "subject" on the form, "name" will only be visible in debug mode leaving only "subject" to be visible for other users. Indeed name is a more technical field used to create and find UTM source record back while subject is the real business field. This change implies that the name will now be set by default in the create method so that the UTMs keeps working as they were. The name will be constructed as follow: "subject create_date". If the admin decides to set the name himself, the name will not be set by default. Field is set in debug mode to allow its edition. In mass mailing sms subject field is made visible. The name field being only visible in debug mode now, the subject field had to be made visible in the mailing form of the mass_mailing_sms module. LINKS Task ID 2072130 (hide name on mass mailing) PR: #36935
This commit is contained in:
committed by
Thibault Delavallée
parent
99585eacfb
commit
1c614e34dc
@@ -10,6 +10,7 @@ import re
|
||||
import threading
|
||||
from ast import literal_eval
|
||||
from base64 import b64encode
|
||||
from datetime import datetime
|
||||
|
||||
from odoo import api, fields, models, tools, _, SUPERUSER_ID
|
||||
from odoo.exceptions import UserError
|
||||
@@ -229,24 +230,14 @@ class MassMailing(models.Model):
|
||||
if self.mailing_type == 'mail' and not self.medium_id:
|
||||
self.medium_id = self.env.ref('utm.utm_medium_email').id
|
||||
|
||||
@api.onchange('subject')
|
||||
def _onchange_subject(self):
|
||||
if self.subject and not self.name:
|
||||
self.name = self.subject
|
||||
|
||||
@api.onchange('name')
|
||||
def _onchange_name(self):
|
||||
if self.name and not self.subject:
|
||||
self.subject = self.name
|
||||
|
||||
# ------------------------------------------------------
|
||||
# ORM
|
||||
# ------------------------------------------------------
|
||||
|
||||
@api.model
|
||||
def create(self, values):
|
||||
if values.get('name') and not values.get('subject'):
|
||||
values['subject'] = values['name']
|
||||
if values.get('subject') and not values.get('name'):
|
||||
values['name'] = "%s %s" % (values['subject'], datetime.strftime(fields.datetime.now(), tools.DEFAULT_SERVER_DATETIME_FORMAT))
|
||||
if values.get('body_html'):
|
||||
values['body_html'] = self._convert_inline_images_to_urls(values['body_html'])
|
||||
if 'medium_id' not in values and values.get('mailing_type', 'mail') == 'mail':
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<field name="priority">10</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Mailings">
|
||||
<field name="name"/>
|
||||
<field name="subject"/>
|
||||
<field name="mailing_type" invisible="1"/>
|
||||
<field name="sent"/>
|
||||
<field name="delivered"/>
|
||||
@@ -134,7 +134,7 @@
|
||||
<widget name="web_ribbon" text="Archived" bg_color="bg-danger" attrs="{'invisible': [('active', '=', True)]}"/>
|
||||
<group>
|
||||
<field name="active" invisible="1"/>
|
||||
<field name="name" required="1" string="Name"/>
|
||||
<field name="name" required="False" groups="base.group_no_one" string="Name"/>
|
||||
<field name="mailing_type" widget="radio" options="{'horizontal': true}" invisible="1"
|
||||
attrs="{'readonly': [('state', 'in', ('sending', 'done'))]}"/>
|
||||
<field name="subject" string="Subject" attrs="{'readonly': [('state', 'in', ('sending', 'done'))]}"/>
|
||||
@@ -142,7 +142,7 @@
|
||||
<div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-3" >
|
||||
<field name="mailing_model_id" widget="selection"
|
||||
<field name="mailing_model_id" widget="selection"
|
||||
attrs="{'readonly': [('state', 'in', ('sending', 'done'))]}"/>
|
||||
</div>
|
||||
<div attrs="{'invisible': [('mailing_model_name', '!=', 'mailing.list')]}" class="col-xs-12 col-md-9 pt-1">
|
||||
@@ -163,7 +163,7 @@
|
||||
'invisible': [('mailing_model_name', '=', 'mailing.list')],
|
||||
'readonly': [('state', 'in', ('sending', 'done'))]
|
||||
}">
|
||||
</field>
|
||||
</field>
|
||||
</div>
|
||||
</group>
|
||||
<notebook>
|
||||
@@ -197,7 +197,7 @@
|
||||
}"/>
|
||||
<field name="reply_to"
|
||||
attrs="{
|
||||
'required': [('reply_to_mode', '=', 'email')],
|
||||
'required': [('reply_to_mode', '=', 'email')],
|
||||
'invisible': [('reply_to_mode', '=', 'thread')],
|
||||
'readonly': [('state', 'in', ('sending', 'done'))]
|
||||
}"/>
|
||||
@@ -229,7 +229,7 @@
|
||||
attrs="{'readonly': [('state', 'in', ('sending', 'done'))]}"/>
|
||||
<label for="contact_ab_pc" groups="mass_mailing.group_mass_mailing_campaign"/>
|
||||
<div groups="mass_mailing.group_mass_mailing_campaign">
|
||||
<field name="contact_ab_pc"
|
||||
<field name="contact_ab_pc"
|
||||
class="oe_inline"
|
||||
attrs="{'readonly': [('state', 'in', ('sending', 'done'))]}"/> %
|
||||
</div>
|
||||
@@ -286,7 +286,7 @@
|
||||
<div class="o_kanban_record_top">
|
||||
<div class="o_kanban_record_headings">
|
||||
<h3 class="mt4 mb4">
|
||||
<field name="name"/>
|
||||
<field name="subject"/>
|
||||
</h3>
|
||||
<field name="mailing_type" invisible="1"/>
|
||||
<div class="o_kanban_record_subtitle" attrs="{'invisible': [('sent_date', '=', False)]}">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo><data noupdate="0">
|
||||
<record id="mailing_sms_0" model="mailing.mailing">
|
||||
<field name="name">XMas Promo</field>
|
||||
<field name="subject">XMas Promo</field>
|
||||
<field name="mailing_type">sms</field>
|
||||
<field name="state">done</field>
|
||||
<field name="user_id" ref="base.user_admin"/>
|
||||
@@ -109,7 +109,7 @@
|
||||
</function>
|
||||
|
||||
<record id="mailing_sms_1" model="mailing.mailing">
|
||||
<field name="name">Extra Promo</field>
|
||||
<field name="subject">Extra Promo</field>
|
||||
<field name="mailing_type">sms</field>
|
||||
<field name="state">done</field>
|
||||
<field name="user_id" ref="base.user_admin"/>
|
||||
|
||||
@@ -85,12 +85,6 @@
|
||||
<attribute name="attrs">{'invisible': [('mailing_type', '!=', 'mail')]}</attribute>
|
||||
</xpath>
|
||||
<!-- Form -->
|
||||
<xpath expr="//field[@name='subject']" position="attributes">
|
||||
<attribute name="attrs">{
|
||||
'invisible': [('mailing_type', '!=', 'mail')],
|
||||
'readonly': [('state', 'in', ('sending', 'done'))]}
|
||||
</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//page[@name='mail_body']" position="attributes">
|
||||
<attribute name="attrs">{'invisible': [('mailing_type', '!=', 'mail')]}</attribute>
|
||||
</xpath>
|
||||
|
||||
@@ -102,7 +102,7 @@ class TestSMSPost(test_mail_full_common.BaseFunctionalTest, sms_common.MockSMS,
|
||||
|
||||
def test_sms_body_link_shorten_suffix(self):
|
||||
mailing = self.env['mailing.mailing'].create({
|
||||
'name': 'Minimal mailing',
|
||||
'subject': 'Minimal mailing',
|
||||
'mailing_model_id': self.env['ir.model']._get('mail.test.sms').id,
|
||||
'mailing_type': 'sms',
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user