From fcee397b2b51772413354bcea2a04b43cb78e183 Mon Sep 17 00:00:00 2001 From: "Bharat Devnani (OpenERP)" Date: Tue, 3 Apr 2012 18:37:38 +0530 Subject: [PATCH] [ADD] added the functionality of email i.e when the the portal field is true the mail will be sent to the partner, and filter the quotation and sale orders of particular partner through their email address bzr revid: bde@tinyerp.com-20120403130738-08cybydbhnq3q4h3 --- addons/portal_customer/__openerp__.py | 3 +- addons/portal_customer/email_template.xml | 35 +++++++++++++++++++ addons/portal_customer/portal_customer.py | 18 ++++++++-- .../portal_customer/portal_customer_view.xml | 6 ---- addons/sale/security/sale_security.xml | 2 +- 5 files changed, 53 insertions(+), 11 deletions(-) create mode 100644 addons/portal_customer/email_template.xml 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)]