[FIX] crm, project.task, project.issue, hr_recruitment: fixed quick create in kanban, simplified a bit the code in the various create overrides.
bzr revid: tde@openerp.com-20130619114633-pb0rtz0kivlrabcx
This commit is contained in:
parent
3e269d1572
commit
9005541f99
|
@ -89,13 +89,11 @@ class crm_lead(base_stage, format_address, osv.osv):
|
||||||
def create(self, cr, uid, vals, context=None):
|
def create(self, cr, uid, vals, context=None):
|
||||||
if context is None:
|
if context is None:
|
||||||
context = {}
|
context = {}
|
||||||
if not vals.get('stage_id'):
|
if vals.get('type') and not context.get('default_type'):
|
||||||
ctx = context.copy()
|
context['default_type'] = vals.get('type')
|
||||||
if vals.get('section_id'):
|
if vals.get('section_id') and not context.get('default_section_id'):
|
||||||
ctx['default_section_id'] = vals['section_id']
|
context['default_section_id'] = vals.get('section_id')
|
||||||
if vals.get('type'):
|
|
||||||
ctx['default_type'] = vals['type']
|
|
||||||
vals['stage_id'] = self._get_default_stage_id(cr, uid, context=ctx)
|
|
||||||
# context: no_log, because subtype already handle this
|
# context: no_log, because subtype already handle this
|
||||||
create_context = dict(context, mail_create_nolog=True)
|
create_context = dict(context, mail_create_nolog=True)
|
||||||
return super(crm_lead, self).create(cr, uid, vals, context=create_context)
|
return super(crm_lead, self).create(cr, uid, vals, context=create_context)
|
||||||
|
@ -362,12 +360,11 @@ class crm_lead(base_stage, format_address, osv.osv):
|
||||||
def on_change_user(self, cr, uid, ids, user_id, context=None):
|
def on_change_user(self, cr, uid, ids, user_id, context=None):
|
||||||
""" When changing the user, also set a section_id or restrict section id
|
""" When changing the user, also set a section_id or restrict section id
|
||||||
to the ones user_id is member of. """
|
to the ones user_id is member of. """
|
||||||
section_id = False
|
|
||||||
if user_id:
|
if user_id:
|
||||||
section_ids = self.pool.get('crm.case.section').search(cr, uid, ['|', ('user_id', '=', user_id), ('member_ids', '=', user_id)], context=context)
|
section_ids = self.pool.get('crm.case.section').search(cr, uid, ['|', ('user_id', '=', user_id), ('member_ids', '=', user_id)], context=context)
|
||||||
if section_ids:
|
if section_ids:
|
||||||
section_id = section_ids[0]
|
return {'value': {'section_id': section_ids[0]}}
|
||||||
return {'value': {'section_id': section_id}}
|
return {'value': {}}
|
||||||
|
|
||||||
def _check(self, cr, uid, ids=False, context=None):
|
def _check(self, cr, uid, ids=False, context=None):
|
||||||
""" Override of the base.stage method.
|
""" Override of the base.stage method.
|
||||||
|
|
|
@ -240,7 +240,7 @@ class hr_applicant(base_stage, osv.Model):
|
||||||
|
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'active': lambda *a: 1,
|
'active': lambda *a: 1,
|
||||||
'user_id': lambda s, cr, uid, c: uid,
|
'user_id': lambda s, cr, uid, c: uid,
|
||||||
'email_from': lambda s, cr, uid, c: s._get_default_email(cr, uid, c),
|
'email_from': lambda s, cr, uid, c: s._get_default_email(cr, uid, c),
|
||||||
'stage_id': lambda s, cr, uid, c: s._get_default_stage_id(cr, uid, c),
|
'stage_id': lambda s, cr, uid, c: s._get_default_stage_id(cr, uid, c),
|
||||||
'department_id': lambda s, cr, uid, c: s._get_default_department_id(cr, uid, c),
|
'department_id': lambda s, cr, uid, c: s._get_default_department_id(cr, uid, c),
|
||||||
|
@ -253,13 +253,11 @@ class hr_applicant(base_stage, osv.Model):
|
||||||
}
|
}
|
||||||
|
|
||||||
def onchange_job(self, cr, uid, ids, job, context=None):
|
def onchange_job(self, cr, uid, ids, job, context=None):
|
||||||
result = {}
|
|
||||||
|
|
||||||
if job:
|
if job:
|
||||||
job_obj = self.pool.get('hr.job')
|
job_record = self.pool.get('hr.job').browse(cr, uid, job, context=context)
|
||||||
result['department_id'] = job_obj.browse(cr, uid, job, context=context).department_id.id
|
if job_record and job_record.department_id:
|
||||||
return {'value': result}
|
return {'value': {'department_id': job_record.department_id.id}}
|
||||||
return {'value': {'department_id': False}}
|
return {}
|
||||||
|
|
||||||
def onchange_department_id(self, cr, uid, ids, department_id=False, context=None):
|
def onchange_department_id(self, cr, uid, ids, department_id=False, context=None):
|
||||||
obj_recru_stage = self.pool.get('hr.recruitment.stage')
|
obj_recru_stage = self.pool.get('hr.recruitment.stage')
|
||||||
|
@ -401,6 +399,11 @@ class hr_applicant(base_stage, osv.Model):
|
||||||
return super(hr_applicant, self).message_update(cr, uid, ids, msg, update_vals=update_vals, context=context)
|
return super(hr_applicant, self).message_update(cr, uid, ids, msg, update_vals=update_vals, context=context)
|
||||||
|
|
||||||
def create(self, cr, uid, vals, context=None):
|
def create(self, cr, uid, vals, context=None):
|
||||||
|
if context is None:
|
||||||
|
context = {}
|
||||||
|
if vals.get('department_id') and not context.get('default_department_id'):
|
||||||
|
context['default_department_id'] = vals.get('department_id')
|
||||||
|
|
||||||
obj_id = super(hr_applicant, self).create(cr, uid, vals, context=context)
|
obj_id = super(hr_applicant, self).create(cr, uid, vals, context=context)
|
||||||
applicant = self.browse(cr, uid, obj_id, context=context)
|
applicant = self.browse(cr, uid, obj_id, context=context)
|
||||||
if applicant.job_id:
|
if applicant.job_id:
|
||||||
|
|
|
@ -186,6 +186,7 @@
|
||||||
<filter string="Next Actions" context="{'invisible_next_action':False, 'invisible_next_date':False}"
|
<filter string="Next Actions" context="{'invisible_next_action':False, 'invisible_next_date':False}"
|
||||||
domain="[('date_action','<>',False)]" help="Filter and view on next actions and date"/>
|
domain="[('date_action','<>',False)]" help="Filter and view on next actions and date"/>
|
||||||
<field name="job_id"/>
|
<field name="job_id"/>
|
||||||
|
<field name="department_id"/>
|
||||||
<field name="user_id"/>
|
<field name="user_id"/>
|
||||||
<separator/>
|
<separator/>
|
||||||
<field name="categ_ids"/>
|
<field name="categ_ids"/>
|
||||||
|
|
|
@ -584,6 +584,15 @@ class task(base_stage, osv.osv):
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _get_default_partner(self, cr, uid, context=None):
|
||||||
|
""" Override of base_stage to add project specific behavior """
|
||||||
|
project_id = self._get_default_project_id(cr, uid, context)
|
||||||
|
if project_id:
|
||||||
|
partner = self.pool.get('project.project').browse(cr, uid, project_id, context=context).partner_id
|
||||||
|
if partner:
|
||||||
|
return partner.id
|
||||||
|
return super(task, self)._get_default_partner(cr, uid, context=context)
|
||||||
|
|
||||||
def _get_default_project_id(self, cr, uid, context=None):
|
def _get_default_project_id(self, cr, uid, context=None):
|
||||||
""" Gives default section by checking if present in the context """
|
""" Gives default section by checking if present in the context """
|
||||||
return (self._resolve_project_id_from_context(cr, uid, context=context) or False)
|
return (self._resolve_project_id_from_context(cr, uid, context=context) or False)
|
||||||
|
@ -598,7 +607,8 @@ class task(base_stage, osv.osv):
|
||||||
context key, or None if it cannot be resolved to a single
|
context key, or None if it cannot be resolved to a single
|
||||||
project.
|
project.
|
||||||
"""
|
"""
|
||||||
if context is None: context = {}
|
if context is None:
|
||||||
|
context = {}
|
||||||
if type(context.get('default_project_id')) in (int, long):
|
if type(context.get('default_project_id')) in (int, long):
|
||||||
return context['default_project_id']
|
return context['default_project_id']
|
||||||
if isinstance(context.get('default_project_id'), basestring):
|
if isinstance(context.get('default_project_id'), basestring):
|
||||||
|
@ -679,13 +689,11 @@ class task(base_stage, osv.osv):
|
||||||
def onchange_planned(self, cr, uid, ids, planned=0.0, effective=0.0):
|
def onchange_planned(self, cr, uid, ids, planned=0.0, effective=0.0):
|
||||||
return {'value':{'remaining_hours': planned - effective}}
|
return {'value':{'remaining_hours': planned - effective}}
|
||||||
|
|
||||||
def onchange_project(self, cr, uid, id, project_id):
|
def onchange_project(self, cr, uid, id, project_id, context=None):
|
||||||
if not project_id:
|
if project_id:
|
||||||
return {}
|
project = self.pool.get('project.project').browse(cr, uid, project_id, context=context)
|
||||||
data = self.pool.get('project.project').browse(cr, uid, [project_id])
|
if project and project.partner_id:
|
||||||
partner_id=data and data[0].partner_id
|
return {'value': {'partner_id': project.partner_id.id}}
|
||||||
if partner_id:
|
|
||||||
return {'value':{'partner_id':partner_id.id}}
|
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def duplicate_task(self, cr, uid, map_ids, context=None):
|
def duplicate_task(self, cr, uid, map_ids, context=None):
|
||||||
|
@ -808,8 +816,9 @@ class task(base_stage, osv.osv):
|
||||||
'progress': 0,
|
'progress': 0,
|
||||||
'sequence': 10,
|
'sequence': 10,
|
||||||
'active': True,
|
'active': True,
|
||||||
'user_id': lambda obj, cr, uid, context: uid,
|
'user_id': lambda obj, cr, uid, ctx=None: uid,
|
||||||
'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'project.task', context=c),
|
'company_id': lambda self, cr, uid, ctx=None: self.pool.get('res.company')._company_default_get(cr, uid, 'project.task', context=ctx),
|
||||||
|
'partner_id': lambda self, cr, uid, ctx=None: self._get_default_partner(cr, uid, context=ctx),
|
||||||
}
|
}
|
||||||
_order = "priority, sequence, date_start, name, id"
|
_order = "priority, sequence, date_start, name, id"
|
||||||
|
|
||||||
|
@ -1103,11 +1112,9 @@ class task(base_stage, osv.osv):
|
||||||
def create(self, cr, uid, vals, context=None):
|
def create(self, cr, uid, vals, context=None):
|
||||||
if context is None:
|
if context is None:
|
||||||
context = {}
|
context = {}
|
||||||
if not vals.get('stage_id'):
|
if vals.get('project_id') and not context.get('default_project_id'):
|
||||||
ctx = context.copy()
|
context['default_project_id'] = vals.get('project_id')
|
||||||
if vals.get('project_id'):
|
|
||||||
ctx['default_project_id'] = vals['project_id']
|
|
||||||
vals['stage_id'] = self._get_default_stage_id(cr, uid, context=ctx)
|
|
||||||
# context: no_log, because subtype already handle this
|
# context: no_log, because subtype already handle this
|
||||||
create_context = dict(context, mail_create_nolog=True)
|
create_context = dict(context, mail_create_nolog=True)
|
||||||
task_id = super(task, self).create(cr, uid, vals, context=create_context)
|
task_id = super(task, self).create(cr, uid, vals, context=create_context)
|
||||||
|
|
|
@ -65,15 +65,22 @@ class project_issue(base_stage, osv.osv):
|
||||||
def create(self, cr, uid, vals, context=None):
|
def create(self, cr, uid, vals, context=None):
|
||||||
if context is None:
|
if context is None:
|
||||||
context = {}
|
context = {}
|
||||||
if not vals.get('stage_id'):
|
if vals.get('project_id') and not context.get('default_project_id'):
|
||||||
ctx = context.copy()
|
context['default_project_id'] = vals.get('project_id')
|
||||||
if vals.get('project_id'):
|
|
||||||
ctx['default_project_id'] = vals['project_id']
|
|
||||||
vals['stage_id'] = self._get_default_stage_id(cr, uid, context=ctx)
|
|
||||||
# context: no_log, because subtype already handle this
|
# context: no_log, because subtype already handle this
|
||||||
create_context = dict(context, mail_create_nolog=True)
|
create_context = dict(context, mail_create_nolog=True)
|
||||||
return super(project_issue, self).create(cr, uid, vals, context=create_context)
|
return super(project_issue, self).create(cr, uid, vals, context=create_context)
|
||||||
|
|
||||||
|
def _get_default_partner(self, cr, uid, context=None):
|
||||||
|
""" Override of base_stage to add project specific behavior """
|
||||||
|
project_id = self._get_default_project_id(cr, uid, context)
|
||||||
|
if project_id:
|
||||||
|
partner = self.pool.get('project.project').browse(cr, uid, project_id, context=context).partner_id
|
||||||
|
if partner:
|
||||||
|
return partner.id
|
||||||
|
return super(project_issue, self)._get_default_partner(cr, uid, context=context)
|
||||||
|
|
||||||
def _get_default_project_id(self, cr, uid, context=None):
|
def _get_default_project_id(self, cr, uid, context=None):
|
||||||
""" Gives default project by checking if present in the context """
|
""" Gives default project by checking if present in the context """
|
||||||
return self._resolve_project_id_from_context(cr, uid, context=context)
|
return self._resolve_project_id_from_context(cr, uid, context=context)
|
||||||
|
@ -215,6 +222,10 @@ class project_issue(base_stage, osv.osv):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def on_change_project(self, cr, uid, ids, project_id, context=None):
|
def on_change_project(self, cr, uid, ids, project_id, context=None):
|
||||||
|
if project_id:
|
||||||
|
project = self.pool.get('project.project').browse(cr, uid, project_id, context=context)
|
||||||
|
if project and project.partner_id:
|
||||||
|
return {'value': {'partner_id': project.partner_id.id}}
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def _get_issue_task(self, cr, uid, ids, context=None):
|
def _get_issue_task(self, cr, uid, ids, context=None):
|
||||||
|
@ -309,6 +320,7 @@ class project_issue(base_stage, osv.osv):
|
||||||
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.helpdesk', context=c),
|
'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],
|
'priority': crm.AVAILABLE_PRIORITIES[2][0],
|
||||||
'kanban_state': 'normal',
|
'kanban_state': 'normal',
|
||||||
|
'user_id': lambda obj, cr, uid, context: uid,
|
||||||
}
|
}
|
||||||
|
|
||||||
_group_by_full = {
|
_group_by_full = {
|
||||||
|
|
Loading…
Reference in New Issue