Thibault Delavallée (OpenERP) has proposed merging lp:~openerp-dev/openobject-addons/7.0-default_stages-cbi into lp:openobject-addons/7.0.
Requested reviews: OpenERP Core Team (openerp) For more details, see: https://code.launchpad.net/~openerp-dev/openobject-addons/7.0-default_stages-cbi/+merge/142102 -- https://code.launchpad.net/~openerp-dev/openobject-addons/7.0-default_stages-cbi/+merge/142102 Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/7.0-default_stages-cbi.
=== modified file 'crm/crm_lead.py' --- crm/crm_lead.py 2013-01-03 17:03:16 +0000 +++ crm/crm_lead.py 2013-01-07 11:25:35 +0000 @@ -84,17 +84,6 @@ }, } - def create(self, cr, uid, vals, context=None): - if context is None: - context = {} - if not vals.get('stage_id') and vals.get('section_id'): - ctx = context.copy() - ctx['default_section_id'] = vals['section_id'] - vals['stage_id'] = self._get_default_stage_id(cr, uid, context=ctx) - elif not vals.get('stage_id') and context.get('default_section_id'): - vals['stage_id'] = self._get_default_stage_id(cr, uid, context=context) - return super(crm_lead, self).create(cr, uid, vals, context=context) - def _get_default_section_id(self, cr, uid, context=None): """ Gives default section by checking if present in the context """ return self._resolve_section_id_from_context(cr, uid, context=context) or False @@ -986,6 +975,11 @@ 'email_cc': msg.get('cc'), 'user_id': False, }) + + # set default section id in the context to get a correct default stage + if custom_values.get('section_id') and not context.get('default_section_id'): + context['default_section_id'] = custom_values['section_id'] + if msg.get('priority') in dict(crm.AVAILABLE_PRIORITIES): custom_values['priority'] = msg.get('priority') return super(crm_lead, self).message_new(cr, uid, msg, custom_values=custom_values, context=context) === modified file 'project/project.py' --- project/project.py 2013-01-07 11:17:01 +0000 +++ project/project.py 2013-01-07 11:25:35 +0000 @@ -1091,12 +1091,6 @@ def create(self, cr, uid, vals, context=None): if context is None: context = {} - if not vals.get('stage_id') and vals.get('project_id'): - ctx = context.copy() - ctx['default_project_id'] = vals['project_id'] - vals['stage_id'] = self._get_default_stage_id(cr, uid, context=ctx) - elif not vals.get('stage_id') and context.get('default_project_id'): - vals['stage_id'] = self._get_default_stage_id(cr, uid, context=context) task_id = super(task, self).create(cr, uid, vals, context=context) self._store_history(cr, uid, [task_id], context=context) return task_id @@ -1178,6 +1172,11 @@ 'name': msg.get('subject'), 'planned_hours': 0.0, }) + + # set default project id in the context to get a correct default stage + if custom_values.get('project_id') and not context.get('default_project_id'): + context['default_project_id'] = custom_values['project_id'] + return super(task,self).message_new(cr, uid, msg, custom_values=custom_values, context=context) def message_update(self, cr, uid, ids, msg, update_vals=None, context=None): === modified file 'project_issue/project_issue.py' --- project_issue/project_issue.py 2013-01-03 17:03:16 +0000 +++ project_issue/project_issue.py 2013-01-07 11:25:35 +0000 @@ -64,17 +64,6 @@ }, } - def create(self, cr, uid, vals, context=None): - if context is None: - context = {} - if not vals.get('stage_id') and vals.get('project_id'): - ctx = context.copy() - ctx['default_project_id'] = vals['project_id'] - vals['stage_id'] = self._get_default_stage_id(cr, uid, context=ctx) - elif not vals.get('stage_id') and context.get('default_project_id'): - vals['stage_id'] = self._get_default_stage_id(cr, uid, context=context) - return super(project_issue, self).create(cr, uid, vals, context=context) - def _get_default_project_id(self, cr, uid, context=None): """ Gives default project by checking if present in the context """ return self._resolve_project_id_from_context(cr, uid, context=context) @@ -507,6 +496,10 @@ if msg.get('priority'): custom_values['priority'] = msg.get('priority') + # set default project id in the context to get a correct default stage + if custom_values.get('project_id') and not context.get('default_project_id'): + context['default_project_id'] = custom_values['project_id'] + res_id = super(project_issue, self).message_new(cr, uid, msg, custom_values=custom_values, context=context) return res_id
_______________________________________________ Mailing list: https://launchpad.net/~openerp-dev-gtk Post to : openerp-dev-gtk@lists.launchpad.net Unsubscribe : https://launchpad.net/~openerp-dev-gtk More help : https://help.launchpad.net/ListHelp