[IMP]mail,crm:added a message_state field in mail.thread object and related filter...
authorMayur Maheshwari (OpenERP) <mma@tinyerp.com>
Mon, 30 Apr 2012 07:33:46 +0000 (13:03 +0530)
committerMayur Maheshwari (OpenERP) <mma@tinyerp.com>
Mon, 30 Apr 2012 07:33:46 +0000 (13:03 +0530)
bzr revid: mma@tinyerp.com-20120430073346-dig7dbbpc73ww20p

addons/crm/crm_lead_menu.xml
addons/crm/crm_lead_view.xml
addons/hr_recruitment/hr_recruitment.py
addons/hr_recruitment/hr_recruitment_menu.xml
addons/hr_recruitment/hr_recruitment_view.xml
addons/mail/mail_message.py
addons/mail/mail_message_view.xml
addons/mail/mail_thread.py
addons/project/project_view.xml

index 3cd45fd..5fc8891 100644 (file)
@@ -9,7 +9,7 @@
         <field name="domain">['|', ('type','=','lead'), ('type','=',False)]</field>
         <field name="view_id" ref="crm_case_tree_view_leads"/>
         <field name="search_view_id" ref="crm.view_crm_case_leads_filter"/>
-        <field name="context">{'default_type': 'lead', 'search_default_section_id': section_id, 'stage_type': 'lead'}</field>
+        <field name="context">{'default_type': 'lead', 'search_default_section_id': section_id, 'stage_type': 'lead', 'search_default_inbox': 1}</field>
         <field name="help">
             &lt;img src="http://www.thaicrmsoftware.com/wp-content/uploads/2011/11/lead-conversion.jpg" align="right" style="padding: 6px" width="306" height="223"&gt;
             &lt;h2&gt;Create your first OpenERP Lead &lt;/h2&gt;
index 9557708..30c4fef 100644 (file)
         <field name="type">search</field>
         <field name="arch" type="xml">
             <search string="Search Leads">
+                <filter icon="terp-check" name="inbox" string="Inbox" domain="[('message_state','=','unread')]"/>
                 <filter icon="terp-check"
                     string="New"
                     name="new" help="New Leads"
index 36f81d4..1536b47 100644 (file)
@@ -156,7 +156,7 @@ class hr_applicant(crm.crm_case, osv.osv):
         if stage_ids:
             return self.write(cr, uid, [applicant_id], {'stage_id': stage_ids[0]}, context=context)
         else:
-            return cr.execute("""UPDATE hr_applicant SET state=%s WHERE id=%s""", (field_value, hr_applicant_id))
+            return cr.execute("""UPDATE hr_applicant SET state=%s WHERE id=%s""", (field_value, applicant_id))
     
 
     _columns = {
index 04d73dc..a30d2ee 100644 (file)
@@ -8,7 +8,7 @@
             <field name="res_model">hr.applicant</field>
             <field name="view_mode">kanban,tree,form,graph,calendar</field>
             <field name="view_id" eval="False"/>
-            <field name="context">{'search_default_filter_inprogress':1,'search_default_filter_new':1,"search_default_department_id": department_id}</field>            
+            <field name="context">{'search_default_filter_inprogress':1, 'search_default_filter_new':1, "search_default_department_id": department_id, 'search_default_inbox': 1}</field>            
             <field name="search_view_id" ref="view_crm_case_jobs_filter"/>
             <field name="help">From this menu you can track applicants in the recruitment process and manage all operations: meetings, interviews, phone calls, etc. If you setup the email gateway, applicants and their attached CV are created automatically when an email is sent to jobs@yourcompany.com. If you install the document management modules, all documents (CV and motivation letters) are indexed automatically, so that you can easily search through their content.</field>
         </record>
index 76b73e9..08f20cd 100644 (file)
         <field name="type">search</field>
         <field name="arch" type="xml">
             <search string="Search Jobs">
+               <filter icon="terp-check" name="inbox" string="Inbox" domain="[('message_state','=','unread')]"/>
                <filter icon="terp-document-new" string="New" name="filter_new" 
                    domain="[('state','=','draft')]"
                    help="All Initial Jobs"
index 02814db..a514165 100644 (file)
@@ -218,7 +218,6 @@ class mail_message(osv.osv):
                         ('exception', 'Delivery Failed'),
                         ('cancel', 'Cancelled'),
                         ], 'State', readonly=True),
-        'message_state': fields.selection([('read', 'Read'),('unread', 'Unread')], 'Message State'),
         'auto_delete': fields.boolean('Auto Delete', help="Permanently delete this email after sending it, to save space"),
         'original': fields.binary('Original', help="Original version of the message, as it was sent on the network", readonly=1),
     }
@@ -226,7 +225,6 @@ class mail_message(osv.osv):
     _defaults = {
         'type': 'email',
         'state': 'received',
-        'message_state': 'unread'
     }
     
     #------------------------------------------------------
@@ -525,7 +523,7 @@ class mail_message(osv.osv):
         if context is None:
             context = {}
         if context.get('active_ids', False):
-            self.write(cr, uid, context['active_ids'], {'message_state':'read'}, context=context)
+            self.pool.get(context['active_model']).write(cr, uid, context['active_ids'], {'message_state':'read'}, context=context)
         if message.auto_delete:
             self.pool.get('ir.attachment').unlink(cr, uid,
                                                   [x.id for x in message.attachment_ids \
@@ -588,7 +586,7 @@ class mail_message(osv.osv):
                                                 mail_server_id=message.mail_server_id.id,
                                                 context=context)
                 if res:
-                    message.write({'state':'sent', 'message_id': res, 'message_state': 'read'})
+                    message.write({'state':'sent', 'message_id': res})
                 else:
                     message.write({'state':'exception'})
                 message.refresh()
index fb42e71..b9fce2c 100644 (file)
                             </notebook>
                             <separator string="" colspan="4"/>
                             <group col="6" colspan="6">
-                                <field name="message_state"/>
                                 <field name="state" colspan="2"/>
                                 <field name="subtype" attrs="{'invisible':[('subtype', '=', False)]}"/>
                                 <group colspan="2">
             <field name="type">search</field>
             <field name="arch" type="xml">
                 <search string="Email Search">
-                    <filter icon="terp-check" name="inbox" string="Inbox" domain="[('message_state','=','unread')]"/>
                     <separator orientation="vertical"/>
                     <filter icon="terp-gtk-stop" name="exception" string="Failed" domain="[('state','=','exception')]"/>
                     <separator orientation="vertical"/>
index 8cd8ef4..fc8e475 100644 (file)
@@ -72,6 +72,7 @@ class mail_thread(osv.osv):
     _columns = {
         'message_ids_social': fields.function(_get_message_ids, method=True,
                         type='one2many', obj='mail.message', string='Temp messages', _fields_id = 'res_id'),
+        'message_state': fields.selection([('read', 'Read'),('unread', 'Unread')], 'Message State'),
     }
 
     #------------------------------------------------------
@@ -569,6 +570,7 @@ class mail_thread(osv.osv):
             data.update(custom_values)
         res_id = model_pool.create(cr, uid, data, context=context)
         self.message_append_dict(cr, uid, [res_id], msg_dict, context=context)
+        self.write(cr, uid, [res_id], {'message_state':'unread'}, context)
         return res_id
 
     def message_update(self, cr, uid, ids, msg_dict, vals={}, default_act=None, context=None):
@@ -587,6 +589,7 @@ class mail_thread(osv.osv):
                                 to determine the model of the thread to
                                 update (instead of the current model).
         """
+        self.write(cr, uid, ids, {'message_state':'unread'}, context=context)
         return self.message_append_dict(cr, uid, ids, msg_dict, context=context)
 
     def message_thread_followers(self, cr, uid, ids, context=None):
index f86caea..fe64e67 100644 (file)
             <field name="arch" type="xml">
                <search string="Tasks">
                     <group>
+                        <filter icon="terp-check" name="inbox" string="Inbox" domain="[('message_state','=','unread')]"/>
                         <filter name="draft" string="New" domain="[('state','=','draft')]" help="New Tasks" icon="terp-check"/>
                         <filter name="open" string="In Progress" domain="[('state','=','open')]" help="In Progress Tasks" icon="terp-camera_test"/>
                         <filter string="Pending" domain="[('state','=','pending')]" context="{'show_delegated':False}" help="Pending Tasks" icon="terp-gtk-media-pause"/>
             <field name="view_mode">kanban,tree,form,calendar,gantt,graph</field>
             <field eval="False" name="filter"/>
             <field name="view_id" eval="False"/>
-            <field name="context">{"search_default_project_id": project_id}</field>
+            <field name="context">{"search_default_project_id": project_id, 'search_default_inbox': 1}</field>
             <field name="search_view_id" ref="view_task_search_form"/>
             <field name="help">A task represents a work that has to be done. Each user works in his own list of tasks where he can record his task work in hours. He can work and close the task itself or delegate it to another user. If you delegate a task to another user, you get a new task in pending state, which will be reopened when you have to review the work achieved. If you install the project_timesheet module, task work can be invoiced based on the project configuration. With the project_mrp module, sales orders can create tasks automatically when they are confirmed.</field>
         </record>