From a027590d6eca9b65c2fdfe5a2509137e839e42ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 15 May 2013 10:29:39 +0200 Subject: [PATCH] [CLEAN] Some code cleaning about context management bzr revid: tde@openerp.com-20130515082939-oediun6cb9wd87lh --- addons/auth_signup/res_users.py | 6 +++--- addons/survey/wizard/survey_send_invitation.py | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/auth_signup/res_users.py b/addons/auth_signup/res_users.py index 2f7bd553d3d..ab1823df980 100644 --- a/addons/auth_signup/res_users.py +++ b/addons/auth_signup/res_users.py @@ -265,12 +265,12 @@ class res_users(osv.Model): self.pool.get('email.template').send_mail(cr, uid, template.id, user.id, True, context=context) def create(self, cr, uid, values, context=None): + if context is None: + context = {} # overridden to automatically invite user to sign up user_id = super(res_users, self).create(cr, uid, values, context=context) user = self.browse(cr, uid, user_id, context=context) - if user.email and (not context or not context.get('no_reset_password')): - if not context: - context = {} + if user.email and not context.get('no_reset_password'): context.update({'create_user': True}) self.action_reset_password(cr, uid, [user.id], context=context) return user_id diff --git a/addons/survey/wizard/survey_send_invitation.py b/addons/survey/wizard/survey_send_invitation.py index 339a22f1eba..eacc19bf23a 100644 --- a/addons/survey/wizard/survey_send_invitation.py +++ b/addons/survey/wizard/survey_send_invitation.py @@ -190,7 +190,8 @@ Thanks,''') % (name, self.pool.get('ir.config_parameter').get_param(cr, uid, 'we 'action_id': act_id[0], 'survey_id': [[6, 0, survey_ids]] } - user = user_ref.create(cr, uid, res_data, {'no_reset_password': True}) + create_ctx = dict(context, no_reset_password=True) + user = user_ref.create(cr, uid, res_data, context=create_ctx) if user not in new_user: new_user.append(user) created+= "- %s (Login: %s, Password: %s)\n" % (partner.name or _('Unknown'),\