Anto has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-portal_crm_test-abo into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-portal_crm_test-abo/+merge/127313
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-portal_crm_test-abo/+merge/127313
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-portal_crm_test-abo.
=== modified file 'crm/test/process/lead2opportunity2win.yml'
--- crm/test/process/lead2opportunity2win.yml	2012-09-27 16:57:08 +0000
+++ crm/test/process/lead2opportunity2win.yml	2012-10-01 15:45:48 +0000
@@ -11,10 +11,12 @@
   !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')})
      self.make_partner(cr, uid ,[ref("crm_lead2partner_id1")], context=context)

=== modified file 'portal/security/ir.model.access.csv'
--- portal/security/ir.model.access.csv	2012-09-20 07:48:50 +0000
+++ portal/security/ir.model.access.csv	2012-10-01 15:45:48 +0000
@@ -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

=== modified file 'portal_crm/__openerp__.py'
--- portal_crm/__openerp__.py	2012-08-22 13:02:32 +0000
+++ portal_crm/__openerp__.py	2012-10-01 15:45:48 +0000
@@ -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',

=== added directory 'portal_crm/test'
=== added file 'portal_crm/test/contact_form.yml'
--- portal_crm/test/contact_form.yml	1970-01-01 00:00:00 +0000
+++ portal_crm/test/contact_form.yml	2012-10-01 15:45:48 +0000
@@ -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: '[email protected]'
+    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='[email protected]',
+        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])

=== modified file 'portal_crm/wizard/contact.py'
--- portal_crm/wizard/contact.py	2012-09-20 14:57:08 +0000
+++ portal_crm/wizard/contact.py	2012-10-01 15:45:48 +0000
@@ -81,8 +81,8 @@
     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 @@
         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 @@
         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 """

=== modified file 'portal_hr_employees/security/ir.model.access.csv'
--- portal_hr_employees/security/ir.model.access.csv	2012-09-14 13:42:51 +0000
+++ portal_hr_employees/security/ir.model.access.csv	2012-10-01 15:45:48 +0000
@@ -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

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to