diff options
| author | Randhir Mayatra (OpenERP) <rajmyt@gmail.com> | 2014-03-20 15:16:14 +0530 |
|---|---|---|
| committer | Randhir Mayatra (OpenERP) <rajmyt@gmail.com> | 2014-03-20 15:16:14 +0530 |
| commit | fbb5eea4ba6278b8910f73e20dff2922ff40d236 (patch) | |
| tree | 92cad5bb5f1998c44c5c0b82a90d568530c27bf1 | |
| parent | 750b2e908467f6c5a3dfc3091b810c1b33916f7f (diff) | |
[IMP] convert button into stat button for project
bzr revid: rajmyt@gmail.com-20140320094614-53ix0c0fdgrzbmsc
| -rw-r--r-- | addons/project/project.py | 35 | ||||
| -rw-r--r-- | addons/project/project_view.xml | 11 | ||||
| -rw-r--r-- | addons/project_issue/project_issue.py | 27 | ||||
| -rw-r--r-- | addons/project_issue/project_issue_view.xml | 5 | ||||
| -rw-r--r-- | addons/project_long_term/project_long_term_view.xml | 7 | ||||
| -rw-r--r-- | addons/project_timesheet/project_timesheet_view.xml | 5 |
6 files changed, 56 insertions, 34 deletions
diff --git a/addons/project/project.py b/addons/project/project.py index e5dcf5de2cf..ee6390e4b87 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -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): diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 08738227f5a..45fe175f515 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -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"/> diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index 6f072f5abd1..69ceb7839ca 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -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)]) } diff --git a/addons/project_issue/project_issue_view.xml b/addons/project_issue/project_issue_view.xml index 3af9ee608d6..2b2c48519f9 100644 --- a/addons/project_issue/project_issue_view.xml +++ b/addons/project_issue/project_issue_view.xml @@ -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> diff --git a/addons/project_long_term/project_long_term_view.xml b/addons/project_long_term/project_long_term_view.xml index 36fb83000ce..d6b118eb323 100644 --- a/addons/project_long_term/project_long_term_view.xml +++ b/addons/project_long_term/project_long_term_view.xml @@ -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> diff --git a/addons/project_timesheet/project_timesheet_view.xml b/addons/project_timesheet/project_timesheet_view.xml index 548264eb07b..a51c7976602 100644 --- a/addons/project_timesheet/project_timesheet_view.xml +++ b/addons/project_timesheet/project_timesheet_view.xml @@ -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> |
