diff --git a/addons/portal_customer/__openerp__.py b/addons/portal_customer/__openerp__.py index a3d1005c7f6..29d568be628 100644 --- a/addons/portal_customer/__openerp__.py +++ b/addons/portal_customer/__openerp__.py @@ -37,7 +37,8 @@ "demo_xml" : [ ], "update_xml" : [ - "portal_customer_view.xml" + "portal_customer_view.xml", + "email_template.xml" ], 'installable': True, } diff --git a/addons/portal_customer/email_template.xml b/addons/portal_customer/email_template.xml new file mode 100644 index 00000000000..7093a78afdd --- /dev/null +++ b/addons/portal_customer/email_template.xml @@ -0,0 +1,35 @@ + + + + + + Customer Portal User Confirmation + + ${object.user_id.user_email or object.company_id.email or 'noreply@' + object.company_id.name + '.com'} + ${object.email} + You are registered as a Customer Portal User + + Hello ${object.name}, + + Welcome to our customer portal, now you are a member of our customer portal. + You can access our portal system through following Username and Password: + Your Username : ${object.email} + Your Password : ${object.email} + + For now, your password is same as Username, kindly change as per your convenience. + + Thanks and Warm Regards, + ${object.user_id.name} + + + + + default_email_customer_portal_user + default + + + res.partner + + + + \ No newline at end of file diff --git a/addons/portal_customer/portal_customer.py b/addons/portal_customer/portal_customer.py index afa27aba44b..87a55a21268 100644 --- a/addons/portal_customer/portal_customer.py +++ b/addons/portal_customer/portal_customer.py @@ -30,12 +30,24 @@ class res_partner(osv.osv): 'customer_portal_access': fields.boolean('Portal'), } - def onchange_portal_create_user(self, cr, uid, ids, field, context=None): + def mail_user_confirm(self, cr, uid, ids, context=None): + """ + Send email to user when the event is confirmed + """ + email_template_obj = self.pool.get('email.template') + portal_user_id = self.browse(cr, uid, ids, context=context)[0].id + template_id = email_template_obj.search(cr, uid, [('name','=','Customer Portal User Confirmation')], context=context)[0] + if template_id: + mail_message = email_template_obj.send_mail(cr,uid,template_id,portal_user_id) + return True + + def onchange_portal_create_user(self, cr, uid, ids, customer_portal_access, context=None): res_users_obj = self.pool.get('res.users') - if field == 1: + self.mail_user_confirm(cr, uid, ids) + if customer_portal_access: name = self.browse(cr, uid, ids, context=context)[0].name login = self.browse(cr, uid, ids, context=context)[0].email res_users_obj.create(cr, uid, {'name':name, 'login':login, 'new_password':login}, context=context) - return True + return {} res_partner() \ No newline at end of file diff --git a/addons/portal_customer/portal_customer_view.xml b/addons/portal_customer/portal_customer_view.xml index 06f88f635cd..869785dfc7a 100644 --- a/addons/portal_customer/portal_customer_view.xml +++ b/addons/portal_customer/portal_customer_view.xml @@ -24,12 +24,6 @@ tree,form - - - - diff --git a/addons/sale/security/sale_security.xml b/addons/sale/security/sale_security.xml index ae8c8bf62e3..64c2225d4ab 100644 --- a/addons/sale/security/sale_security.xml +++ b/addons/sale/security/sale_security.xml @@ -58,7 +58,7 @@ Personal Orders - ['|',('user_id','=',user.id),('user_id','=',False)] + ['|',('partner_id.email','=',user.login),('user_id','=',False)]