[IMP] in the portal's contact form, only show the 'email' field to anonymous users

bzr revid: abo@openerp.com-20120725142024-btojdzrsvqru4dlk
This commit is contained in:
Antonin Bourguignon 2012-07-25 16:20:24 +02:00
parent 232c567956
commit eb4f3cecb6
2 changed files with 16 additions and 2 deletions

View File

@ -24,7 +24,7 @@ class crm_contact_us(osv.TransientModel):
read datas generated through this module. That's why we'll write those
information in the crm.lead table and leave blank entries in the
portal_crm.crm_contact_us table. This is why the create() method is
overridden.
overwritten.
"""
crm_lead = self.pool.get('crm.lead')
@ -37,6 +37,16 @@ class crm_contact_us(osv.TransientModel):
is figured out.
"""
values['contact_name'] = values['name']
"""
The email_from field only makes sense if the form is submitted by an
anonymous user; otherwise it should be the current user's email.
"""
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
if (user.login != 'anonymous'):
values['email_from'] = user.user_email
crm_lead.create(cr, 1, dict(values,user_id=False), context)
"""

View File

@ -17,7 +17,11 @@
<div class="oe_portal_crm_contact_form">
<field name="name" placeholder="Name"/>
<field name="partner_name" placeholder="Company"/>
<field name="email_from" placeholder="Email"/>
<!--
The email field only makes sense for the anonymous user.
In other cases, it's auto-filled in the python code.
-->
<field name="email_from" placeholder="Email" groups="anonymous.group_anonymous"/>
<field name="phone" placeholder="Phone"/>
<field name="description" placeholder="Your question"/>
<button string="Submit" name="submit" type="object"/>