[MERGE] [IMP] mail: subtype: order by application + allow to hide technical subtypes + updated addons subtypes

- mail.message.subtype:
-- added sequence field, used to order subtypes when displaying them
-- added hidden field, used to hide some subtypes. Subtypes like 'Task Created' or 'Issue Created' are not necessary on a task or issue, but useful on the project form view. Indeed by following the task created subtype on the project, the user is notified of new tasks. However on the task itself it makes no sense to be able to follow task created. This subtype has to exist due to the technical implementation, but should be hidden in the followers widget of the task.
- mail: updated followers widget accordingly, and display subtypes by application with a visual border to separate them

- project, crm, sale_crm: updated hidden and sequence of subtypes

bzr revid: tde@openerp.com-20140221122036-m30laylmb4tqndkh
This commit is contained in:
Thibault Delavallée
2014-02-21 13:20:36 +01:00
10 changed files with 61 additions and 8 deletions
+5
View File
@@ -146,6 +146,7 @@
<!-- CRM-related subtypes for messaging / Chatter -->
<record id="mt_lead_create" model="mail.message.subtype">
<field name="name">Lead Created</field>
<field name="hidden" eval="True"/>
<field name="res_model">crm.lead</field>
<field name="default" eval="False"/>
<field name="description">Lead created</field>
@@ -171,6 +172,7 @@
<!-- Salesteam-related subtypes for messaging / Chatter -->
<record id="mt_salesteam_lead" model="mail.message.subtype">
<field name="name">Lead Created</field>
<field name="sequence">10</field>
<field name="res_model">crm.case.section</field>
<field name="default" eval="False"/>
<field name="parent_id" eval="ref('mt_lead_create')"/>
@@ -178,18 +180,21 @@
</record>
<record id="mt_salesteam_lead_stage" model="mail.message.subtype">
<field name="name">Opportunity Stage Changed</field>
<field name="sequence">11</field>
<field name="res_model">crm.case.section</field>
<field name="parent_id" eval="ref('mt_lead_stage')"/>
<field name="relation_field">section_id</field>
</record>
<record id="mt_salesteam_lead_won" model="mail.message.subtype">
<field name="name">Opportunity Won</field>
<field name="sequence">12</field>
<field name="res_model">crm.case.section</field>
<field name="parent_id" eval="ref('mt_lead_won')"/>
<field name="relation_field">section_id</field>
</record>
<record id="mt_salesteam_lead_lost" model="mail.message.subtype">
<field name="name">Opportunity Lost</field>
<field name="sequence">13</field>
<field name="res_model">crm.case.section</field>
<field name="default" eval="False"/>
<field name="parent_id" eval="ref('mt_lead_lost')"/>
+1
View File
@@ -54,6 +54,7 @@
<!-- Discussion subtype for messaging / Chatter -->
<record id="mt_comment" model="mail.message.subtype">
<field name="name">Discussions</field>
<field name="sequence" eval="0"/>
</record>
</data>
</openerp>
+6
View File
@@ -29,6 +29,8 @@ class mail_message_subtype(osv.osv):
on the Wall. """
_name = 'mail.message.subtype'
_description = 'Message subtypes'
_order = 'sequence, id'
_columns = {
'name': fields.char('Message Type', required=True, translate=True,
help='Message subtype gives a more precise type on the message, '\
@@ -50,7 +52,11 @@ class mail_message_subtype(osv.osv):
help="Model the subtype applies to. If False, this subtype applies to all models."),
'default': fields.boolean('Default',
help="Activated by default when subscribing."),
'sequence': fields.integer('Sequence', help="Used to order subtypes."),
'hidden': fields.boolean('Hidden', help="Hide the subtype in the follower options")
}
_defaults = {
'default': True,
'sequence': 1,
}
+13 -6
View File
@@ -9,6 +9,7 @@
<field name="arch" type="xml">
<tree string="Subtype">
<field name="name"/>
<field name="sequence"/>
<field name="res_model"/>
<field name="default"/>
</tree>
@@ -22,12 +23,18 @@
<form string="Email message" version="7.0">
<sheet>
<group>
<field name="name"/>
<field name="res_model"/>
<field name="default"/>
<field name="description"/>
<field name="parent_id"/>
<field name="relation_field"/>
<group string='Description'>
<field name="name"/>
<field name="sequence"/>
<field name="res_model"/>
<field name="description"/>
<field name="default"/>
<field name="hidden"/>
</group>
<group string='Auto subscription'>
<field name="parent_id"/>
<field name="relation_field"/>
</group>
</group>
</sheet>
</form>
+12 -2
View File
@@ -20,6 +20,7 @@
##############################################################################
import base64
from collections import OrderedDict
import datetime
import dateutil
import email
@@ -185,8 +186,17 @@ class mail_thread(osv.AbstractModel):
# find current model subtypes, add them to a dictionary
subtype_obj = self.pool.get('mail.message.subtype')
subtype_ids = subtype_obj.search(cr, uid, ['|', ('res_model', '=', self._name), ('res_model', '=', False)], context=context)
subtype_dict = dict((subtype.name, dict(default=subtype.default, followed=False, id=subtype.id)) for subtype in subtype_obj.browse(cr, uid, subtype_ids, context=context))
subtype_ids = subtype_obj.search(
cr, uid, [
'&', ('hidden', '=', False), '|', ('res_model', '=', self._name), ('res_model', '=', False)
], context=context)
subtype_dict = OrderedDict(
(subtype.name, {
'default': subtype.default,
'followed': False,
'parent_model': subtype.parent_id and subtype.parent_id.res_model or self._name,
'id': subtype.id}
) for subtype in subtype_obj.browse(cr, uid, subtype_ids, context=context))
for id in ids:
res[id]['message_subtype_data'] = subtype_dict.copy()
+4
View File
@@ -760,4 +760,8 @@
.openerp .oe_sidebar_suggestion .oe_suggest_items:hover a.oe_suggestion_remove_item {
visibility: visible;
}
.subtype-border {
border-bottom: 1px solid #dddddd;
margin-bottom: 10px;
}
@@ -265,7 +265,15 @@ openerp_mail_followers = function(session, mail) {
var records = data[id].message_subtype_data;
this.records_length = $.map(records, function(value, index) { return index; }).length;
if (this.records_length > 1) { self.display_followers(); }
var old_model = '';
_(records).each(function (record, record_name) {
if (old_model != record.parent_model){
if (old_model != ''){
var index = $($list).find('.oe_subtype').length;
$($($list).find('.oe_subtype')[index-1]).addClass('subtype-border');
}
old_model = record.parent_model;
}
record.name = record_name;
record.followed = record.followed || undefined;
$(session.web.qweb.render('mail.followers.subtype', {'record': record})).appendTo($list);
+5
View File
@@ -78,6 +78,7 @@
<field name="name">Task Created</field>
<field name="res_model">project.task</field>
<field name="default" eval="False"/>
<field name="hidden" eval="True"/>
<field name="description">Task created</field>
</record>
<record id="mt_task_assigned" model="mail.message.subtype">
@@ -101,6 +102,7 @@
<!-- Project-related subtypes for messaging / Chatter -->
<record id="mt_project_task_new" model="mail.message.subtype">
<field name="name">Task Created</field>
<field name="sequence">10</field>
<field name="res_model">project.project</field>
<field name="default" eval="False"/>
<field name="parent_id" eval="ref('mt_task_new')"/>
@@ -108,6 +110,7 @@
</record>
<record id="mt_project_task_assigned" model="mail.message.subtype">
<field name="name">Task Assigned</field>
<field name="sequence">11</field>
<field name="res_model">project.project</field>
<field name="default" eval="False"/>
<field name="parent_id" eval="ref('mt_task_assigned')"/>
@@ -115,12 +118,14 @@
</record>
<record id="mt_project_task_blocked" model="mail.message.subtype">
<field name="name">Task Blocked</field>
<field name="sequence">12</field>
<field name="res_model">project.project</field>
<field name="parent_id" eval="ref('mt_task_blocked')"/>
<field name="relation_field">project_id</field>
</record>
<record id="mt_project_task_stage" model="mail.message.subtype">
<field name="name">Task Stage Changed</field>
<field name="sequence">13</field>
<field name="res_model">project.project</field>
<field name="parent_id" eval="ref('mt_task_stage')"/>
<field name="relation_field">project_id</field>
@@ -33,6 +33,7 @@ Access all issues from the top Project menu, and access the issues of a specific
<field name="name">Issue Created</field>
<field name="res_model">project.issue</field>
<field name="default" eval="False"/>
<field name="hidden" eval="True"/>
<field name="description">Issue created</field>
</record>
<record id="mt_issue_assigned" model="mail.message.subtype">
@@ -56,6 +57,7 @@ Access all issues from the top Project menu, and access the issues of a specific
<!-- Project-related subtypes for messaging / Chatter -->
<record id="mt_project_issue_new" model="mail.message.subtype">
<field name="name">Issue Created</field>
<field name="sequence">20</field>
<field name="res_model">project.project</field>
<field name="default" eval="False"/>
<field name="parent_id" eval="ref('mt_issue_new')"/>
@@ -63,6 +65,7 @@ Access all issues from the top Project menu, and access the issues of a specific
</record>
<record id="mt_project_issue_assigned" model="mail.message.subtype">
<field name="name">Issue Assigned</field>
<field name="sequence">21</field>
<field name="res_model">project.project</field>
<field name="default" eval="False"/>
<field name="parent_id" eval="ref('mt_issue_assigned')"/>
@@ -70,12 +73,14 @@ Access all issues from the top Project menu, and access the issues of a specific
</record>
<record id="mt_project_issue_blocked" model="mail.message.subtype">
<field name="name">Issue Blocked</field>
<field name="sequence">22</field>
<field name="res_model">project.project</field>
<field name="parent_id" eval="ref('mt_issue_blocked')"/>
<field name="relation_field">project_id</field>
</record>
<record id="mt_project_issue_stage" model="mail.message.subtype">
<field name="name">Issue Stage Changed</field>
<field name="sequence">23</field>
<field name="res_model">project.project</field>
<field name="description">Stage changed</field>
<field name="parent_id" eval="ref('mt_issue_stage')"/>
+2
View File
@@ -5,12 +5,14 @@
<!-- Salesteam-related subtypes for messaging / Chatter -->
<record id="mt_salesteam_order_sent" model="mail.message.subtype">
<field name="name">Quotation Send</field>
<field name="sequence">20</field>
<field name="res_model">crm.case.section</field>
<field name="parent_id" eval="ref('sale.mt_order_sent')"/>
<field name="relation_field">section_id</field>
</record>
<record id="mt_salesteam_order_confirmed" model="mail.message.subtype">
<field name="name">Sales Order Confirmed</field>
<field name="sequence">21</field>
<field name="res_model">crm.case.section</field>
<field name="parent_id" eval="ref('sale.mt_order_confirmed')"/>
<field name="relation_field">section_id</field>