[MERGE] trunk-portal_crm_test-abo: add a few tests in portal_crm for the contact form
also fix a rights problem in portal and portal_hr_employees bzr revid: abo@openerp.com-20121001154808-gjbudxw2u3xalp5e
This commit is contained in:
@@ -11,9 +11,11 @@
|
||||
!assert {model: crm.lead, id: crm.crm_case_4, string: Lead in open state}:
|
||||
- state == "open"
|
||||
-
|
||||
I create partner from lead.
|
||||
I fill in a lead2partner wizard.
|
||||
-
|
||||
!record {model: crm.lead2partner, id: crm_lead2partner_id1, context: '{"active_model": "crm.lead", "active_ids": [ref("crm_case_4")]}'}:
|
||||
-
|
||||
I create a partner from the lead2partner wizard.
|
||||
-
|
||||
!python {model: crm.lead2partner}: |
|
||||
context.update({'active_model': 'crm.lead', 'active_ids': [ref('crm_case_4')], 'active_id': ref('crm_case_4')})
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_mail_message_portal,mail.message.portal,mail.model_mail_message,group_portal,1,0,1,1
|
||||
access_res_partner,res.partner,base.model_res_partner,portal.group_portal,1,0,0,0
|
||||
access_res_partner_address,res.partner_address,base.model_res_partner_address,portal.group_portal,1,0,0,0
|
||||
access_res_partner_category,res.partner_category,base.model_res_partner_category,portal.group_portal,1,0,0,0
|
||||
access_res_partner_title,res.partner_title,base.model_res_partner_title,portal.group_portal,1,0,0,0
|
||||
|
||||
|
@@ -27,11 +27,14 @@
|
||||
'complexity': 'easy',
|
||||
'description': """
|
||||
This module adds a contact page (with a contact form creating a lead when submitted) to your portal if crm and portal are installed.
|
||||
====================================================================================================================================
|
||||
====================================================================================================================================
|
||||
""",
|
||||
'author': 'OpenERP SA',
|
||||
'depends': ['crm','portal'],
|
||||
'data': ['wizard/contact_view.xml'],
|
||||
'test': [
|
||||
'test/contact_form.yml',
|
||||
],
|
||||
'installable': True,
|
||||
'auto_install': True,
|
||||
'category': 'Hidden',
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
-
|
||||
Set the current user as portal user.
|
||||
-
|
||||
!context
|
||||
'uid': 'portal.demo_user0'
|
||||
-
|
||||
As a portal user, I fill in the contact form and submit it.
|
||||
-
|
||||
!record {model: portal_crm.crm_contact_us, id: contact_us_01}:
|
||||
name: 'Need information about your contact form module'
|
||||
partner_name: 'Mr. John Doe'
|
||||
email_from: 'mister@john.doe'
|
||||
phone: '+32 444 11 22 33'
|
||||
description: 'Dear Sir or Madam, could you get back to me asap ? Regards.'
|
||||
-
|
||||
For security reasons, the wizard values is empty.
|
||||
-
|
||||
!python {model: portal_crm.crm_contact_us}: |
|
||||
obj = self.browse(cr, uid, ref("contact_us_01"))
|
||||
assert not(obj.name or obj.partner_name or obj.email_from or obj.phone or obj.description), 'All the wizard\'s values are not empty'
|
||||
-
|
||||
And a lead is created with the proper values.
|
||||
-
|
||||
!python {model: crm.lead}: |
|
||||
from openerp import SUPERUSER_ID
|
||||
|
||||
ids = self.search(cr, SUPERUSER_ID, [('name', '=', 'Need information about your contact form module')])
|
||||
assert len(ids) == 1, 'There are more than one matching lead, while only one was expected'
|
||||
|
||||
obj = self.browse(cr, SUPERUSER_ID, ids[0])
|
||||
expected_values = dict(
|
||||
name='Need information about your contact form module',
|
||||
partner_name='Mr. John Doe',
|
||||
email_from='mister@john.doe',
|
||||
phone='+32 444 11 22 33',
|
||||
description='Dear Sir or Madam, could you get back to me asap ? Regards.')
|
||||
for k, v in expected_values.iteritems():
|
||||
assert obj[k] == expected_values[k], 'Lead data mismatch: expected %s, got %s' % (expected_values[k], obj[k])
|
||||
@@ -81,8 +81,8 @@ class crm_contact_us(osv.TransientModel):
|
||||
def create(self, cr, uid, values, context=None):
|
||||
"""
|
||||
Since they are potentially sensitive, we don't want any user to be able
|
||||
to read datas generated through this module. That's why we'll write
|
||||
those information directly in the crm.lead table and leave blank
|
||||
to read datas generated through this module. Therefore we'll write
|
||||
these information directly in the crm.lead table and leave blank
|
||||
entries in the portal_crm.crm_contact_us table.
|
||||
This is why the create() method is overwritten.
|
||||
"""
|
||||
@@ -93,8 +93,7 @@ class crm_contact_us(osv.TransientModel):
|
||||
models implied (like mail.thread, among others, that performs a read
|
||||
when its create() method is called (in method message_get_subscribers()),
|
||||
it is quite complicated to set proper rights for this object.
|
||||
Therefore, user SUPERUSER_ID will perform the creation until a better
|
||||
workaround is figured out.
|
||||
Therefore, user SUPERUSER_ID will perform the creation.
|
||||
"""
|
||||
values['contact_name'] = values['name']
|
||||
crm_lead.create(cr, SUPERUSER_ID, dict(values,user_id=False), context)
|
||||
@@ -103,7 +102,8 @@ class crm_contact_us(osv.TransientModel):
|
||||
Create an empty record in the portal_crm.crm_contact_us table.
|
||||
Since the 'name' field is mandatory, give an empty string to avoid an integrity error.
|
||||
"""
|
||||
return super(crm_contact_us, self).create(cr, uid, {'name': ' '})
|
||||
empty_values = dict((k, False) if k != 'name' else (k, '') for k, v in values.iteritems())
|
||||
return super(crm_contact_us, self).create(cr, uid, empty_values)
|
||||
|
||||
def submit(self, cr, uid, ids, context=None):
|
||||
""" When the form is submitted, redirect the user to a "Thanks" message """
|
||||
|
||||
@@ -1,6 +1,2 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_hr_employee_user,hr.employee user,hr.model_hr_employee,portal.group_portal,1,0,0,0
|
||||
access_res_partner,res.partner,base.model_res_partner,portal.group_portal,1,0,0,0
|
||||
access_res_partner_address,res.partner_address,base.model_res_partner_address,portal.group_portal,1,0,0,0
|
||||
access_res_partner_category,res.partner_category,base.model_res_partner_category,portal.group_portal,1,0,0,0
|
||||
access_res_partner_title,res.partner_title,base.model_res_partner_title,portal.group_portal,1,0,0,0
|
||||
|
||||
|
Reference in New Issue
Block a user