[IMP] set assign_to when the state is open

[FIX] Recompute the working days
[IMP] Add an onchange event on the project, to assign the project manager for the user_id field
[FIX] Review the reports for the project.issue
[FIX] Use avg instead of sum for the working days
[IMP] Raise a warning if the analytic account is in pending
[FIX] Use the assigned_To user for the worklogs

bzr revid: stephane@openerp.com-20110328094548-pdzuc4ukf8n7743p
This commit is contained in:
Stephane Wirtel
2011-03-28 11:45:48 +02:00
parent 878a554bdb
commit 7e7369face
6 changed files with 52 additions and 21 deletions
+22 -10
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')})
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)
@@ -205,14 +205,14 @@ class project_issue(crm.crm_case, osv.osv):
'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.many2one('res.users', 'Assigned to', required=True, select=1),
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,18 +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,
'assigned_to' : lambda obj, cr, uid, context: uid,
'categ_id' : lambda *a: False,
#'assigned_to' : lambda obj, cr, uid, context: uid,
}
def convert_issue_task(self, cr, uid, ids, context=None):
+1 -1
View File
@@ -53,7 +53,7 @@
<form string="Issue Tracker Form">
<group colspan="4" col="6">
<field name="name"/>
<field name="project_id" required="True"/>
<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"/>
@@ -101,11 +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 res_id from ir_model_data WHERE model = 'crm.case.categ' and name='bug_categ')
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()
@@ -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>
@@ -33,13 +33,31 @@ class project_issue(osv.osv):
def on_change_project(self, cr, uid, ids, project_id, context=None):
if not project_id:
return {}
result = super(project_issue, self).on_change_project(cr, uid, ids, project_id, context=context)
project = self.pool.get('project.project').browse(cr, uid, project_id, context=context)
if 'value' not in result:
result['value'] = {}
account = project.analytic_account_id
if account:
return {'value' : {'analytic_account_id' : account.id}}
else:
result['value']['analytic_account_id'] = account.id
return result
def on_change_account_id(self, cr, uid, ids, account_id, context=None):
if not account_id:
return {}
account = self.pool.get('account.analytic.account').browse(cr, uid, account_id, context=context)
result = {}
if account and account.state == 'pending':
result = {'warning' : {'title' : _('Analytic Account'), 'message' : _('The Analytic Account is in pending !')}}
return result
project_issue()
class account_analytic_line(osv.osv):
@@ -13,15 +13,16 @@
<xpath expr="/form/notebook" position="before">
<field name="analytic_account_id"
domain="[('parent_id','!=',False),('partner_id', '=', partner_id),('type', '!=', 'view')]"
on_change='on_change_account_id(analytic_account_id)'
groups="base.group_extended" />
</xpath>
<notebook colspan="4">
<page string="Worklogs">
<field name="timesheet_ids" colspan="4" nolabel="1" context="{'default_user_id' : user_id, 'default_account_id' : analytic_account_id}">
<field name="timesheet_ids" colspan="4" nolabel="1" context="{'default_user_id' : assigned_to, 'default_account_id' : analytic_account_id}">
<tree editable="top" string="Timesheet">
<field name="name"/>
<field name="unit_amount" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id)" widget="float_time"/>
<field name="account_id" invisible="0" domain="[('partner_id', '=', parent.partner_id)]" on_change="on_change_account_id(account_id)"/>
<field name="name"/>
<field name="unit_amount" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id)" widget="float_time"/>
<field name="account_id" invisible="0" domain="[('partner_id', '=', parent.partner_id)]" on_change="on_change_account_id(account_id)"/>
<field name="date"/>
<field name="user_id"/>
<field invisible="1" name="journal_id"/>