summaryrefslogtreecommitdiff
path: root/addons/project_issue
diff options
context:
space:
mode:
authorThibault Francois <tfr@openerp.com>2011-04-07 13:41:45 +0200
committerThibault Francois <tfr@openerp.com>2011-04-07 13:41:45 +0200
commitb11a71fd8751bc4fb33faa1f95f7915e230b86ab (patch)
tree15aa10c814bd240a7f3a6e2ae6cff0ae67b296de /addons/project_issue
parent1a45ff614d9da8c39a120335d2f84ac454c47417 (diff)
[MERGE] improvement project-issue
bzr revid: tfr@openerp.com-20110407114145-xvr27pjquxwk9ff0
Diffstat (limited to 'addons/project_issue')
-rw-r--r--addons/project_issue/project_issue.py39
-rw-r--r--addons/project_issue/project_issue_view.xml37
-rw-r--r--addons/project_issue/report/project_issue_report.py7
-rw-r--r--addons/project_issue/report/project_issue_report_view.xml4
4 files changed, 50 insertions, 37 deletions
diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py
index aaaff37305e..a8a32847243 100644
--- a/addons/project_issue/project_issue.py
+++ b/addons/project_issue/project_issue.py
@@ -43,9 +43,9 @@ project_issue_version()
class project_issue(crm.crm_case, osv.osv):
_name = "project.issue"
_description = "Project Issue"
- _order = "priority, id desc"
+ _order = "priority, create_date desc"
_inherit = ['mailgate.thread']
-
+
def case_open(self, cr, uid, ids, *args):
"""
@param self: The object pointer
@@ -56,7 +56,7 @@ class project_issue(crm.crm_case, osv.osv):
"""
res = super(project_issue, self).case_open(cr, uid, ids, *args)
- self.write(cr, uid, ids, {'date_open': time.strftime('%Y-%m-%d %H:%M:%S')})
+ self.write(cr, uid, ids, {'date_open': time.strftime('%Y-%m-%d %H:%M:%S'), 'assigned_to' : uid})
for (id, name) in self.name_get(cr, uid, ids):
message = _("Issue '%s' has been opened.") % name
self.log(cr, uid, id, message)
@@ -175,7 +175,7 @@ class project_issue(crm.crm_case, osv.osv):
'section_id': fields.many2one('crm.case.section', 'Sales Team', \
select=True, help='Sales team to which Case belongs to.\
Define Responsible user and Email account for mail gateway.'),
- 'user_id': fields.many2one('res.users', 'Responsible'),
+ 'user_id': fields.related('project_id', 'user_id', type='many2one', relation='res.users', store=True, select=1, string='Responsible'),
'partner_id': fields.many2one('res.partner', 'Partner'),
'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', \
domain="[('partner_id','=',partner_id)]"),
@@ -200,19 +200,19 @@ class project_issue(crm.crm_case, osv.osv):
'partner_name': fields.char("Employee's Name", size=64),
'partner_mobile': fields.char('Mobile', size=32),
'partner_phone': fields.char('Phone', size=32),
- 'type_id': fields.many2one ('project.task.type', 'Resolution'),
+ 'type_id': fields.many2one ('project.task.type', 'Resolution', domain="[('project_ids', '=', project_id)]"),
'project_id':fields.many2one('project.project', 'Project'),
'duration': fields.float('Duration'),
'task_id': fields.many2one('project.task', 'Task', domain="[('project_id','=',project_id)]"),
'day_open': fields.function(_compute_day, string='Days to Open', \
- method=True, multi='day_open', type="float", store=True),
+ method=True, multi='compute_day', type="float", store=True),
'day_close': fields.function(_compute_day, string='Days to Close', \
- method=True, multi='day_close', type="float", store=True),
- 'assigned_to': fields.related('task_id', 'user_id', string = 'Assigned to', type="many2one", relation="res.users", store=True, help='This is the current user to whom the related task have been assigned'),
+ method=True, multi='compute_day', type="float", store=True),
+ 'assigned_to': fields.many2one('res.users', 'Assigned to', required=False, select=1),
'working_hours_open': fields.function(_compute_day, string='Working Hours to Open the Issue', \
- method=True, multi='working_days_open', type="float", store=True),
+ method=True, multi='compute_day', type="float", store=True),
'working_hours_close': fields.function(_compute_day, string='Working Hours to Close the Issue', \
- method=True, multi='working_days_close', type="float", store=True),
+ method=True, multi='compute_day', type="float", store=True),
'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model','=',_name)]),
'date_action_last': fields.datetime('Last Action', readonly=1),
'date_action_next': fields.datetime('Next Action', readonly=1),
@@ -230,17 +230,30 @@ class project_issue(crm.crm_case, osv.osv):
return user.context_project_id.id
return False
+ def on_change_project(self, cr, uid, ids, project_id, context=None):
+ result = {}
+
+ if project_id:
+ project = self.pool.get('project.project').browse(cr, uid, project_id, context=context)
+ if project.user_id:
+ result['value'] = {'user_id' : project.user_id.id}
+
+ return result
+
+
_defaults = {
'active': 1,
- 'user_id': crm.crm_case._get_default_user,
+ #'user_id': crm.crm_case._get_default_user,
'partner_id': crm.crm_case._get_default_partner,
'partner_address_id': crm.crm_case._get_default_partner_address,
- 'email_from': crm.crm_case. _get_default_email,
+ 'email_from': crm.crm_case._get_default_email,
'state': 'draft',
- 'section_id': crm.crm_case. _get_section,
+ 'section_id': crm.crm_case._get_section,
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.helpdesk', context=c),
'priority': crm.AVAILABLE_PRIORITIES[2][0],
'project_id':_get_project,
+ 'categ_id' : lambda *a: False,
+ #'assigned_to' : lambda obj, cr, uid, context: uid,
}
def convert_issue_task(self, cr, uid, ids, context=None):
diff --git a/addons/project_issue/project_issue_view.xml b/addons/project_issue/project_issue_view.xml
index 36c0e4ba82f..2224527e9d2 100644
--- a/addons/project_issue/project_issue_view.xml
+++ b/addons/project_issue/project_issue_view.xml
@@ -52,13 +52,14 @@
<field name="arch" type="xml">
<form string="Issue Tracker Form">
<group colspan="4" col="6">
- <field name="name"/>
- <field name="project_id" required="True"/>
- <field name="categ_id" widget="selection" domain="[('object_id.model', '=', 'project.issue')]"/>
- <field name="user_id"/>
- <field name="assigned_to" />
+ <field name="name"/>
+ <field name="project_id" required="True" on_change="on_change_project(project_id)"/>
+ <field name="categ_id" widget="selection" domain="[('object_id.model', '=', 'project.issue')]"/>
+ <field name="user_id" invisible="1" />
+ <field name="assigned_to"/>
+ <field name="version_id" colspan="2" widget="selection"/>
<group colspan="2" col="4">
- <field name="type_id" readonly="1"/>
+ <field name="type_id" string="Resolution" />
<button name="prev_type" string="Previous" type="object" icon="gtk-go-back" help="Change to Previous Stage"/>
<button name="next_type" string="Next" type="object" icon="gtk-go-forward" help="Change to Next Stage"/>
</group>
@@ -73,7 +74,6 @@
</group>
<group col="3" colspan="2">
<separator colspan="3" string="Status"/>
- <field name="version_id" colspan="3" widget="selection"/>
<field name="priority" colspan="3"/>
<field name="task_id" on_change="onchange_task_id(task_id)"/>
<button string="Convert To Task" name="convert_issue_task" icon="gtk-index" type="object"
@@ -184,12 +184,11 @@
<field name="partner_id" groups="base.group_extended"/>
<field name="project_id" />
<field name="priority" string="Priority"/>
- <field name="type_id" widget="selection" readonly="1"/>
+ <field name="type_id" widget="selection" readonly="1" string="Resolution" />
<button name="prev_type" string="Previous" type="object" icon="gtk-go-back" help="Change to Previous Stage"/>
<button name="next_type" string="Next" type="object" icon="gtk-go-forward" help="Change to Next Stage"/>
<field name="version_id" widget="selection"/>
- <field name="user_id"/>
- <field name="assigned_to" attrs="{'readonly':[('task_id','=',False)]}"/>
+ <field name="assigned_to"/>
<field name="progress" widget="progressbar" attrs="{'invisible':[('task_id','=',False)]}"/>
<field name="state"/>
<button name="case_cancel" string="Cancel" states="draft,open,pending" type="object" icon="gtk-cancel"/>
@@ -218,8 +217,8 @@
<separator orientation="vertical"/>
<field name="name"/>
<field name="partner_id" groups="base.group_extended"/>
- <field name="user_id">
- <filter domain="[('user_id','=',False)]" help="Unassigned Issues" icon="terp-personal-" separator="1"/>
+ <field name="assigned_to">
+ <filter domain="[('assigned_to','=',False)]" help="Unassigned Issues" icon="terp-personal-" separator="1"/>
</field>
<field name="project_id"/>
</group>
@@ -233,7 +232,7 @@
<newline/>
<group expand="0" string="Group By..." groups="base.group_extended">
<filter string="Responsible" icon="terp-personal"
- domain="[]" context="{'group_by':'user_id'}" />
+ domain="[]" context="{'group_by':'assigned_to'}" />
<filter string="Partner" icon="terp-partner" domain="[]"
context="{'group_by':'partner_id'}" />
<separator orientation="vertical"/>
@@ -264,7 +263,7 @@
<field name="type">calendar</field>
<field name="priority" eval="2"/>
<field name="arch" type="xml">
- <calendar string="Issues" date_start="date" color="user_id" date_delay="duration">
+ <calendar string="Issues" date_start="date" color="assigned_to" date_delay="duration">
<field name="name"/>
<field name="partner_id"/>
</calendar>
@@ -285,11 +284,11 @@
<field name="name" string="Feature description"/>
<field name="partner_id" groups="base.group_extended"/>
<field name="priority" string="Priority"/>
- <field name="type_id" widget="selection" readonly="1"/>
- <button name="prev_type" string="Previous" type="object" icon="gtk-go-back" help="Change to Previous Stage"/>
- <button name="next_type" string="Next" type="object" icon="gtk-go-forward" help="Change to Next Stage"/>
+ <field name="type_id" widget="selection" readonly="1"/>
+ <button name="prev_type" string="Previous" type="object" icon="gtk-go-back" help="Change to Previous Stage"/>
+ <button name="next_type" string="Next" type="object" icon="gtk-go-forward" help="Change to Next Stage"/>
<field name="version_id"/>
- <field name="user_id"/>
+ <field name="assigned_to"/>
<field name="state"/>
<button name="case_cancel" string="Cancel" states="draft,open,pending" type="object" icon="gtk-cancel"/>
<button name="case_close" string="Done" states="open,draft,pending" type="object" icon="gtk-jump-to"/>
@@ -312,7 +311,7 @@
<separator orientation="vertical"/>
<group>
<field name="name" select='1' string="Feature description"/>
- <field name="user_id" select="1"/>
+ <field name="assigned_to" select="1"/>
<field name="state" select="1">
<filter icon="terp-check" domain="[('state','in',('open','draft'))]" help="Current Features" name="current_feature"/>
<filter icon="terp-camera_test" domain="[('state','=','open')]" help="Open Features"/>
diff --git a/addons/project_issue/report/project_issue_report.py b/addons/project_issue/report/project_issue_report.py
index b66963569e7..29542f32912 100644
--- a/addons/project_issue/report/project_issue_report.py
+++ b/addons/project_issue/report/project_issue_report.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
@@ -16,7 +16,7 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
@@ -101,10 +101,11 @@ class project_issue_report(osv.osv):
c.task_id,
date_trunc('day',c.create_date) as create_date,
extract('epoch' from (c.date_open-c.create_date))/(3600*24) as delay_open,
- extract('epoch' from (c.date_closed-c.create_date))/(3600*24) as delay_close,
+ extract('epoch' from (c.date_closed-c.date_open))/(3600*24) as delay_close,
(SELECT count(id) FROM mailgate_message WHERE model='project.issue' AND res_id=c.id) AS email
FROM
project_issue c
+ WHERE c.categ_id IN (select id from crm_case_categ where object_id in (select id from ir_model where model = 'project.issue'))
)""")
project_issue_report()
diff --git a/addons/project_issue/report/project_issue_report_view.xml b/addons/project_issue/report/project_issue_report_view.xml
index 4ca0fbf2279..015a7750548 100644
--- a/addons/project_issue/report/project_issue_report_view.xml
+++ b/addons/project_issue/report/project_issue_report_view.xml
@@ -28,8 +28,8 @@
<field name="nbr" string="#Project Issues" sum='#Number of Project Issues'/>
<field name="delay_open" avg='Avg Opening Delay'/>
<field name="delay_close" avg='Avg Closing Delay'/>
- <field name="working_hours_open" sum='Open Working Hours'/>
- <field name="working_hours_close" sum='Close Working hours'/>
+ <field name="working_hours_open" avg='Open Working Hours'/>
+ <field name="working_hours_close" avg='Close Working hours'/>
<field name="email" sum='# Emails'/>
</tree>
</field>