[imp] merge + cleaning: contract managemeent, not perfect yet, but good enough -> to replace static email one day

bzr revid: fp@tinyerp.com-20111108225337-5muyehnvgqasv44i
This commit is contained in:
Fabien Pinckaers
2011-11-08 23:53:37 +01:00
13 changed files with 209 additions and 28 deletions
+13 -9
View File
@@ -98,26 +98,25 @@ class project_issue(crm.crm_case, osv.osv):
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)
elif field in ['days_since_creation']:
if issue.create_date:
days_since_creation = datetime.today() - datetime.strptime(issue.create_date, "%Y-%m-%d %H:%M:%S")
@@ -139,7 +138,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:
@@ -148,10 +151,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):
@@ -365,7 +370,6 @@ class project_issue(crm.crm_case, osv.osv):
self.write(cr, uid, task.id, {'type_id': index and types[index-1] or False})
return True
def onchange_task_id(self, cr, uid, ids, task_id, context=None):
result = {}
if not task_id:
@@ -383,7 +387,7 @@ 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:
+5 -5
View File
@@ -55,7 +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"/>
<field name="user_id"/>
<field name="version_id" colspan="2" widget="selection"/>
<group colspan="2" col="4">
<field name="type_id" string="Resolution" />
@@ -188,7 +188,7 @@
<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="progress" widget="progressbar"/>
<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"/>
<button name="case_close" string="Done" states="open,draft,pending" type="object" icon="gtk-jump-to"/>
@@ -372,7 +372,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">
@@ -384,8 +384,8 @@
<field name="name" string="Feature description"/>
<field name="user_id"/>
<field name="state">
<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"/>
<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"/>
</field>
<field name="project_id" string="Project"/>
</group>