[IMP] Small improvements
[odoo/odoo.git] / addons / mail / doc / mail_subtype.rst
1 .. _mail_message_subtype:
2
3 OpenChatter Pi (3.1415): Message Subtype
4 ========================================
5
6   To overcome the problems of crowdy walls in system notification, We have added features of **Message Subtype** in mail.
7
8 mail.message.subtype
9 ++++++++++++++++++++
10 ``mail.message.subtype`` has following fields:
11
12  - ``Name``: fields.char(' Message Subtype ', size = 128,required = True,help = 'Subtype Of Message'),
13  - ``model_ids``: fields.many2many('ir.model','mail_message_subtyp_message_rel','message_subtype_id', 'model_id', 'Model',help = "link some subtypes to several models, for projet/task"),
14  - ``default``: fields.boolean('Default', help = "When subscribing to the document, users will receive by default messages related to this subtype unless they uncheck this subtype"),
15
16 mail.followers
17 ++++++++++++++
18
19 In ``mail.followers`` we have added additional many2many field subtype ids :
20
21  - ``subtype_ids``: fields.many2many('mail.message.subtype','mail_message_subtyp_rel','subscription_id', 'subtype_id', 'Subtype',help = "linking some subscription to several subtype for projet/task")
22
23 mail.message
24 ++++++++++++
25
26 In mail_message we have added additional field subtype_id which Indicates the Type of Message
27
28  - ``subtype_id``: fields.many2one('mail.message.subtype', 'Subtype')
29
30 mail.thread
31 +++++++++++
32
33  - In **message_post** method add the *subtype_id* field as parameter and set as default subtype 'Other'.
34  
35         def message_post(self, cr, uid, thread_id, body='', subject=False, msg_type='notification', parent_id=False, attachments=None, subtype='other', context=None, ``**kwargs``):
36
37  - In **message_subscribe** method add the *subtype_ids* field as parameter.In this method if subtype_ids is None, it fatch the default true subtypes in mail.message.subtypes otherwise pass selected subtypes.
38    For update subtypes call **message_subscribe_udpate_subtypes** method
39
40         def message_subscribe(self, cr, uid, ids, partner_ids,subtype_ids = None, context=None):
41
42  - Add **message_subscribe_udpate_subtypes** method to update the subtype_ids in followers.
43
44     def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids,context=None):
45         followers_obj = self.pool.get('mail.followers')
46         followers_ids = followers_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)])
47         return followers_obj.write(cr, uid, followers_ids, {'subtype_ids': [(6, 0 , subtype_ids)]}, context = context)
48
49 For Each Addons:
50 ++++++++++++++++
51
52  - Add data of subtypes for each addons module.
53  - Add subtype field as parameter in **message_post** Method for each addons module.
54
55 How It Works:
56 +++++++++++++
57
58  - In addons module when we Follow a Perticular document It display under the followers button.
59  - In sybtypes there are 3 default subtypes for each addons
60     1) Email
61     2) Comment
62     3) Other
63  - In document display a default subtypes(which are true) related a perticular model_ids wise.
64     
65     Example:-
66         If I have open crm.lead, It display only subtypes of crm.lead
67
68  - When we select subtype it update subtype_ids(which are checked) in mail.follower where match res_model & res_id of the current documents.
69  - when message created update subtype_id of that message in mail.message.
70  - In Feeds display only those notifications of documents which subtypes are selected