diff --git a/addons/portal_crm/__init__.py b/addons/portal_crm/__init__.py index 6b791be9f25..92b3ac62321 100644 --- a/addons/portal_crm/__init__.py +++ b/addons/portal_crm/__init__.py @@ -2,7 +2,7 @@ ############################################################################## # # OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). +# 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 @@ -19,4 +19,4 @@ # ############################################################################## -import wizard +import contact diff --git a/addons/portal_crm/__openerp__.py b/addons/portal_crm/__openerp__.py index 1516ab13961..2eaa829e88a 100644 --- a/addons/portal_crm/__openerp__.py +++ b/addons/portal_crm/__openerp__.py @@ -31,7 +31,9 @@ This module adds a contact page (with a contact form creating a lead when submit """, 'author': 'OpenERP SA', 'depends': ['crm','portal'], - 'data': ['wizard/contact_view.xml'], + 'data': [ + 'contact_view.xml', + ], 'test': [ 'test/contact_form.yml', ], diff --git a/addons/portal_crm/wizard/contact.py b/addons/portal_crm/contact.py similarity index 91% rename from addons/portal_crm/wizard/contact.py rename to addons/portal_crm/contact.py index 09605257a5a..3beed3b3282 100644 --- a/addons/portal_crm/wizard/contact.py +++ b/addons/portal_crm/contact.py @@ -22,14 +22,12 @@ from openerp.osv import osv, fields from openerp import SUPERUSER_ID -class crm_contact_us(osv.TransientModel): +class contact(osv.TransientModel): """ Create new leads through the "contact us" form """ - _name = 'portal_crm.crm_contact_us' + _name = 'contact' _description = 'Contact form for the portal' _inherit = 'crm.lead' _columns = { - 'subject' : fields.char('Subject'), - 'body' : fields.text('Content'), 'company_ids' : fields.many2many('res.company', string='Companies', readonly=True), } @@ -85,7 +83,7 @@ class crm_contact_us(osv.TransientModel): Since they are potentially sensitive, we don't want any user to be able 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. + entries in the contact table. This is why the create() method is overwritten. """ crm_lead = self.pool.get('crm.lead') @@ -98,17 +96,15 @@ class crm_contact_us(osv.TransientModel): Therefore, user SUPERUSER_ID will perform the creation. """ print values - values['name'] = values['subject'] values['contact_name'] = values['partner_name'] - values['description'] = values['body'] crm_lead.create(cr, SUPERUSER_ID, dict(values,user_id=False), context) """ - Create an empty record in the portal_crm.crm_contact_us table. + Create an empty record in the contact table. Since the 'name' field is mandatory, give an empty string to avoid an integrity error. """ 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) + return super(contact, 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 """ diff --git a/addons/portal_crm/wizard/contact_view.xml b/addons/portal_crm/contact_view.xml similarity index 87% rename from addons/portal_crm/wizard/contact_view.xml rename to addons/portal_crm/contact_view.xml index dce8e18a69b..25216d9ff29 100644 --- a/addons/portal_crm/wizard/contact_view.xml +++ b/addons/portal_crm/contact_view.xml @@ -3,10 +3,10 @@ - Wizard form view - portal_crm.crm_contact_us + Contact form + contact -
+

Contact us

@@ -15,8 +15,9 @@ - - + + +