This commit prepares SMS refactoring by updating some mail models. Purpose
is to be able to store SMS notification information inside existing mail
flow and models.
Main changes
* mail.notification: define a notification_type field to store the medium
used to notify people. In mail two ways exist: inbox and email. It will
ease introduction of SMS notification mechanism. This field replaces the
is_email boolean field;
* mail.notification: make res_partner_id field not required. This means
notifications could be linked to something else than a partner. An SMS
for example. For Inbox and email notifications partner is still required
and a constraint is added accordingly;
* mail.thread: let notification methods handle the creation and update of
their notification instead of creating them in _notify_thread and tweaking
them in sub notification methods;
* mail.thread: clearly move inbox-style notification in its own method like
notify by email;
Some lighter code changes
* propagate message_type to notification recipient computation. It will
allow for example to be more precise when computing a notification type
depending on the message_type. For example, send a notification by SMS
when the message_type is SMS;
* ease inheritance of ``_notify_thread`` by returning computed recipients
data. It will allow to work on it without having to re-compute it;
* propagate kwargs from message_post and message_notify to notify methods.
This allow to avoid depending on context and set explicit parameters.
Drawback is that message_post and notify must separate kwargs used to
create a message and those that are propagated to notification methods;
* update various notification check to ensure they work on email
notifications, notably the resend and cancel wizards;
One side effect of this commit is that notifications are created by the
relevant notification method. Previously all notifications were created
by writing on needaction_partner_ids fields then updated according to the
notification process. Notably there could be too much notification created
when sending emails due to _notify_customize_recipients not being correctly
synchronized with notification. This issue is now solved as only really
sent emails create notifications.
Migration tips
* notification_type: notification.is_email and 'email' else 'inbox';
* remove is_email;
Related to task 1922163
Linked to PR #33510
196 lines
10 KiB
XML
196 lines
10 KiB
XML
<?xml version="1.0"?>
|
|
<odoo>
|
|
<data>
|
|
<!-- mail.message tree: short view !-->
|
|
<record model="ir.ui.view" id="view_message_tree">
|
|
<field name="name">mail.message.tree</field>
|
|
<field name="model">mail.message</field>
|
|
<field name="priority">20</field>
|
|
<field name="arch" type="xml">
|
|
<tree string="Messages">
|
|
<field name="date"/>
|
|
<field name="subject"/>
|
|
<field name="author_id"/>
|
|
<field name="model"/>
|
|
<field name="res_id"/>
|
|
</tree>
|
|
</field>
|
|
</record>
|
|
|
|
<!-- mail.message form: short view !-->
|
|
<record model="ir.ui.view" id="view_message_form">
|
|
<field name="name">mail.message.form</field>
|
|
<field name="model">mail.message</field>
|
|
<field name="priority">20</field>
|
|
<field name="arch" type="xml">
|
|
<form string="Message">
|
|
<sheet>
|
|
<group>
|
|
<group>
|
|
<field name="subject"/>
|
|
<field name="date"/>
|
|
<field name="email_from"/>
|
|
<field name="author_id"/>
|
|
<field name="record_name"/>
|
|
<field name="moderator_id"/>
|
|
</group>
|
|
<group>
|
|
<field name="parent_id"/>
|
|
<field name="model"/>
|
|
<field name="res_id"/>
|
|
<field name="message_type"/>
|
|
<field name="subtype_id"/>
|
|
<field name="moderation_status"/>
|
|
</group>
|
|
</group>
|
|
<notebook>
|
|
<page string="Body">
|
|
<field name="body" options="{'style-inline': true}"/>
|
|
</page>
|
|
<page string="Gateway">
|
|
<group>
|
|
<group>
|
|
<field name="reply_to"/>
|
|
<field name="no_auto_thread"/>
|
|
</group>
|
|
<group>
|
|
<field name="message_id"/>
|
|
<field name="mail_server_id"/>
|
|
</group>
|
|
</group>
|
|
</page>
|
|
<page string="Recipients">
|
|
<group>
|
|
<group>
|
|
<field name="partner_ids" widget="many2many_tags"/>
|
|
<field name="channel_ids" widget="many2many_tags"/>
|
|
</group>
|
|
<group>
|
|
<field name="needaction_partner_ids" widget="many2many_tags"/>
|
|
<field name="starred_partner_ids" widget="many2many_tags"/>
|
|
</group>
|
|
</group>
|
|
<group>
|
|
<field name="notification_ids">
|
|
<tree>
|
|
<field name="res_partner_id"/>
|
|
<field name="is_read"/>
|
|
<field name="notification_type"/>
|
|
<field name="notification_status"/>
|
|
</tree>
|
|
</field>
|
|
</group>
|
|
</page>
|
|
<page string="Tracking">
|
|
<field name="tracking_value_ids"/>
|
|
</page>
|
|
</notebook>
|
|
</sheet>
|
|
</form>
|
|
</field>
|
|
</record>
|
|
|
|
<!-- mail.message search: wall view !-->
|
|
<record model="ir.ui.view" id="view_message_search">
|
|
<field name="name">mail.message.search</field>
|
|
<field name="model">mail.message</field>
|
|
<field name="priority">25</field>
|
|
<field name="arch" type="xml">
|
|
<search string="Messages Search">
|
|
<field name="body" string="Content" filter_domain="['|', ('subject', 'ilike', self), ('body', 'ilike', self)]" />
|
|
<field name="subject"/>
|
|
<field name="message_type"/>
|
|
<field name="author_id"/>
|
|
<field name="partner_ids"/>
|
|
<field name="model"/>
|
|
<field name="res_id"/>
|
|
<field name="parent_id"/>
|
|
<filter string="Has Mentions"
|
|
name="filter_has_mentions"
|
|
domain="[('partner_ids.user_ids', 'in', [uid])]"/>
|
|
<separator/>
|
|
<filter string="Need Action"
|
|
name="message_needaction" help="Unread messages"
|
|
domain="[('needaction', '=', True)]"/>
|
|
<separator/>
|
|
<filter string="Has attachments"
|
|
name="attachments"
|
|
domain="[('attachment_ids', '!=', False)]"/>
|
|
</search>
|
|
</field>
|
|
</record>
|
|
|
|
<record id="action_view_mail_message" model="ir.actions.act_window">
|
|
<field name="name">Messages</field>
|
|
<field name="res_model">mail.message</field>
|
|
<field name="view_mode">tree,form</field>
|
|
<field name="search_view_id" ref="view_message_search"/>
|
|
</record>
|
|
|
|
<!-- Add menu entry in Settings/Email -->
|
|
<menuitem name="Messages" id="menu_mail_message" parent="base.menu_email" action="action_view_mail_message"/>
|
|
|
|
<record model="ir.ui.view" id="view_document_file_kanban">
|
|
<field name="name">ir.attachment kanban</field>
|
|
<field name="model">ir.attachment</field>
|
|
<field name="arch" type="xml">
|
|
<kanban>
|
|
<field name="id"/>
|
|
<field name="mimetype"/>
|
|
<field name="type"/>
|
|
<field name="create_uid"/>
|
|
<field name="url"/>
|
|
<field name="type"/>
|
|
<field name="create_date"/>
|
|
<field name="name"/>
|
|
<field name="res_name"/>
|
|
<templates>
|
|
<t t-name="kanban-box">
|
|
<div class="oe_kanban_global_area o_kanban_attachment oe_kanban_global_click">
|
|
<div class="o_kanban_image">
|
|
<div class="o_kanban_image_wrapper">
|
|
<t t-set="webimage" t-value="new RegExp('image.*(gif|jpeg|jpg|png)').test(record.mimetype.value)"/>
|
|
<div t-if="record.type.raw_value == 'url'" class="o_url_image fa fa-link fa-3x text-muted"/>
|
|
<img t-elif="webimage" t-attf-src="/web/image/#{record.id.raw_value}" width="100" height="100" alt="Document" class="o_attachment_image"/>
|
|
<div t-else="!webimage" class="o_image o_image_thumbnail" t-att-data-mimetype="record.mimetype.value"/>
|
|
</div>
|
|
</div>
|
|
<div class="o_kanban_details">
|
|
<div class="o_kanban_details_wrapper">
|
|
<div t-att-title="record.name.raw_value" class="o_kanban_record_title">
|
|
<field name="name" class="o_text_overflow"/>
|
|
</div>
|
|
<div class="o_kanban_record_body">
|
|
<t t-if="record.type.raw_value == 'url'">
|
|
<span class="o_document_url"><i class="fa fa-globe"/> <field name="url" widget="url"/></span>
|
|
</t>
|
|
<samp t-else="" class="text-muted"> </samp>
|
|
</div>
|
|
<div class="o_kanban_record_bottom">
|
|
<time class="oe_kanban_bottom_left">
|
|
<field name="create_date" widget="date"/>
|
|
</time>
|
|
<div class="oe_kanban_bottom_right">
|
|
<img t-att-src="kanban_image('res.users', 'image_small', record.create_uid.raw_value)" t-att-data-member_id="record.create_uid.raw_value" t-att-alt="record.create_uid.raw_value" width="32" height="32" class="oe_kanban_avatar"/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</t>
|
|
</templates>
|
|
</kanban>
|
|
</field>
|
|
</record>
|
|
<record id="base.action_attachment" model="ir.actions.act_window">
|
|
<field name="view_mode">kanban,tree,form</field>
|
|
<field name="help" type="html">
|
|
<p class="o_view_nocontent_smiling_face">
|
|
Attach a new document
|
|
</p>
|
|
</field>
|
|
</record>
|
|
|
|
</data>
|
|
</odoo>
|