[IMP] improve code
bzr revid: rma@tinyerp.com-20140320112017-03miv5s8jovz0iac
This commit is contained in:
parent
fbb5eea4ba
commit
df53c3f970
|
@ -186,20 +186,7 @@ class project(osv.osv):
|
|||
task_attachments = attachment.search(cr, uid, [('res_model', '=', 'project.task'), ('res_id', 'in', task_ids)], context=context, count=True)
|
||||
res[id] = (project_attachments or 0) + (task_attachments or 0)
|
||||
return res
|
||||
|
||||
# def _task_count(self, cr, uid, ids, field_name, arg, context=None):
|
||||
# """ :deprecated: this method will be removed with OpenERP v8. Use task_ids
|
||||
# fields instead. """
|
||||
# if context is None:
|
||||
# context = {}
|
||||
# res = dict.fromkeys(ids, 0)
|
||||
# ctx = context.copy()
|
||||
# ctx['active_test'] = False
|
||||
# task_ids = self.pool.get('project.task').search(cr, uid, [('project_id', 'in', ids)], context=ctx)
|
||||
# for task in self.pool.get('project.task').browse(cr, uid, task_ids, context):
|
||||
# res[task.project_id.id] += 1
|
||||
# return res
|
||||
def _total_task_count(self, cr, uid, ids, field_name, arg, context=None):
|
||||
def _task_count(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res={}
|
||||
for tasks in self.browse(cr, uid, ids, context):
|
||||
res[tasks.id] = len(tasks.task_ids)
|
||||
|
@ -269,8 +256,7 @@ class project(osv.osv):
|
|||
}),
|
||||
'resource_calendar_id': fields.many2one('resource.calendar', 'Working Time', help="Timetable working hours to adjust the gantt diagram report", states={'close':[('readonly',True)]} ),
|
||||
'type_ids': fields.many2many('project.task.type', 'project_task_type_rel', 'project_id', 'type_id', 'Tasks Stages', states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}),
|
||||
# 'task_count': fields.function(_task_count, type='integer', string="Open Tasks",
|
||||
# deprecated="This field will be removed in OpenERP v8. Use task_ids one2many field instead."),
|
||||
'task_count': fields.function(_task_count, type='integer', string="Tasks",),
|
||||
'task_ids': fields.one2many('project.task', 'project_id',
|
||||
domain=[('stage_id.fold', '=', False)]),
|
||||
'color': fields.integer('Color Index'),
|
||||
|
@ -292,7 +278,6 @@ class project(osv.osv):
|
|||
" is activated, portal users see the followed tasks or issues."),
|
||||
'state': fields.selection([('template', 'Template'),('draft','New'),('open','In Progress'), ('cancelled', 'Cancelled'),('pending','Pending'),('close','Closed')], 'Status', required=True,),
|
||||
'doc_count':fields.function(_get_attached_docs, string="Number of documents attached", type='int'),
|
||||
'total_task_count': fields.function(_total_task_count, string="Task", type='integer'),
|
||||
}
|
||||
|
||||
def _get_type_common(self, cr, uid, context):
|
||||
|
|
|
@ -95,7 +95,7 @@
|
|||
<div class="oe_right oe_button_box" name="buttons" groups="base.group_user">
|
||||
<button class="oe_inline oe_stat_button" type="action" attrs="{'invisible':[('use_tasks','=', 0)]}"
|
||||
name="%(act_project_project_2_project_task_all)d" icon="fa-tasks">
|
||||
<field string="Task" name="total_task_count" widget="statinfo"/>
|
||||
<field string="Task" name="task_count" widget="statinfo"/>
|
||||
</button>
|
||||
<button class="oe_inline oe_stat_button" name="attachment_tree_view" type="object" icon="fa-files-o">
|
||||
<field string="Documents" name="doc_count" widget="statinfo"/>
|
||||
|
@ -243,7 +243,7 @@
|
|||
<field name="user_id"/>
|
||||
<field name="date"/>
|
||||
<field name="color"/>
|
||||
<field name="total_task_count"/>
|
||||
<field name="task_count"/>
|
||||
<field name="task_ids"/>
|
||||
<field name="alias_id"/>
|
||||
<field name="doc_count"/>
|
||||
|
|
|
@ -490,16 +490,7 @@ class project(osv.Model):
|
|||
def _get_alias_models(self, cr, uid, context=None):
|
||||
return [('project.task', "Tasks"), ("project.issue", "Issues")]
|
||||
|
||||
# def _issue_count(self, cr, uid, ids, field_name, arg, context=None):
|
||||
# """ :deprecated: this method will be removed with OpenERP v8. Use issue_ids
|
||||
# fields instead. """
|
||||
# res = dict.fromkeys(ids, 0)
|
||||
# issue_ids = self.pool.get('project.issue').search(cr, uid, [('project_id', 'in', ids)])
|
||||
# for issue in self.pool.get('project.issue').browse(cr, uid, issue_ids, context):
|
||||
# if issue.stage_id and not issue.stage_id.fold:
|
||||
# res[issue.project_id.id] += 1
|
||||
# return res
|
||||
def _total_issue_count(self, cr, uid, ids, field_name, arg, context=None):
|
||||
def _issue_count(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res={}
|
||||
for issues in self.browse(cr, uid, ids, context):
|
||||
res[issues.id] = len(issues.issue_ids)
|
||||
|
@ -508,9 +499,7 @@ class project(osv.Model):
|
|||
'project_escalation_id': fields.many2one('project.project', 'Project Escalation',
|
||||
help='If any issue is escalated from the current Project, it will be listed under the project selected here.',
|
||||
states={'close': [('readonly', True)], 'cancelled': [('readonly', True)]}),
|
||||
# 'issue_count': fields.function(_issue_count, type='integer', string="Unclosed Issues",
|
||||
# deprecated="This field will be removed in OpenERP v8. Use issue_ids one2many field instead."),
|
||||
'total_issue_count': fields.function(_total_issue_count, string="Issue", type='integer'),
|
||||
'issue_count': fields.function(_issue_count, type='integer', string="Issues",),
|
||||
'issue_ids': fields.one2many('project.issue', 'project_id',
|
||||
domain=[('stage_id.fold', '=', False)])
|
||||
}
|
||||
|
|
|
@ -308,7 +308,7 @@
|
|||
<xpath expr='//div[@name="buttons"]' position='inside'>
|
||||
<button class="oe_inline oe_stat_button" type="action" attrs="{'invisible':[('use_issues','=', 0)]}"
|
||||
name="%(act_project_project_2_project_issue_all)d" icon="fa-bug">
|
||||
<field string="Issues" name="total_issue_count" widget="statinfo"/>
|
||||
<field string="Issues" name="issue_count" widget="statinfo"/>
|
||||
</button>
|
||||
</xpath>
|
||||
<xpath expr='//page[@name="project_stages"]' position="attributes">
|
||||
|
|
Loading…
Reference in New Issue