[IMP] convert button into stat button for project
bzr revid: rajmyt@gmail.com-20140320094614-53ix0c0fdgrzbmsc
This commit is contained in:
parent
750b2e9084
commit
fbb5eea4ba
|
@ -187,19 +187,23 @@ class project(osv.osv):
|
|||
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
|
||||
# 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):
|
||||
res={}
|
||||
for tasks in self.browse(cr, uid, ids, context):
|
||||
res[tasks.id] = len(tasks.task_ids)
|
||||
return res
|
||||
|
||||
def _get_alias_models(self, cr, uid, context=None):
|
||||
""" Overriden in project_issue to offer more options """
|
||||
return [('project.task', "Tasks")]
|
||||
|
@ -265,8 +269,8 @@ 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="Open Tasks",
|
||||
# deprecated="This field will be removed in OpenERP v8. Use task_ids one2many field instead."),
|
||||
'task_ids': fields.one2many('project.task', 'project_id',
|
||||
domain=[('stage_id.fold', '=', False)]),
|
||||
'color': fields.integer('Color Index'),
|
||||
|
@ -287,7 +291,8 @@ class project(osv.osv):
|
|||
"- Followers Only: employees see only the followed tasks or issues; if portal\n"
|
||||
" 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')
|
||||
'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):
|
||||
|
|
|
@ -93,8 +93,13 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="oe_right oe_button_box" name="buttons" groups="base.group_user">
|
||||
<field name="tasks" widget="x2many_counter" string="Tasks" attrs="{'invisible':[('use_tasks','=', False)]}" options='{"views": [[false, "kanban"], [false, "tree"], [false, "form"], [false, "calendar"], [false, "gantt"], [false, "graph"]]}'/>
|
||||
<button name="attachment_tree_view" string="Documents" type="object"/>
|
||||
<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"/>
|
||||
</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"/>
|
||||
</button>
|
||||
</div>
|
||||
<group>
|
||||
<group>
|
||||
|
@ -238,7 +243,7 @@
|
|||
<field name="user_id"/>
|
||||
<field name="date"/>
|
||||
<field name="color"/>
|
||||
<field name="task_count"/>
|
||||
<field name="total_task_count"/>
|
||||
<field name="task_ids"/>
|
||||
<field name="alias_id"/>
|
||||
<field name="doc_count"/>
|
||||
|
|
|
@ -490,22 +490,27 @@ 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
|
||||
# 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):
|
||||
res={}
|
||||
for issues in self.browse(cr, uid, ids, context):
|
||||
res[issues.id] = len(issues.issue_ids)
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'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."),
|
||||
# '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_ids': fields.one2many('project.issue', 'project_id',
|
||||
domain=[('stage_id.fold', '=', False)])
|
||||
}
|
||||
|
|
|
@ -306,7 +306,10 @@
|
|||
<label for="use_issues"/>
|
||||
</xpath>
|
||||
<xpath expr='//div[@name="buttons"]' position='inside'>
|
||||
<button name="%(act_project_project_2_project_issue_all)d" string="Issues" type="action" attrs="{'invisible':[('use_issues','=', 0)]}"/>
|
||||
<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"/>
|
||||
</button>
|
||||
</xpath>
|
||||
<xpath expr='//page[@name="project_stages"]' position="attributes">
|
||||
<attribute name="attrs">{'invisible': [('use_tasks', '=', False),('use_issues','=',False)]}</attribute>
|
||||
|
|
|
@ -102,9 +102,10 @@
|
|||
<label for="use_phases"/>
|
||||
</xpath>
|
||||
<xpath expr="//div[@name='buttons']" position='inside'>
|
||||
<button name="%(act_project_phases)d"
|
||||
string="Phases" type="action"
|
||||
attrs="{'invisible':[('use_phases','=', 0)]}"/>
|
||||
<button class="oe_inline oe_stat_button" type="action"
|
||||
attrs="{'invisible':[('use_phases','=', 0)]}" name="%(act_project_phases)d" icon="fa-qrcode">
|
||||
<field string="Phases" name="phase_count" widget="statinfo"/>
|
||||
</button>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
@ -30,7 +30,10 @@
|
|||
<label for="use_timesheets"/>
|
||||
</xpath>
|
||||
<xpath expr='//div[@name="buttons"]' position="inside">
|
||||
<button name="open_timesheets" string="Timesheets" type="object" attrs="{'invisible':[('use_timesheets','=', 0)]}"/>
|
||||
<button class="oe_inline oe_stat_button" name="open_timesheets" type="object" attrs="{'invisible':[('use_timesheets','=', 0)]}"
|
||||
icon="fa-calendar" widget="statinfo">
|
||||
<field name="hours_quantity" string="Timesheets" widget="statinfo"/>
|
||||
</button>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
|
Loading…
Reference in New Issue