[IMP]:project:Used a relate action like 'project.act_project_project_2_project_task_all' instead (easier to configure and maintain) and remove default value for project_id.

bzr revid: apa@tinyerp.com-20120507125708-7gcxl8915us0xoio
This commit is contained in:
Amit Patel (OpenERP) 2012-05-07 18:27:08 +05:30
parent a28980fe61
commit 38fd7fa19d
3 changed files with 16 additions and 41 deletions

View 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)
}

View File

@ -161,6 +161,16 @@
</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>
@ -198,11 +208,11 @@
<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>
@ -397,8 +407,7 @@
</form>
</field>
</record>
<!-- Project Task Kanban View -->
<record model="ir.ui.view" id="view_task_kanban">
<field name="name">project.task.kanban</field>
@ -717,15 +726,6 @@
<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>

View 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.