[MERGE]:merged stages clickable

bzr revid: apa@tinyerp.com-20120730064219-m8nwqjm4l9g341t1
This commit is contained in:
Amit Patel (OpenERP)
2012-07-30 12:12:19 +05:30
8 changed files with 65 additions and 45 deletions
+13 -1
View File
@@ -282,9 +282,21 @@ class crm_lead(base_stage, osv.osv):
if not stage_id:
return {'value':{}}
stage = self.pool.get('crm.case.stage').browse(cr, uid, stage_id, context)
if stage.state == "draft":
return {'value':{'probability': 0.0}}
if stage.state == "open":
cases = self.browse(cr, uid, ids, context=context)
data = {'active': True}
for case in cases:
if case.stage_id and case.stage_id.state == 'draft':
data['date_open'] = fields.datetime.now()
if not case.user_id:
data['user_id'] = uid
return {'value':data}
if not stage.on_change:
return {'value':{}}
return {'value':{'probability': stage.probability}}
else:
return {'value':{'probability': stage.probability}}
def _check(self, cr, uid, ids=False, context=None):
""" Override of the base.stage method.
+1 -9
View File
@@ -428,26 +428,18 @@
<field name="arch" type="xml">
<form string="Opportunities" version="7.0">
<header>
<button name="stage_previous" string="Previous" type="object"
states="open" context="{'stage_type': 'opportunity'}"/>
<button name="stage_next" string="Next" type="object"
states="open" context="{'stage_type': 'opportunity'}"/>
<button name="case_mark_won" string="Mark Won" type="object"
states="open" class="oe_highlight"/>
<button name="case_mark_won" string="Mark Won" type="object"
states="draft,pending"/>
<button name="case_open" string="Open" type="object" class="oe_highlight"
states="draft,pending"/>
<button name="case_escalate" string="Escalate" type="object"
states="open" />
<button name="case_mark_lost" string="Mark Lost" type="object"
states="draft,open"/>
<button name="case_reset" string="Reset to Draft" type="object"
states="done,cancel" />
<button name="case_cancel" string="Cancel" type="object"
states="draft"/>
<field name="stage_id" widget="statusbar"
on_change="onchange_stage_id(stage_id)"/>
on_change="onchange_stage_id(stage_id)" clickable="True"/>
</header>
<sheet>
<div class="oe_right oe_button_box">
+27 -2
View File
@@ -242,6 +242,28 @@ class hr_applicant(base_stage, osv.Model):
_group_by_full = {
'stage_id': _read_group_stage_ids
}
def onchange_stage_id(self, cr, uid, ids, stage_id, context={}):
if context is None:
context = {}
if not stage_id:
return {'value':{}}
stage = self.pool.get('hr.recruitment.stage').browse(cr, uid, stage_id, context)
if stage.state == 'done':
context['onchange'] = True
self.case_close_with_emp(cr, uid, ids, context)
if stage.state == "draft":
return {'value':{'active': True,'date_open': False, 'date_closed': False}}
if stage.state == "open":
cases = self.browse(cr, uid, ids, context=context)
data = {'active': True}
for case in cases:
if case.stage_id and case.stage_id.state == 'draft':
data['date_open'] = fields.datetime.now()
if not case.user_id:
data['user_id'] = uid
return {'value':data}
return {'value':{}}
def onchange_job(self,cr, uid, ids, job, context=None):
result = {}
@@ -407,8 +429,11 @@ class hr_applicant(base_stage, osv.Model):
'address_home_id': address_id,
'department_id': applicant.department_id.id
})
self.write(cr, uid, [applicant.id], {'emp_id': emp_id}, context=context)
self.case_close(cr, uid, [applicant.id], context)
if context.get('onchange'):
return {'value':{'emp_id': emp_id,'active': True, 'date_closed': fields.datetime.now()}}
else:
self.write(cr, uid, [applicant.id], {'emp_id': emp_id}, context=context)
self.case_close(cr, uid, [applicant.id], context)
else:
raise osv.except_osv(_('Warning!'),_('You must define Applied Job for this applicant.'))
+2 -12
View File
@@ -105,21 +105,11 @@
<field name="arch" type="xml">
<form string="Jobs - Recruitment Form" version="7.0">
<header>
<button name="%(action_hr_recruitment_hired_employee)d" string="Hire" type="action"
<button name="case_close_with_emp" string="Hire" type="object"
states="open,pending" class="oe_highlight"/>
<button name="case_open" string="Open" type="object"
states="draft,pending" class="oe_highlight"/>
<button name="case_pending" string="Pending" type="object" invisible="1"
states="open"/>
<button name="case_reset" string="Reset to New" type="object"
states="done,cancel"/>
<button name="case_cancel" string="Refuse" type="object"
states="draft,open,pending" class="oe_highlight"/>
<button name="stage_previous" string="Previous" type="object"
states="open"/>
<button name="stage_next" string="Next" type="object"
states="open"/>
<field name="stage_id" widget="statusbar"/>
<field name="stage_id" widget="statusbar" clickable="True" on_change="onchange_stage_id(stage_id)"/>
</header>
<sheet>
<div class="oe_right oe_button_box">
+1 -7
View File
@@ -402,18 +402,12 @@
states="cancelled,done" context="{'button_reactivate':True}"/>
<button name="action_close" string="Done" type="object"
states="draft,open,pending" class="oe_highlight"/>
<button name="do_pending" string="Pending" type="object"
states="open"/>
<button name="%(action_project_task_delegate)d" string="Delegate" type="action"
states="pending,open,draft" groups="project.group_delegate_task"/>
<button name="do_cancel" string="Cancel" type="object"
states="draft,open,pending"/>
<button name="stage_previous" string="Previous Stage" type="object"
states="open,pending" icon="gtk-go-back" attrs="{'invisible': [('stage_id','=', False)]}"/>
<button name="stage_next" string="Next Stage" type="object" class="oe_highlight"
states="open,pending" icon="gtk-go-forward" attrs="{'invisible': [('stage_id','=', False)]}"/>
</span>
<field name="stage_id" widget="statusbar"/>
<field name="stage_id" widget="statusbar" clickable="True"/>
</header>
<sheet string="Task">
<label for="name" class="oe_edit_only"/>
+19
View File
@@ -397,6 +397,25 @@ class project_issue(base_stage, osv.osv):
res = super(project_issue, self).case_reset(cr, uid, ids, context)
self.write(cr, uid, ids, {'date_open': False, 'date_closed': False})
return res
def onchange_stage_id(self, cr, uid, ids, stage_id, context={}):
if context is None:
context = {}
if not stage_id:
return {'value':{}}
stage = self.pool.get('project.task.type').browse(cr, uid, stage_id, context)
if stage.state == "draft":
return {'value':{'active': True,'date_open': False, 'date_closed': False}}
if stage.state == "open":
cases = self.browse(cr, uid, ids, context=context)
data = {'active': True}
for case in cases:
if case.stage_id and case.stage_id.state == 'draft':
data['date_open'] = fields.datetime.now()
if not case.user_id:
data['user_id'] = uid
return {'value':data}
return {'value':{}}
def create(self, cr, uid, vals, context=None):
obj_id = super(project_issue, self).create(cr, uid, vals, context=context)
+1 -13
View File
@@ -93,28 +93,16 @@
<form version="7.0">
<header>
<span groups="base.group_user">
<button name="case_open" string="Open" type="object"
states="draft,pending" class="oe_highlight"/>
<button name="case_close" string="Done" type="object"
states="open"/>
<button name="case_close" string="Done" type="object"
states="draft,pending"/>
<button name="case_pending" string="Pending" type="object"
states="draft,open"/>
<button name="case_escalate" string="Escalate" type="object"
states="draft,open,pending"/>
<button name="case_reset" string="Reset to New" type="object"
states="cancelled,done"/>
<button name="stage_previous" string="Previous Stage" type="object"
states="open,pending" icon="gtk-go-back"
attrs="{'invisible': [('stage_id','=', False)]}"/>
<button name="stage_next" string="Next Stage" type="object"
states="open,pending" icon="gtk-go-forward"
attrs="{'invisible': [('stage_id','=', False)]}"/>
<button name="case_cancel" string="Cancel" type="object"
states="draft,open,pending"/>
</span>
<field name="stage_id" widget="statusbar"/>
<field name="stage_id" widget="statusbar" on_change="onchange_stage_id(stage_id)" clickable="True"/>
</header>
<sheet string="Issue">
<label for="name" class="oe_edit_only"/>
+1 -1
View File
@@ -9,7 +9,7 @@
<field name="inherit_id" ref="crm.crm_case_form_view_oppor"/>
<field name="arch" type="xml">
<data>
<xpath expr="/form/header/button[@name='stage_previous']" position="before">
<xpath expr="/form/header/button[@name='case_mark_won']" position="before">
<button string="Convert to Quote" name="%(action_crm_make_sale)d" type="action" class="oe_highlight"/>
</xpath>
</data>