[FIX] Set the user_id (Responsible) field when the user clicks up on the "Open" button.

[FIX] There was a bug in the computation function for the working_hours, delay_open, ... fields.
[FIX] The user_id (Responsible) is replaced by a many2one instead of a related field.
[IMP] Escalation: The user_id (Responsible) is the project manager of the project escalation, if there is no project manager, let's empty.

bzr revid: stephane@openerp.com-20110422114605-nlle7h9mpqq9yj00
This commit is contained in:
Stephane Wirtel 2011-04-22 13:46:05 +02:00
parent dcf034bd52
commit c56df04360
3 changed files with 42 additions and 30 deletions

View File

@ -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'), 'assigned_to' : uid})
self.write(cr, uid, ids, {'date_open': time.strftime('%Y-%m-%d %H:%M:%S'), 'user_id' : uid})
for (id, name) in self.name_get(cr, uid, ids):
message = _("Issue '%s' has been opened.") % name
self.log(cr, uid, id, message)
@ -90,32 +90,32 @@ class project_issue(crm.crm_case, osv.osv):
res = {}
for issue in self.browse(cr, uid, ids, context=context):
res[issue.id] = {}
for field in fields:
res[issue.id] = {}
duration = 0
ans = False
hours = 0
date_create = datetime.strptime(issue.create_date, "%Y-%m-%d %H:%M:%S")
if field in ['working_hours_open','day_open']:
if issue.date_open:
date_create = datetime.strptime(issue.create_date, "%Y-%m-%d %H:%M:%S")
date_open = datetime.strptime(issue.date_open, "%Y-%m-%d %H:%M:%S")
ans = date_open - date_create
date_until = issue.date_open
#Calculating no. of working hours to open the issue
hours = cal_obj.interval_hours_get(cr, uid, issue.project_id.resource_calendar_id.id,
datetime.strptime(issue.create_date, '%Y-%m-%d %H:%M:%S'),
datetime.strptime(issue.date_open, '%Y-%m-%d %H:%M:%S'))
date_create,
date_open)
elif field in ['working_hours_close','day_close']:
if issue.date_closed:
date_create = datetime.strptime(issue.create_date, "%Y-%m-%d %H:%M:%S")
date_close = datetime.strptime(issue.date_closed, "%Y-%m-%d %H:%M:%S")
date_until = issue.date_closed
ans = date_close - date_create
#Calculating no. of working hours to close the issue
hours = cal_obj.interval_hours_get(cr, uid, issue.project_id.resource_calendar_id.id,
datetime.strptime(issue.create_date, '%Y-%m-%d %H:%M:%S'),
datetime.strptime(issue.date_closed, '%Y-%m-%d %H:%M:%S'))
date_create,
date_close)
if ans:
resource_id = False
if issue.user_id:
@ -125,7 +125,11 @@ class project_issue(crm.crm_case, osv.osv):
duration = float(ans.days)
if issue.project_id and issue.project_id.resource_calendar_id:
duration = float(ans.days) * 24
new_dates = cal_obj.interval_min_get(cr, uid, issue.project_id.resource_calendar_id.id, datetime.strptime(issue.create_date, '%Y-%m-%d %H:%M:%S'), duration, resource=resource_id)
new_dates = cal_obj.interval_min_get(cr, uid,
issue.project_id.resource_calendar_id.id,
date_create,
duration, resource=resource_id)
no_days = []
date_until = datetime.strptime(date_until, '%Y-%m-%d %H:%M:%S')
for in_time, out_time in new_dates:
@ -134,10 +138,12 @@ class project_issue(crm.crm_case, osv.osv):
if out_time > date_until:
break
duration = len(no_days)
if field in ['working_hours_open','working_hours_close']:
res[issue.id][field] = hours
else:
res[issue.id][field] = abs(float(duration))
return res
def _get_issue_task(self, cr, uid, ids, context=None):
@ -175,7 +181,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.related('project_id', 'user_id', type='many2one', relation='res.users', store=True, select=1, string='Responsible'),
'user_id' : fields.many2one('res.users', 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)]"),
@ -282,7 +288,7 @@ class project_issue(crm.crm_case, osv.osv):
'date': bug.date,
'project_id': bug.project_id.id,
'priority': bug.priority,
'user_id': bug.assigned_to.id,
'user_id': bug.user_id.id,
'planned_hours': 0.0,
})
@ -362,13 +368,10 @@ class project_issue(crm.crm_case, osv.osv):
"""
cases = self.browse(cr, uid, ids)
for case in cases:
data = {}
data = {'state' : 'draft'}
if case.project_id.project_escalation_id:
data['project_id'] = case.project_id.project_escalation_id.id
if case.project_id.project_escalation_id.user_id:
data['user_id'] = case.project_id.project_escalation_id.user_id.id
if case.task_id:
self.pool.get('project.task').write(cr, uid, [case.task_id.id], {'project_id': data['project_id'], 'user_id': False})
data['user_id'] = case.project_id.project_escalation_id.user_id and case.project_id.project_escalation_id.user_id.id or False
else:
raise osv.except_osv(_('Warning !'), _('You cannot escalate this issue.\nThe relevant Project has not configured the Escalation Project!'))
self.write(cr, uid, [case.id], data)
@ -487,6 +490,14 @@ class project_issue(crm.crm_case, osv.osv):
return super(project_issue, self).copy(cr, uid, id, default=default,
context=context)
#def set_reply_to(self, cr, uid, oid, values, context=None):
# default_value = False
# if oid:
# this = self.browse(cr, uid, oid, context=context)[0]
# if this.section_id:
# values['reply_to'] = this.section_id.email or default_value
project_issue()
class project(osv.osv):

View File

@ -55,8 +55,7 @@
<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="user_id" invisible="0" />
<field name="version_id" colspan="2" widget="selection"/>
<group colspan="2" col="4">
<field name="type_id" string="Resolution" />
@ -75,7 +74,7 @@
<group col="3" colspan="2">
<separator colspan="3" string="Status"/>
<field name="priority" colspan="3"/>
<field name="task_id" on_change="onchange_task_id(task_id)"/>
<field name="task_id" />
<button string="Convert To Task" name="convert_issue_task" icon="gtk-index" type="object"
attrs="{'invisible':[('task_id','!=',False)]}" />
<field name="progress" colspan="3" widget="progressbar" attrs="{'invisible':[('task_id','=',False)]}"/>
@ -188,7 +187,7 @@
<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="assigned_to"/>
<field name="user_id"/>
<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"/>
@ -217,8 +216,8 @@
<separator orientation="vertical"/>
<field name="name"/>
<field name="partner_id" groups="base.group_extended"/>
<field name="assigned_to">
<filter domain="[('assigned_to','=',False)]" help="Unassigned Issues" icon="terp-personal-" separator="1"/>
<field name="user_id">
<filter domain="[('user_id','=',False)]" help="Unassigned Issues" icon="terp-personal-" separator="1"/>
</field>
<field name="project_id"/>
</group>
@ -232,7 +231,7 @@
<newline/>
<group expand="0" string="Group By..." groups="base.group_extended">
<filter string="Responsible" icon="terp-personal"
domain="[]" context="{'group_by':'assigned_to'}" />
domain="[]" context="{'group_by':'user_id'}" />
<filter string="Partner" icon="terp-partner" domain="[]"
context="{'group_by':'partner_id'}" />
<separator orientation="vertical"/>
@ -263,7 +262,7 @@
<field name="type">calendar</field>
<field name="priority" eval="2"/>
<field name="arch" type="xml">
<calendar string="Issues" date_start="date" color="assigned_to" date_delay="duration">
<calendar string="Issues" date_start="date" color="user_id" date_delay="duration">
<field name="name"/>
<field name="partner_id"/>
</calendar>
@ -288,7 +287,7 @@
<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="assigned_to"/>
<field name="user_id"/>
<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"/>
@ -301,7 +300,7 @@
</record>
<record id="view_project_feature_filter" model="ir.ui.view">
<field name="name">Project Issue- Feature Tracker Search</field>
<field name="name">Project Issue - Feature Tracker Search</field>
<field name="model">project.issue</field>
<field name="type">search</field>
<field name="arch" type="xml">
@ -311,7 +310,7 @@
<separator orientation="vertical"/>
<group>
<field name="name" select='1' string="Feature description"/>
<field name="assigned_to" select="1"/>
<field name="user_id" 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"/>

View File

@ -89,7 +89,7 @@
</field>
<field name="project_id"/>
<field name="user_id" select="1" widget="selection"/>
<field name="user_id" select="1"/>
</group>
<newline/>
<group expand="0" string="Extended Filters..." colspan="10" col="12" groups="base.group_extended">
@ -154,8 +154,10 @@
<field name="name">Issues Analysis</field>
<field name="res_model">project.issue.report</field>
<field name="view_type">form</field>
<field name="view_mode">graph,tree</field>
<field name="context">{'search_default_This Month':1,'search_default_project':1,'group_by_no_leaf':1,'group_by':[]}</field>
<field name="view_mode">graph,tree</field>
<!--<field name="context">{'search_default_This Month':1,'search_default_project':1,'group_by_no_leaf':1,'group_by':[]}</field>
-->
<field name="context">{'search_default_Current' : 1, 'search_default_month' : 1}</field>
<field name="view_id" ref="view_project_issue_report_tree"/>
<field name="search_view_id" ref="view_project_issue_report_filter"/>
<field name="help">This report on the project issues allows you to analyse the quality of your support or after-sales services. You can track the issues per age. You can analyse the time required to open or close an issue, the number of email to exchange and the time spent on average by issues.</field>