From 58aeaa48aeec688f7445e4ada079ba80c2e8cc8a Mon Sep 17 00:00:00 2001 From: "Bharat Devnani (OpenERP)" Date: Mon, 2 Apr 2012 18:58:03 +0530 Subject: [PATCH 1/9] [ADD] created portal customer module, kept boolean field on res.partner object if the field is true the user is created bzr revid: bde@tinyerp.com-20120402132803-0oa084aw0k95myid --- addons/portal_customer/__init__.py | 24 ++++++++++ addons/portal_customer/__openerp__.py | 45 +++++++++++++++++++ addons/portal_customer/portal_customer.py | 41 +++++++++++++++++ .../portal_customer/portal_customer_view.xml | 36 +++++++++++++++ 4 files changed, 146 insertions(+) create mode 100644 addons/portal_customer/__init__.py create mode 100644 addons/portal_customer/__openerp__.py create mode 100644 addons/portal_customer/portal_customer.py create mode 100644 addons/portal_customer/portal_customer_view.xml diff --git a/addons/portal_customer/__init__.py b/addons/portal_customer/__init__.py new file mode 100644 index 00000000000..4a812a97cb5 --- /dev/null +++ b/addons/portal_customer/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2011 OpenERP S.A (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +import portal_customer + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/portal_customer/__openerp__.py b/addons/portal_customer/__openerp__.py new file mode 100644 index 00000000000..a3d1005c7f6 --- /dev/null +++ b/addons/portal_customer/__openerp__.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2011 OpenERP S.A (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +{ + 'name' : "Portal Customer", + 'version' : "1.0", + 'depends' : ["sale"], + 'author' : "OpenERP SA", + 'category': 'Portal', + 'description': """ + The Portal Customer module helps customers to track their Sales Quotations, Orders, Invoices and various + other possibilities + """, + 'website': 'http://www.openerp.com', + 'data': [ + ], + "init_xml" : [ + ], + "demo_xml" : [ + ], + "update_xml" : [ + "portal_customer_view.xml" + ], + 'installable': True, +} + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/portal_customer/portal_customer.py b/addons/portal_customer/portal_customer.py new file mode 100644 index 00000000000..afa27aba44b --- /dev/null +++ b/addons/portal_customer/portal_customer.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2011 OpenERP S.A (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import fields, osv +from tools.translate import _ +import time + +class res_partner(osv.osv): + + _inherit = 'res.partner' + _columns = { + 'customer_portal_access': fields.boolean('Portal'), + } + + def onchange_portal_create_user(self, cr, uid, ids, field, context=None): + res_users_obj = self.pool.get('res.users') + if field == 1: + 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 + +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 new file mode 100644 index 00000000000..06f88f635cd --- /dev/null +++ b/addons/portal_customer/portal_customer_view.xml @@ -0,0 +1,36 @@ + + + + + + + + + res.partner.form + res.partner + + form + + + + + + + + + Contacts + res.partner + form + tree,form + + + + + + + + + + \ No newline at end of file From fcee397b2b51772413354bcea2a04b43cb78e183 Mon Sep 17 00:00:00 2001 From: "Bharat Devnani (OpenERP)" Date: Tue, 3 Apr 2012 18:37:38 +0530 Subject: [PATCH 2/9] [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)] From ae2cdf7a498ab34bfb1f1d41d14220ca17f4798d Mon Sep 17 00:00:00 2001 From: "Bharat Devnani (OpenERP)" Date: Wed, 4 Apr 2012 19:00:45 +0530 Subject: [PATCH 3/9] [ADD] Added access rights to the portal user through demo data bzr revid: bde@tinyerp.com-20120404133045-klv8f8b9wci8hw0y --- addons/portal_customer/__init__.py | 1 - addons/portal_customer/__openerp__.py | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/portal_customer/__init__.py b/addons/portal_customer/__init__.py index 4a812a97cb5..55ddb5dd2bf 100644 --- a/addons/portal_customer/__init__.py +++ b/addons/portal_customer/__init__.py @@ -20,5 +20,4 @@ ############################################################################## import portal_customer - # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/portal_customer/__openerp__.py b/addons/portal_customer/__openerp__.py index 29d568be628..1028f98a4f5 100644 --- a/addons/portal_customer/__openerp__.py +++ b/addons/portal_customer/__openerp__.py @@ -22,7 +22,7 @@ { 'name' : "Portal Customer", 'version' : "1.0", - 'depends' : ["sale"], + 'depends' : ["sale","portal"], 'author' : "OpenERP SA", 'category': 'Portal', 'description': """ @@ -37,8 +37,10 @@ "demo_xml" : [ ], "update_xml" : [ +# "security/ir.model.access.csv", "portal_customer_view.xml", - "email_template.xml" + "email_template.xml", + "portal_demo.xml" ], 'installable': True, } From 4bfaf289513b24f74048cf20ba6bbab56f457b4b Mon Sep 17 00:00:00 2001 From: "Bharat Devnani (OpenERP)" Date: Thu, 5 Apr 2012 10:29:01 +0530 Subject: [PATCH 4/9] [ADD] Added access rights, menus, groups to the portal user through demo data bzr revid: bde@tinyerp.com-20120405045901-ngchas7m8qqc26o1 --- addons/portal_customer/portal_demo.xml | 81 ++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 addons/portal_customer/portal_demo.xml diff --git a/addons/portal_customer/portal_demo.xml b/addons/portal_customer/portal_demo.xml new file mode 100644 index 00000000000..3bc08fe9e76 --- /dev/null +++ b/addons/portal_customer/portal_demo.xml @@ -0,0 +1,81 @@ + + + + + + + + + Sale Order + + True + + + + Sale Order Line + + True + + + + Stock Picking + + True + + + + + Account Invoice + + True + + + + + Account Invoice Line + + True + + + + + + Personal Leads + + ['|',('partner_id.email','=',user.login),('user_id','=',False)] + + + + + Personal Leads + + [('partner_id.email','=',user.login)] + + + + + Personal Leads + + [('partner_id.email','=',user.login)] + + + + + Sales Portal + + + + + + + + + \ No newline at end of file From e43743e54bab08877d11b8fbe19b4e69775a7a55 Mon Sep 17 00:00:00 2001 From: "Bharat Devnani (OpenERP)" Date: Fri, 6 Apr 2012 10:27:25 +0530 Subject: [PATCH 5/9] [ADD] hidden menus which are not required for portal user, added access rights through csv file bzr revid: bde@tinyerp.com-20120406045725-7vjc5rbxf3u0vlhv --- addons/portal_customer/__openerp__.py | 6 +++--- addons/portal_customer/portal_customer_view.xml | 15 +++++++++++++++ addons/portal_customer/portal_demo.xml | 16 ++++++---------- .../portal_customer/security/ir.model.access.csv | 2 ++ 4 files changed, 26 insertions(+), 13 deletions(-) create mode 100755 addons/portal_customer/security/ir.model.access.csv diff --git a/addons/portal_customer/__openerp__.py b/addons/portal_customer/__openerp__.py index 1028f98a4f5..167c97f6574 100644 --- a/addons/portal_customer/__openerp__.py +++ b/addons/portal_customer/__openerp__.py @@ -37,10 +37,10 @@ "demo_xml" : [ ], "update_xml" : [ -# "security/ir.model.access.csv", "portal_customer_view.xml", - "email_template.xml", - "portal_demo.xml" +# "email_template.xml", + "portal_demo.xml", + "security/ir.model.access.csv", ], 'installable': True, } diff --git a/addons/portal_customer/portal_customer_view.xml b/addons/portal_customer/portal_customer_view.xml index 869785dfc7a..af64cdd8052 100644 --- a/addons/portal_customer/portal_customer_view.xml +++ b/addons/portal_customer/portal_customer_view.xml @@ -24,6 +24,21 @@ tree,form + + + + + + + + + + + + + + + diff --git a/addons/portal_customer/portal_demo.xml b/addons/portal_customer/portal_demo.xml index 3bc08fe9e76..6cdc8d76586 100644 --- a/addons/portal_customer/portal_demo.xml +++ b/addons/portal_customer/portal_demo.xml @@ -32,18 +32,12 @@ Account Invoice True - Account Invoice Line True - @@ -68,14 +62,16 @@ - + Sales Portal + - + - + + - \ No newline at end of file + diff --git a/addons/portal_customer/security/ir.model.access.csv b/addons/portal_customer/security/ir.model.access.csv new file mode 100755 index 00000000000..2c29e0159ad --- /dev/null +++ b/addons/portal_customer/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_sale_order_portal,sale.order,sale.model_sale_order,portal_customer.group_sale_access_portal,1,0,0,0 From ac3215f026806ee06e7b1a66eb2162826fca2bf2 Mon Sep 17 00:00:00 2001 From: "Bharat Devnani (OpenERP)" Date: Fri, 6 Apr 2012 14:17:29 +0530 Subject: [PATCH 6/9] [REM] removed access rights, menu_access, model_access from portal_customer/portal_demo.xml file bzr revid: bde@tinyerp.com-20120406084729-t3exodo18zy80l4l --- .../portal_customer/portal_customer_view.xml | 8 ++-- addons/portal_customer/portal_demo.xml | 44 +------------------ 2 files changed, 5 insertions(+), 47 deletions(-) diff --git a/addons/portal_customer/portal_customer_view.xml b/addons/portal_customer/portal_customer_view.xml index 7ebfc9ac843..3108f051c3b 100644 --- a/addons/portal_customer/portal_customer_view.xml +++ b/addons/portal_customer/portal_customer_view.xml @@ -7,13 +7,13 @@ - - - + + + - + diff --git a/addons/portal_customer/portal_demo.xml b/addons/portal_customer/portal_demo.xml index 3bc08fe9e76..3d6fdb3285a 100644 --- a/addons/portal_customer/portal_demo.xml +++ b/addons/portal_customer/portal_demo.xml @@ -7,46 +7,6 @@ Sale Portal Demo --> - - Sale Order - - True - - - - Sale Order Line - - True - - - - Stock Picking - - True - - - - - Account Invoice - - True - - - - - Account Invoice Line - - True - - - - Personal Leads @@ -70,10 +30,8 @@ Sales Portal - - + - From baaa86f9cd6c4f3c522dd2fd94b4707648917ce5 Mon Sep 17 00:00:00 2001 From: "Bharat Devnani (OpenERP)" Date: Mon, 9 Apr 2012 10:20:34 +0530 Subject: [PATCH 7/9] [ADD] added the menu items and assigned proper groups accordingly and improved the module bzr revid: bde@tinyerp.com-20120409045034-xtqy3gt5lh53dp3r --- addons/portal_customer/__openerp__.py | 2 +- .../portal_customer/portal_customer_view.xml | 27 +++++++++++++++---- addons/portal_customer/portal_demo.xml | 7 ++--- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/addons/portal_customer/__openerp__.py b/addons/portal_customer/__openerp__.py index fcecb007808..57a45822b34 100644 --- a/addons/portal_customer/__openerp__.py +++ b/addons/portal_customer/__openerp__.py @@ -38,8 +38,8 @@ ], "update_xml" : [ # "security/ir.model.access.csv", + "portal_demo.xml", "portal_customer_view.xml", - "portal_demo.xml" ], 'installable': True, } diff --git a/addons/portal_customer/portal_customer_view.xml b/addons/portal_customer/portal_customer_view.xml index 3108f051c3b..311fa3b9199 100644 --- a/addons/portal_customer/portal_customer_view.xml +++ b/addons/portal_customer/portal_customer_view.xml @@ -4,16 +4,16 @@ - + - - - + + + - + @@ -28,6 +28,23 @@ + + + + + + + + + + + + + + + + + diff --git a/addons/portal_customer/portal_demo.xml b/addons/portal_customer/portal_demo.xml index 3d6fdb3285a..95fe69490bd 100644 --- a/addons/portal_customer/portal_demo.xml +++ b/addons/portal_customer/portal_demo.xml @@ -8,21 +8,21 @@ --> - Personal Leads + Personal Quotations/Sales ['|',('partner_id.email','=',user.login),('user_id','=',False)] - Personal Leads + Personal Delivery Orders [('partner_id.email','=',user.login)] - Personal Leads + Personal Account Invoices [('partner_id.email','=',user.login)] @@ -30,6 +30,7 @@ Sales Portal + From d42aeae5f0149ed37f26a00eeacb1aeffe5cfbba Mon Sep 17 00:00:00 2001 From: "Bharat Devnani (OpenERP)" Date: Mon, 9 Apr 2012 18:53:22 +0530 Subject: [PATCH 8/9] [ADD] added action on menu's of portal_customer, and made some improvement on rules and added sale own leads group in sales portal group bzr revid: bde@tinyerp.com-20120409132322-it5qz8pk5nq45e81 --- .../portal_customer/portal_customer_view.xml | 24 ++++++++++--------- addons/portal_customer/portal_demo.xml | 8 +++---- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/addons/portal_customer/portal_customer_view.xml b/addons/portal_customer/portal_customer_view.xml index 311fa3b9199..9cea57cefd7 100644 --- a/addons/portal_customer/portal_customer_view.xml +++ b/addons/portal_customer/portal_customer_view.xml @@ -2,23 +2,25 @@ - - - - - - - - - + + + + + + + + + + + - + - + diff --git a/addons/portal_customer/portal_demo.xml b/addons/portal_customer/portal_demo.xml index 95fe69490bd..fc54c1c1e02 100644 --- a/addons/portal_customer/portal_demo.xml +++ b/addons/portal_customer/portal_demo.xml @@ -11,27 +11,27 @@ Personal Quotations/Sales ['|',('partner_id.email','=',user.login),('user_id','=',False)] - + Personal Delivery Orders [('partner_id.email','=',user.login)] - + Personal Account Invoices [('partner_id.email','=',user.login)] - + Sales Portal - + From 99ccf6c0b93505f17ed3e998321fdbb738cdcf67 Mon Sep 17 00:00:00 2001 From: "Bharat Devnani (OpenERP)" Date: Tue, 10 Apr 2012 18:59:38 +0530 Subject: [PATCH 9/9] [IMP] improved the file names, added the access rights through csv files, added action for payment and ir.rule bzr revid: bde@tinyerp.com-20120410132938-3ahgqwhpmutuer0c --- addons/portal_customer/__openerp__.py | 4 +-- .../portal_customer/portal_customer_view.xml | 33 ++++++++++++------- .../security/ir.model.access.csv | 2 ++ .../portal_security.xml} | 25 ++++++++++++-- 4 files changed, 48 insertions(+), 16 deletions(-) create mode 100644 addons/portal_customer/security/ir.model.access.csv rename addons/portal_customer/{portal_demo.xml => security/portal_security.xml} (62%) diff --git a/addons/portal_customer/__openerp__.py b/addons/portal_customer/__openerp__.py index 57a45822b34..95684874770 100644 --- a/addons/portal_customer/__openerp__.py +++ b/addons/portal_customer/__openerp__.py @@ -37,8 +37,8 @@ "demo_xml" : [ ], "update_xml" : [ -# "security/ir.model.access.csv", - "portal_demo.xml", + "security/portal_security.xml", + "security/ir.model.access.csv", "portal_customer_view.xml", ], 'installable': True, diff --git a/addons/portal_customer/portal_customer_view.xml b/addons/portal_customer/portal_customer_view.xml index 9cea57cefd7..3dfe3ef69c0 100644 --- a/addons/portal_customer/portal_customer_view.xml +++ b/addons/portal_customer/portal_customer_view.xml @@ -16,7 +16,7 @@ - + @@ -31,13 +31,13 @@ - - - - - - - + + + + + + + @@ -45,9 +45,20 @@ - - - + + + + + + + + Feeds + 0 + + + + + diff --git a/addons/portal_customer/security/ir.model.access.csv b/addons/portal_customer/security/ir.model.access.csv new file mode 100644 index 00000000000..9ba5a09311d --- /dev/null +++ b/addons/portal_customer/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_account_voucher,account.voucher,account_voucher.model_account_voucher,portal_customer.group_sales_portal,1,1,1,1 \ No newline at end of file diff --git a/addons/portal_customer/portal_demo.xml b/addons/portal_customer/security/portal_security.xml similarity index 62% rename from addons/portal_customer/portal_demo.xml rename to addons/portal_customer/security/portal_security.xml index fc54c1c1e02..b204107f49f 100644 --- a/addons/portal_customer/portal_demo.xml +++ b/addons/portal_customer/security/portal_security.xml @@ -28,13 +28,32 @@ - - Sales Portal + + Personal Payments + + [('partner_id.email','=',user.login)] + + + + + Personal Contacts + + [('email','=',user.login)] + + + + + Sales Portal Group - + + + Sales Portal + + + \ No newline at end of file