[ADD] a new link module portal_crm; this will contain the 'contact us' form of the portal, creating new leads
bzr revid: abo@openerp.com-20120525133015-w8kjkobk4s370svk
This commit is contained in:
parent
e9b97f6bbe
commit
54de5b4f8a
|
@ -111,41 +111,6 @@ the portal's users.
|
|||
<field name="view_id" ref="base.view_company_form" />
|
||||
</record>
|
||||
|
||||
<!--
|
||||
<record id="action_contact_us" model="ir.actions.act_window">
|
||||
<field name="name">Contact Us</field>
|
||||
<field name="model"></field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
-->
|
||||
|
||||
<!-- contact wizard form view -->
|
||||
<!--
|
||||
<record id="wizard_form_view" model="ir.ui.view">
|
||||
<field name="name">Contact wizard form view</field>
|
||||
<field name="model"></field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Subscribe Attendees">
|
||||
<field name="session_ids" colspan="4"/>
|
||||
<field name="attendee_ids" colspan="4">
|
||||
<tree editable="bottom">
|
||||
<field name="name"/>
|
||||
<field name="partner_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
<group colspan="4">
|
||||
<button string="Cancel" icon="gtk-cancel"
|
||||
special="cancel"/>
|
||||
<button string="Subscribe" icon="gtk-ok"
|
||||
name="action_subscribe" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
-->
|
||||
|
||||
|
||||
|
||||
<!-- module's menu -->
|
||||
|
@ -167,7 +132,6 @@ the portal's users.
|
|||
<menuitem name="News" id="portal_company_news" parent="portal_company"/>
|
||||
<menuitem name="Jobs" id="portal_company_jobs" parent="portal_company"/>
|
||||
<menuitem name="Address Book" id="portal_company_address_book" parent="portal_company" action="base.action_partner_form"/>
|
||||
<!-- <menuitem name="Contact Us" id="portal_company_contact" parent="portal_company" action="action_contact_us"/> -->
|
||||
<menuitem name="About" id="portal_company_about" parent="portal_company" action="action_about"/>
|
||||
|
||||
</data>
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import wizard
|
|
@ -0,0 +1,42 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
||||
{
|
||||
'name': 'Portal CRM',
|
||||
'version': '0.1',
|
||||
'category': 'Tools',
|
||||
'complexity': "easy",
|
||||
'description': """
|
||||
This module adds the menu if crm and portal are installed.
|
||||
""",
|
||||
'author': 'OpenERP SA',
|
||||
'depends': ['crm','portal'],
|
||||
'data': [
|
||||
'security/ir.model.access.csv',
|
||||
'wizard/contact_view.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'auto_install':True,
|
||||
'category':'Hidden',
|
||||
|
||||
}
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,2 @@
|
|||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
from openerp.osv import osv, fields
|
||||
|
||||
class crm_contact_us(osv.TransientModel):
|
||||
""" Create new leads through the "contact us" form """
|
||||
_name = 'portal_crm.crm_contact_us'
|
||||
_description = 'Contact form for the portal'
|
||||
_inherit = 'crm.lead'
|
||||
|
||||
def create(self, cr, uid, values, context=None):
|
||||
"""
|
||||
Since they 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 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.
|
||||
"""
|
||||
crm_lead = self.pool.get('crm.lead')
|
||||
|
||||
"""
|
||||
Because of the complex inheritance of the crm.lead model and the other
|
||||
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 #1 will perform the creation until a better workaround
|
||||
is figured out.
|
||||
"""
|
||||
crm_lead.create(cr, 1, dict(values,create_uid=uid), context)
|
||||
|
||||
""" Create an empty record in the portal_crm.crm_contact_us table """
|
||||
return super(crm_contact_us, self).create(cr, uid, {})
|
||||
|
||||
def submit(self, cr, uid, ids, context=None):
|
||||
""" When the form is submitted, redirect the user to a "Thanks" message """
|
||||
return {'type': 'ir.actions.act_window',
|
||||
'view_mode': 'form',
|
||||
'view_type': 'form',
|
||||
'res_model': self._name,
|
||||
'res_id': ids[0],
|
||||
'view_id': self.pool.get('ir.model.data').get_object_reference(cr, uid, 'portal_crm', 'wizard_contact_form_view_thanks')[1]
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- wizard action -->
|
||||
<record id="action_wizard_contact_us" model="ir.actions.act_window">
|
||||
<field name="name">Contact Us</field>
|
||||
<field name="res_model">portal_crm.crm_contact_us</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">inline</field>
|
||||
</record>
|
||||
|
||||
<!-- attach it to the portal menu -->
|
||||
<menuitem name="Contact Us" id="portal_company_contact"
|
||||
parent="portal.portal_company" action="action_wizard_contact_us"/>
|
||||
|
||||
<!-- wizard form view -->
|
||||
<record id="wizard_contact_form_view" model="ir.ui.view">
|
||||
<field name="name">Wizard form view</field>
|
||||
<field name="model">portal_crm.crm_contact_us</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Contact Us wizard view">
|
||||
<group col="2">
|
||||
<field name="name"/>
|
||||
<field name="email_from"/>
|
||||
<group colspan="2">
|
||||
<button string="Submit" icon="gtk-ok" name="submit" type="object"/>
|
||||
</group>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- wizard thanks message (shows after submitting the form) -->
|
||||
<record id="wizard_contact_form_view_thanks" model="ir.ui.view">
|
||||
<field name="name">Wizard thanks message</field>
|
||||
<field name="model">portal_crm.crm_contact_us</field>
|
||||
<field name="type">form</field>
|
||||
<!-- give it a low priority to ensure this won't be the default view -->
|
||||
<field name="priority">99</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Thank you">
|
||||
<!--
|
||||
make sure there is at least one field in the view,
|
||||
otherwise the orm will try to select all the model's
|
||||
records and this will result in a permission denied error
|
||||
-->
|
||||
<field name="name" invisible="1"/>
|
||||
<label string="Thank you"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue