summaryrefslogtreecommitdiff
path: root/addons/project_issue/project_issue.py
diff options
context:
space:
mode:
authorHarry (Open ERP) <hmo@tinyerp.com>2010-03-16 18:43:28 +0530
committerHarry (Open ERP) <hmo@tinyerp.com>2010-03-16 18:43:28 +0530
commit0db347d65f9c67f4b114a96874ea120cf7eacdee (patch)
tree14b476a2f5cfca2255c1a289b40a64ce35531dac /addons/project_issue/project_issue.py
parent4b08bc496fe4945b25580d004b7f8745d00f7b15 (diff)
parentb509b2d0867f0283e7876c6ee636f7e18f48f11e (diff)
[MERGE] merged from lp:~openerp-commiter/openobject-addons/crm-improvement
bzr revid: hmo@tinyerp.com-20100316131328-lgttnpy712rqr7ga
Diffstat (limited to 'addons/project_issue/project_issue.py')
-rw-r--r--addons/project_issue/project_issue.py71
1 files changed, 62 insertions, 9 deletions
diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py
index 48492f44675..cfb6961d112 100644
--- a/addons/project_issue/project_issue.py
+++ b/addons/project_issue/project_issue.py
@@ -29,13 +29,50 @@ from tools.translate import _
import tools
from osv import fields,osv,orm
from osv.orm import except_orm
+from datetime import datetime, timedelta
+
from crm import crm
+import time
+
class project_issue(osv.osv):
_name = "project.issue"
_description = "Project Issue"
_order = "priority, id desc"
_inherit = 'crm.case'
+
+ def _compute_openday(self, cr, uid, ids, name, args, context={}):
+ result = {}
+ for r in self.browse(cr, uid, ids , context):
+ result[r.id] = 0
+ model_id = self.pool.get('ir.model').search(cr, uid, [('model', '=', 'project.issue')])
+ log_obj = self.pool.get('crm.case.log')
+ hist_id = log_obj.search(cr, uid, [('model_id', '=', model_id[0]), \
+ ('res_id', '=', r.id), \
+ ('name', '=', 'Open')])
+
+ if hist_id:
+ # Considering last log for opening case
+ log = log_obj.browse(cr, uid, hist_id[-1])
+ date_lead_open = datetime.strptime(r.create_date, "%Y-%m-%d %H:%M:%S")
+ date_log_open = datetime.strptime(log.date, "%Y-%m-%d %H:%M:%S")
+ ans = date_lead_open - date_log_open
+ duration = float(ans.days) + (float(ans.seconds) / 86400)
+ result[r.id] = abs(int(duration))
+ return result
+
+ def _compute_closeday(self, cr, uid, ids, name, args, context={}):
+ result = {}
+ for r in self.browse(cr, uid, ids , context):
+ result[r.id] = 0
+ if r.date_closed:
+ date_create = datetime.strptime(r.create_date, "%Y-%m-%d %H:%M:%S")
+ date_close = datetime.strptime(r.date_closed, "%Y-%m-%d %H:%M:%S")
+ ans = date_close - date_create
+ duration = float(ans.days) + (float(ans.seconds) / 86400)
+ result[r.id] = abs(int(duration))
+ return result
+
_columns = {
'date_closed': fields.datetime('Closed', readonly=True),
'date': fields.datetime('Date'),
@@ -43,17 +80,29 @@ class project_issue(osv.osv):
'ref2' : fields.reference('Reference 2', selection=crm._links_get, size=128),
'canal_id': fields.many2one('res.partner.canal', 'Channel',help="The channels represent the different communication modes available with the customer." \
" With each commercial opportunity, you can indicate the canall which is this opportunity source."),
+ 'planned_revenue': fields.float('Planned Revenue'),
+ 'planned_cost': fields.float('Planned Costs'),
+ 'som': fields.many2one('res.partner.som', 'State of Mind', help="The minds states allow to define a value scale which represents" \
+ "the partner mentality in relation to our services.The scale has" \
+ "to be created with a factor for each level from 0 (Very dissatisfied) to 10 (Extremely satisfied)."),
'categ_id': fields.many2one('crm.case.categ','Category', domain="[('object_id.model', '=', 'crm.project.bug')]"),
- 'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Severity'),
- 'type_id': fields.many2one('crm.case.resource.type', 'Version', domain="[('object_id.model', '=', 'project.issue')]"),
+ 'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
+ 'type_id': fields.many2one('crm.case.resource.type', 'Bug Type', domain="[('object_id.model', '=', 'project.issue')]"),
+
'partner_name': fields.char("Employee's Name", size=64),
'partner_mobile': fields.char('Mobile', size=32),
'partner_phone': fields.char('Phone', size=32),
'stage_id': fields.many2one ('crm.case.stage', 'Stage', domain="[('object_id.model', '=', 'project.issue')]"),
'project_id':fields.many2one('project.project', 'Project'),
- 'duration': fields.float('Duration'),
- 'task_id': fields.many2one('project.task', 'Task', domain="[('project_id','=',project_id)]")
+ 'duration': fields.float('Duration'),
+ 'probability': fields.float('Probability (%)'),
+ 'task_id': fields.many2one('project.task', 'Task', domain="[('project_id','=',project_id)]"),
+ 'day_open': fields.function(_compute_openday, string='Days to Open', \
+ method=True, type="integer", store=True),
+ 'day_close': fields.function(_compute_closeday, string='Days to Close', \
+ method=True, type="integer", store=True),
}
+
def _get_project(self, cr, uid, context):
user = self.pool.get('res.users').browse(cr,uid,uid, context=context)
if user.context_project_id:
@@ -62,10 +111,10 @@ class project_issue(osv.osv):
def _convert(self, cr, uid, ids, xml_id, context=None):
data_obj = self.pool.get('ir.model.data')
- id2 = data_obj._get_id(cr, uid, 'project_issue', xml_id)
+ id2 = data_obj._get_id(cr, uid, 'project_issue', xml_id)
categ_id = False
if id2:
- categ_id = data_obj.browse(cr, uid, id2, context=context).res_id
+ categ_id = data_obj.browse(cr, uid, id2, context=context).res_id
if categ_id:
self.write(cr, uid, ids, {'categ_id': categ_id})
return True
@@ -82,10 +131,14 @@ class project_issue(osv.osv):
stage = self.pool.get('crm.case.stage').browse(cr, uid, stage_id, context)
if not stage.on_change:
return {'value':{}}
- return {'value':{}}
+ return {'value':{'probability':stage.probability}}
_defaults = {
- 'project_id':_get_project,
- }
+ 'project_id':_get_project,
+ 'probability':lambda *a:0.0,
+ 'planned_cost':lambda *a:0.0,
+ 'planned_revenue':lambda *a:0.0,
+ }
+
project_issue()