Foram Katharotiya (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-message-sub-type-apa-mail-subtype-fka 
into lp:~openerp-dev/openobject-addons/trunk-message-sub-type-apa.

Requested reviews:
  Amit Patel (OpenERP) (apa-tiny)
  Thibault Delavallée (OpenERP) (tde-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-message-sub-type-apa-mail-subtype-fka/+merge/119882

hello sir,

- I have fix & Improve code as per your suggetion

Thanks,
FKA
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-message-sub-type-apa-mail-subtype-fka/+merge/119882
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-message-sub-type-apa.
=== modified file 'crm/crm_data.xml'
--- crm/crm_data.xml	2012-08-14 08:20:29 +0000
+++ crm/crm_data.xml	2012-08-16 10:14:39 +0000
@@ -56,7 +56,7 @@
 
         <!-- notify all employees of module installation -->
         <function model="mail.group" name="message_append_note">
-            <!-- ids, subject, body, parent_id=False, type='notification', content_subtype='html' -->
+            <!-- ids, subject,subtype_id="other", body, parent_id=False, type='notification', content_subtype='html' -->
             <value eval="[ref('mail.group_all_employees')]"/>
             <value>Module CRM has been installed</value>
             <value>From the top menu Sales, you can: trace leads and opportunities, get accurate forecast on your sales pipeline, plan meetings and phonecalls, get realtime statistics and efficiently organize the communication with your prospects.

=== modified file 'crm/crm_lead.py'
--- crm/crm_lead.py	2012-08-15 20:51:43 +0000
+++ crm/crm_lead.py	2012-08-16 10:14:39 +0000
@@ -278,6 +278,9 @@
 
     def create(self, cr, uid, vals, context=None):
         obj_id = super(crm_lead, self).create(cr, uid, vals, context)
+        obj = self.browse(cr, uid, obj_id, context)
+        if obj.user_id:
+            self.message_subscribe(cr, uid, [obj_id], [obj.user_id.id], context = context)
         self.create_send_note(cr, uid, [obj_id], context=context)
         return obj_id
 
@@ -867,7 +870,7 @@
     def stage_set_send_note(self, cr, uid, ids, stage_id, context=None):
         """ Override of the (void) default notification method. """
         stage_name = self.pool.get('crm.case.stage').name_get(cr, uid, [stage_id], context=context)[0][1]
-        return self.message_append_note(cr, uid, ids, body= _("Stage changed to <b>%s</b>.") % (stage_name), context=context)
+        return self.message_append_note(cr, uid, ids, body= _("Stage changed to <b>%s</b>.") % (stage_name), subtype="stage change",context=context)
 
     def case_get_note_msg_prefix(self, cr, uid, lead, context=None):
         if isinstance(lead, (int, long)):
@@ -877,16 +880,16 @@
     def create_send_note(self, cr, uid, ids, context=None):
         for id in ids:
             message = _("%s has been <b>created</b>.")% (self.case_get_note_msg_prefix(cr, uid, id, context=context))
-            self.message_append_note(cr, uid, [id], body=message, context=context)
+            self.message_append_note(cr, uid, [id], body=message, subtype="new", context=context)
         return True
 
     def case_mark_lost_send_note(self, cr, uid, ids, context=None):
         message = _("Opportunity has been <b>lost</b>.")
-        return self.message_append_note(cr, uid, ids, body=message, context=context)
+        return self.message_append_note(cr, uid, ids, body=message,subtype="lost", context=context)
 
     def case_mark_won_send_note(self, cr, uid, ids, context=None):
         message = _("Opportunity has been <b>won</b>.")
-        return self.message_append_note(cr, uid, ids, body=message, context=context)
+        return self.message_append_note(cr, uid, ids, body=message, subtype="won", context=context)
 
     def schedule_phonecall_send_note(self, cr, uid, ids, phonecall_id, action, context=None):
         phonecall = self.pool.get('crm.phonecall').browse(cr, uid, [phonecall_id], context=context)[0]

=== modified file 'crm/crm_lead_data.xml'
--- crm/crm_lead_data.xml	2012-08-14 08:20:29 +0000
+++ crm/crm_lead_data.xml	2012-08-16 10:14:39 +0000
@@ -154,5 +154,38 @@
             <field name="object_id" search="[('model','=','crm.lead')]" model="ir.model"/>
         </record>
 
+        <!--  mail subtype -->
+        <record id="mail_subtype_lead_new" model="mail.message.subtype">
+            <field name="name">new</field>
+            <field name="model_ids" eval="[(6, 0, [ref('crm.model_crm_lead')])]"/>
+            <field name="default" eval="False"/>
+        </record>
+        <record id="mail_subtype_lead_won" model="mail.message.subtype">
+            <field name="name">won</field>
+            <field name="model_ids" eval="[(6, 0, [ref('crm.model_crm_lead')])]"/>
+        </record>
+        <record id="mail_subtype_lead_lost" model="mail.message.subtype">
+            <field name="name">lost</field>
+            <field name="model_ids" eval="[(6, 0, [ref('crm.model_crm_lead')])]"/>
+        </record>
+        <record id="mail_subtype_lead_stage_change" model="mail.message.subtype">
+            <field name="name">stage change</field>
+            <field name="model_ids" eval="[(6, 0, [ref('crm.model_crm_lead')])]"/>
+            <field name="default" eval="False"/>
+        </record>
+        <record id="mail_subtype_lead_other" model="mail.message.subtype">
+            <field name="name">other</field>
+            <field name="model_ids" eval="[(6, 0, [ref('crm.model_crm_lead')])]"/>
+            <field name="default" eval="False"/>
+        </record>
+        <record id="mail_subtype_lead_email" model="mail.message.subtype">
+            <field name="name">email</field>
+            <field name="model_ids" eval="[(6, 0, [ref('crm.model_crm_lead')])]"/>
+        </record>
+        <record id="mail_subtype_lead_comment" model="mail.message.subtype">
+            <field name="name">comment</field>
+            <field name="model_ids" eval="[(6, 0, [ref('crm.model_crm_lead')])]"/>
+            <field name="default" eval="False"/>
+        </record>
     </data>
 </openerp>

=== modified file 'mail/__init__.py'
--- mail/__init__.py	2012-08-15 19:56:52 +0000
+++ mail/__init__.py	2012-08-16 10:14:39 +0000
@@ -19,6 +19,7 @@
 #
 ##############################################################################
 
+import mail_message_subtype
 import mail_alias
 import mail_message
 import mail_followers

=== modified file 'mail/__openerp__.py'
--- mail/__openerp__.py	2012-08-15 19:56:52 +0000
+++ mail/__openerp__.py	2012-08-16 10:14:39 +0000
@@ -62,6 +62,7 @@
     'depends': ['base', 'base_tools', 'base_setup'],
     'data': [
         'wizard/mail_compose_message_view.xml',
+        'mail_message_subtype.xml',
         'res_config_view.xml',
         'mail_message_view.xml',
         'mail_followers_view.xml',

=== modified file 'mail/data/mail_group_data.xml'
--- mail/data/mail_group_data.xml	2012-08-14 15:26:34 +0000
+++ mail/data/mail_group_data.xml	2012-08-16 10:14:39 +0000
@@ -14,7 +14,7 @@
 
         <!-- notify all employees of module installation -->
         <function model="mail.group" name="message_append_note">
-            <!-- ids, subject, body, parent_id=False, type='notification', content_subtype='html' -->
+            <!-- ids, subject,subtype_id="other", body, parent_id=False, type='notification', content_subtype='html' -->
             <value eval="[ref('mail.group_all_employees')]"/>
             <value>Welcome to OpenERP!</value>
             <value>Your homepage is a summary of messages you received and key information about documents you follow.

=== modified file 'mail/mail_followers.py'
--- mail/mail_followers.py	2012-08-13 19:10:06 +0000
+++ mail/mail_followers.py	2012-08-16 10:14:39 +0000
@@ -45,6 +45,10 @@
                         help='Id of the followed resource'),
         'user_id': fields.many2one('res.users', string='Related User',
                         ondelete='cascade', required=True, select=1),
+        '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"),
     }
 
 class mail_notification(osv.Model):

=== modified file 'mail/mail_followers_view.xml'
--- mail/mail_followers_view.xml	2012-08-15 19:56:52 +0000
+++ mail/mail_followers_view.xml	2012-08-16 10:14:39 +0000
@@ -17,7 +17,33 @@
             </field>
         </record>
 
-        <!-- NOTIFICATION !-->
+<<<<<<< TREE
+        <!-- NOTIFICATION !-->
+=======
+        <record model="ir.ui.view" id="view_mail_subscription_form">
+            <field name="name">mail.followers.form</field>
+            <field name="model">mail.followers</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <form string="Followers Form" version="7.0">
+                    <sheet>
+                        <group>
+                            <group>
+                                <field name="res_model"/>
+                                <field name="user_id"/>
+                            </group>
+                            <group>
+                                <field name="res_id"/>
+                                <field name="subtype_ids" widget="many2many_tags"/>
+                            </group>
+                        </group>
+                    </sheet>
+                </form>
+            </field>
+        </record>
+        
+        <!-- NOTIFICATION !-->
+>>>>>>> MERGE-SOURCE
         <record model="ir.ui.view" id="view_notification_tree">
             <field name="name">mail.notification.tree</field>
             <field name="model">mail.notification</field>

=== modified file 'mail/mail_message.py'
--- mail/mail_message.py	2012-08-14 15:26:34 +0000
+++ mail/mail_message.py	2012-08-16 10:14:39 +0000
@@ -234,6 +234,7 @@
             select=True, ondelete='set null',
             help="Parent message, used for displaying as threads with hierarchy"),
         'child_ids': fields.one2many('mail.message', 'parent_id', 'Child Messages'),
+        'subtype_id': fields.many2one('mail.message.subtype', 'Subtype', select = True),
     }
         
     _defaults = {
@@ -278,7 +279,7 @@
     def create(self, cr, uid, values, context=None):
         self.check(cr, uid, [], mode='create', context=context, values=values)
         return super(mail_message, self).create(cr, uid, values, context)
-
+       
     def read(self, cr, uid, ids, fields_to_read=None, context=None, load='_classic_read'):
         self.check(cr, uid, ids, 'read', context=context)
         return super(mail_message, self).read(cr, uid, ids, fields_to_read, context, load)

=== added file 'mail/mail_message_subtype.py'
--- mail/mail_message_subtype.py	1970-01-01 00:00:00 +0000
+++ mail/mail_message_subtype.py	2012-08-16 10:14:39 +0000
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2009-today OpenERP SA (<http://www.openerp.com>)
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>
+#
+##############################################################################
+
+from osv import osv
+from osv import fields
+
+class mail_message_subtype(osv.osv):
+    
+    _name = 'mail.message.subtype'
+    _description = 'mail_message_subtype'
+    _columns = {
+                'name': fields.char(' Message Subtype ', size = 128,
+                        required = True, select = 1,
+                        help = 'Subtype Of Message'),
+                '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"),
+                '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"),
+    }
+    _defaults = {
+        'default': True,
+    }
+    _sql_constraints = [
+        ('name_uniq', 'unique (name)', 'The name of the message subtype must be unique !')
+    ]

=== added file 'mail/mail_message_subtype.xml'
--- mail/mail_message_subtype.xml	1970-01-01 00:00:00 +0000
+++ mail/mail_message_subtype.xml	2012-08-16 10:14:39 +0000
@@ -0,0 +1,56 @@
+<?xml version="1.0"?>
+<openerp>
+    <data>
+
+        <!-- 
+            SUBTYPES
+                !-->
+
+        <record model="ir.ui.view" id="view_message_subtype_tree">
+            <field name="name">mail.message.subtype.tree</field>
+            <field name="model">mail.message.subtype</field>
+            <field name="type">tree</field>
+            <field name="priority">10</field>
+            <field name="arch" type="xml">
+                <tree string="Subtype">
+                    <field name="name"/>
+                    <field name="model_ids" invisible="1"/>
+                    <field name="default"/>
+                </tree>
+            </field>
+        </record>
+        
+        <record model="ir.ui.view" id="view_mail_message_subtype_form">
+            <field name="name">mail.message.subtype.form</field>
+            <field name="model">mail.message.subtype</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <form string="Email message" version="7.0">
+                    <sheet>
+                        <group>
+                            <group>
+                                <field name="name"/>
+                            </group>
+                            <group>
+                                <field name="default"/>
+                            </group>
+                        </group>
+                        <separator string="Models"/>
+                        <field name="model_ids" widget="many2many"/>
+                    </sheet>
+                </form>
+            </field>
+        </record>
+        
+        <record id="action_view_message_subtype" model="ir.actions.act_window">
+            <field name="name">Subtypes</field>
+            <field name="res_model">mail.message.subtype</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+        </record>
+        
+        <menuitem name="Subtypes" id="menu_message_subtype" parent="base.menu_email"
+                    action="action_view_message_subtype"/>
+
+    </data>
+</openerp>

=== modified file 'mail/mail_message_view.xml'
--- mail/mail_message_view.xml	2012-08-14 13:10:03 +0000
+++ mail/mail_message_view.xml	2012-08-16 10:14:39 +0000
@@ -145,6 +145,7 @@
                                     <group>
                                         <field name="auto_delete"/>
                                         <field name="type"/>
+                                        <field name="subtype_id"/>
                                         <field name="content_subtype"/>
                                         <field name="state" colspan="2"/>
                                         <field name="mail_server_id"/>

=== modified file 'mail/mail_thread.py'
--- mail/mail_thread.py	2012-08-15 23:38:31 +0000
+++ mail/mail_thread.py	2012-08-16 10:14:39 +0000
@@ -260,7 +260,7 @@
     # mail.message wrappers and tools
     #------------------------------------------------------
 
-    def message_create(self, cr, uid, thread_id, vals, context=None):
+    def message_create(self, cr, uid, thread_id, vals, context = None):
         """ OpenChatter: wrapper of mail.message create method
            - creates the mail.message
            - automatically subscribe the message writer
@@ -268,10 +268,29 @@
         """
         if context is None:
             context = {}
-
-        # create message
-        msg_id = self.pool.get('mail.message').create(cr, uid, vals, context=context)
-
+<<<<<<< TREE
+
+        # create message
+        msg_id = self.pool.get('mail.message').create(cr, uid, vals, context=context)
+
+=======
+        
+        notification_obj = self.pool.get('mail.notification')
+        followers_obj = self.pool.get('mail.followers')
+        subtype_obj = self.pool.get('mail.message.subtype')
+        subtype_name = vals.get('subtype')
+        sutype = False
+        body = vals.get('body_html', '') if vals.get('content_subtype') == 'html' else vals.get('body_text', '')
+        if subtype_name:
+            subtypes = subtype_obj.name_search(cr, uid, subtype_name)
+            if len(subtypes):
+                subtype = subtype_obj.browse(cr, uid, subtypes[0][0])
+                if self._name in [model.model for model in subtype.model_ids]:
+                    vals['subtype_id']=subtype.id
+        # create message
+        msg_id = self.pool.get('mail.message').create(cr, uid, vals, context=context)
+
+>>>>>>> MERGE-SOURCE
         # automatically subscribe the writer of the message
         if vals.get('user_id'):
             record = self.browse(cr, uid, thread_id, context=context)
@@ -280,32 +299,58 @@
                 self.message_subscribe(cr, uid, [thread_id], [vals.get('user_id')], context=context)
 
         # Set as unread if writer is not the document responsible
-        self.message_create_set_unread(cr, uid, [thread_id], context=context)
+        self.message_create_set_unread(cr, uid, [thread_id], context = context)
         
         # special: if install mode, do not push demo data
         if context.get('install_mode', False):
             return msg_id
         
         # get users that will get a notification pushed
+<<<<<<< TREE
         notification_obj = self.pool.get('mail.notification')
         user_to_push_ids = self.message_get_user_ids_to_notify(cr, uid, [thread_id], vals, context=context)
         for id in user_to_push_ids:
             notification_obj.create(cr, uid, {'user_id': id, 'message_id': msg_id}, context=context)
+=======
+        subtype_id = subtype and subtype.id or False
+        user_to_push_ids = self.message_get_user_ids_to_notify(cr, uid, [thread_id], vals, subtype_id, context = context)
+        
+        for user_id in user_to_push_ids:
+            notification_obj.create(cr, uid, {'user_id': user_id, 'message_id': msg_id}, context = context)
+>>>>>>> MERGE-SOURCE
         
         # create the email to send
         self.message_create_notify_by_email(cr, uid, vals, user_to_push_ids, context=context)
         
         return msg_id
     
+<<<<<<< TREE
     def message_get_user_ids_to_notify(self, cr, uid, thread_ids, new_msg_vals, context=None):
+=======
+    def message_get_user_ids_to_notify(self, cr, uid, thread_ids, new_msg_vals, subtype_id=None, context=None):
+>>>>>>> MERGE-SOURCE
         # get body
         body = new_msg_vals.get('body_html', '') if new_msg_vals.get('content_subtype') == 'html' else new_msg_vals.get('body_text', '')
         
         # get subscribers
+<<<<<<< TREE
         subscr_obj = self.pool.get('mail.followers')
         subscr_ids = subscr_obj.search(cr, uid, ['&', ('res_model', '=', self._name), ('res_id', 'in', thread_ids)], context=context)
         notif_user_ids = [sub['user_id'][0] for sub in subscr_obj.read(cr, uid, subscr_ids, ['user_id'], context=context)]
     
+=======
+        subscr_obj = self.pool.get('mail.followers')
+        subscr_ids = subscr_obj.search(cr, uid, ['&', ('res_model', '=', self._name), ('res_id', 'in', thread_ids)], context=context)
+        notif_user_ids = []
+        # check with subtype
+        for subscription in subscr_obj.browse(cr, uid, subscr_ids, context=context):
+            if subtype_id:
+                if subtype_id in [subtype.id for subtype in subscription.subtype_ids]:
+                    notif_user_ids.append(subscription.user_id.id)
+            else:
+                notif_user_ids.append(subscription.user_id.id)
+    
+>>>>>>> MERGE-SOURCE
         # add users requested to perform an action (need_action mechanism)
         if hasattr(self, 'get_needaction_user_ids') and self._columns.get('user_id'):
             user_ids_dict = self.get_needaction_user_ids(cr, uid, thread_ids, context=context)
@@ -336,12 +381,12 @@
         return ret_dict
 
     def message_append(self, cr, uid, threads, subject, body_text=None, body_html=None,
-                        type='email', email_date=None, parent_id=False,
+                        type = 'email', email_date = None, parent_id = False,
                         content_subtype='plain', state=None,
                         partner_ids=None, email_from=False, email_to=False,
                         email_cc=None, email_bcc=None, reply_to=None,
                         headers=None, message_id=False, references=None,
-                        attachments=None, original=None, context=None):
+                        attachments=None, original=None, subtype = "other", context=None):
         """ Creates a new mail.message through message_create. The new message
             is attached to the current mail.thread, containing all the details 
             passed as parameters. All attachments will be attached to the 
@@ -391,6 +436,8 @@
             :param dict context: if a ``thread_model`` value is present in the
                 context, its value will be used to determine the model of the
                 thread to update (instead of the current model).
+            :param subtype: subtype of message: 'email', 'comment', 'notification';
+                other by default
         """
         if context is None:
             context = {}
@@ -433,10 +480,16 @@
             if partner_ids is None:
                 partner_ids = []
             mail_partner_ids = [(6, 0, partner_ids)]
-
+            if type in ['email', 'comment']:
+                subtype = type
             data = {
                 'subject': subject,
-                'body_text': body_text or thread._model._columns.get('description') and thread.description or '',
+<<<<<<< TREE
+                'body_text': body_text or thread._model._columns.get('description') and thread.description or '',
+=======
+                'subtype': subtype,
+                'body_text': body_text or thread._model._columns.get('description') and thread.description or '',
+>>>>>>> MERGE-SOURCE
                 'body_html': body_html or '',
                 'parent_id': parent_id,
                 'date': email_date or fields.datetime.now(),
@@ -465,7 +518,8 @@
                     'references': references,
                     'headers': headers,
                     'reply_to': reply_to,
-                    'original': original, })
+                    'original': original,
+                })
 
             new_msg_ids.append(self.message_create(cr, uid, thread.id, data, context=context))
         return new_msg_ids
@@ -507,6 +561,7 @@
                             attachments = msg_dict.get('attachments'),
                             headers = msg_dict.get('headers'),
                             original = msg_dict.get('original'),
+                            subtype = msg_dict.get('subtype','other'),
                             context = context)
 
     #------------------------------------------------------
@@ -990,21 +1045,22 @@
         self.message_append_note(cr, uid, [id], 'res.log', message, context=context)
 
     def message_append_note(self, cr, uid, ids, subject=None, body=None, parent_id=False,
-                            type='notification', content_subtype='html', context=None):
+                            type='notification', content_subtype='html', subtype='other', context=None):
         if content_subtype == 'html':
             body_html = body
             body_text = body
         else:
             body_html = body
             body_text = body
-        return self.message_append(cr, uid, ids, subject, body_html, body_text,
-                                    type, parent_id=parent_id,
-                                    content_subtype=content_subtype, context=context)
+        return self.message_append(cr, uid, ids, subject, body_text, body_html,
+                                    type, parent_id = parent_id,
+                                    content_subtype=content_subtype, subtype=subtype, context=context)
 
     #------------------------------------------------------
     # Subscription mechanism
     #------------------------------------------------------
 
+<<<<<<< TREE
     def message_get_monitored_follower_fields(self, cr, uid, ids, context=None):
         """ Returns a list of fields containing a res.user.id. Those fields
             will be checked to automatically subscribe those users.
@@ -1012,6 +1068,15 @@
         return []
 
     def message_subscribe(self, cr, uid, ids, user_ids = None, context=None):
+=======
+    def message_get_monitored_follower_fields(self, cr, uid, ids, context=None):
+        """ Returns a list of fields containing a res.user.id. Those fields
+            will be checked to automatically subscribe those users.
+        """
+        return []
+
+    def message_subscribe(self, cr, uid, ids, user_ids = None, subtype_ids = None, context = None):
+>>>>>>> MERGE-SOURCE
         """ Subscribe the user (or user_ids) to the current document.
             
             :param user_ids: a list of user_ids; if not set, subscribe
@@ -1019,12 +1084,24 @@
             :param return: new value of followers, for Chatter
         """
         to_subscribe_uids = [uid] if user_ids is None else user_ids
+<<<<<<< TREE
         write_res = self.write(cr, uid, ids, {'message_follower_ids': self.message_subscribe_get_command(cr, uid, to_subscribe_uids, context)}, context=context)
         return [follower.id for thread in self.browse(cr, uid, ids, context=context) for follower in thread.message_follower_ids]
 
     def message_subscribe_get_command(self, cr, uid, follower_ids, context=None):
         """ Generate the many2many command to add followers. """
         return [(4, id) for id in follower_ids]
+=======
+        write_res = self.write(cr, uid, ids, {'message_follower_ids': self.message_subscribe_get_command(cr, uid, to_subscribe_uids, context)}, context=context)
+        follower_ids = [follower.id for thread in self.browse(cr, uid, ids, context=context) for follower in thread.message_follower_ids]
+        if subtype_ids:
+            self.pool.get('mail.followers').write(cr, uid, follower_ids, {'subtype_ids': [(6, 0, subtype_ids)]}, context=context)
+        return follower_ids
+
+    def message_subscribe_get_command(self, cr, uid, follower_ids, context=None):
+        """ Generate the many2many command to add followers. """
+        return [(4, id) for id in follower_ids]
+>>>>>>> MERGE-SOURCE
 
     def message_unsubscribe(self, cr, uid, ids, user_ids = None, context=None):
         """ Unsubscribe the user (or user_ids) from the current document.
@@ -1158,10 +1235,25 @@
         for obj in self.browse(cr, uid, ids, context=context):
             if not obj.message_state and self._columns.get('user_id') and obj.user_id and obj.user_id.id == uid:
                 self.message_mark_as_read(cr, uid, [obj.id], context=context)
-    
+
     def message_mark_as_read(self, cr, uid, ids, context=None):
         """ Set as read. """
         return self.write(cr, uid, ids, {'message_state': True}, context=context)
 
-
+    def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids):
+        subscription_obj = self.pool.get('mail.followers')
+        subscription_ids = subscription_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)])
+        return subscription_obj.write(cr, uid, subscription_ids, {'subtype_ids': [6, 0 , subtype_ids]}, context = context) #overright or add new one
+        
+    def message_subscription_remove_subtype(self, cr, uid, ids, user_id, subtype_id):
+        subscription_obj = self.pool.get('mail.followers')
+        subscription_ids = subscription_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)])
+        return subscription_obj.write(cr, uid, subscription_ids, {'subtype_ids': [3, subtype_id]}, context = context) # remove link
+        
+    def message_subscription_remove_subtype_name(self, cr, uid, ids, user_id, subtype_name):
+        subtype_obj = self.pool.get('mail.message.subtype')
+        subtype_ids = subtype_obj.search(cr, uid, [('name', '=', subtype_name), ('model_ids', '=', self._name)])
+        if not subtype_ids:
+            return False
+        self.message_subscription_remove_subtype(cr, uid, ids, user_id, subtype_ids)
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== modified file 'project/project.py'
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to