[IMP]:project:Used a relate action like 'project.act_project_project_2_project_task_a...
authorAmit Patel (OpenERP) <apa@tinyerp.com>
Mon, 7 May 2012 12:57:08 +0000 (18:27 +0530)
committerAmit Patel (OpenERP) <apa@tinyerp.com>
Mon, 7 May 2012 12:57:08 +0000 (18:27 +0530)
bzr revid: apa@tinyerp.com-20120507125708-7gcxl8915us0xoio

addons/project/project.py
addons/project/project_view.xml
addons/project/static/src/js/project.js

index 7916b85..3a65449 100644 (file)
@@ -203,31 +203,7 @@ class project(osv.osv):
         'color': fields.integer('Color Index'),
         'company_uom_id': fields.related('company_id', 'project_time_mode_id', type='many2one', relation='product.uom'),
      }
-    def dummy(self, cr, uid, ids, context=None):
-            return False
          
-    def open_tasks(self, cr, uid, ids, context=None):
-        #Open the View for the Tasks for the project
-        """
-        This opens Tasks views
-        @return :Dictionary value for task view
-        """
-        if context is None:
-            context = {}
-        if ids:
-            context = dict(context, search_default_project_id=ids[0])
-        return {
-            'name': _('Task'),
-            'context': context,
-            'view_type': 'form',
-            'view_mode': 'kanban,tree,calendar,form',
-            'res_model': 'project.task',
-            'view_id': False,
-            'domain':[('project_id','in',ids)],
-            'type': 'ir.actions.act_window',
-            'nodestroy': True
-        }
-    
     def _get_type_common(self, cr, uid, context):
         ids = self.pool.get('project.task.type').search(cr, uid, [('project_default','=',1)], context=context)
         return ids
@@ -757,7 +733,6 @@ class task(osv.osv):
         'sequence': 10,
         'active': True,
         'user_id': lambda obj, cr, uid, context: uid,
-        'project_id':lambda self, cr, uid, context: context.get('active_id',False),
         'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'project.task', context=c)
     }
 
index 3a9a825..1e8b6ce 100644 (file)
             </field>
         </record>
         
+        <act_window
+            context="{'search_default_project_id': [active_id], 'default_project_id': active_id}"
+            id="act_project_project_2_project_task_all"
+            name="Tasks"
+            res_model="project.task"
+            src_model="project.project"
+            view_mode="kanban,tree,form,calendar,graph"
+            view_type="form"/>
+
+        
         <record model="ir.ui.view" id="view_project_kanban">
             <field name="name">project.project.kanban</field>
             <field name="model">project.project</field>
                                     <h4><t t-esc="record.name.value.substr(0,33)"/><t t-if="record.name.value.length > 33">...</t></h4>
                                     <div id="list">
                                         <t t-if="record.use_tasks.raw_value">
-                                            <a id="1" name="open_tasks" class="oe_project_buttons" type="object"><t t-if="record.task_count.value &lt;= 1"> Task</t><t t-if="record.task_count.value &gt; 1"> Tasks</t>(<t t-esc="record.task_count.value"/>)</a>
+                                            <a id="1" name="%(act_project_project_2_project_task_all)d" class="oe_project_buttons" type="action"><t t-if="record.task_count.value &lt;= 1"> Task</t><t t-if="record.task_count.value &gt; 1"> Tasks</t>(<t t-esc="record.task_count.value"/>)</a>
                                         </t>
                                     </div>
                                     <br/>
-                                    <button class="click_button" type="object">
+                                    <button class="click_button" type="action">
                                         <table class="project_fields">
                                             <tr id="deadline" t-if="record.date.raw_value">
                                                 <th align="left">Deadline</th>
                 </form>
             </field>
         </record>
-
-
+        
         <!-- Project Task Kanban View  -->
         <record model="ir.ui.view" id="view_task_kanban">
             <field name="name">project.task.kanban</field>
 
         <act_window context="{'search_default_user_id': [active_id], 'default_user_id': active_id}" id="act_res_users_2_project_project" name="User's projects" res_model="project.project" src_model="res.users" view_mode="tree,form" view_type="form"/>
 
-        <act_window
-            context="{'search_default_project_id': [active_id], 'default_project_id': active_id}"
-            id="act_project_project_2_project_task_all"
-            name="Tasks"
-            res_model="project.task"
-            src_model="project.project"
-            view_mode="tree,form,calendar,graph"
-            view_type="form"/>
-
          <record id="task_company" model="ir.ui.view">
             <field name="name">res.company.task.config</field>
             <field name="model">res.company</field>
index 0017771..27874b2 100644 (file)
@@ -16,9 +16,6 @@ openerp.project = function(openerp) {
                     });
                  });
                 
-                //if task is true , then open the task when click on the anywhere in the box.
-                if(this.record.use_tasks.raw_value)$(this.$element).find('.click_button').attr('data-name','open_tasks');
-                if(!this.record.use_tasks.raw_value)$(this.$element).find('.click_button').attr('data-name','dummy');
                 
                 // set sequence like Tasks,Issues,Timesheets and Phases
                 my_list = $("#list a")
@@ -29,6 +26,9 @@ openerp.project = function(openerp) {
                   });
                 $('#list').replaceWith(my_list);
                 
+                //if task is true , then open the task when click on the anywhere in the box.
+                if(this.record.use_tasks.raw_value)$(this.$element).find('.click_button').attr('data-name',my_list[0].getAttribute('data-name'));
+                
                 /* set background color.
                   we can do other way to implement new widget.
                   because we need to rpc call for that.