Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ o8_*/
/*.conf
/*.init
/*.log
/*.pid

#pycharm
.idea/

#Mac OSX
.DS_*
1 change: 1 addition & 0 deletions addons-loaded/website_crm_sendmail
1 change: 1 addition & 0 deletions addons-own/website_crm_extended/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import controllers
48 changes: 48 additions & 0 deletions addons-own/website_crm_extended/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
# Copyright (C) 2010-2012 OpenERP s.a. (<http://openerp.com>).
#
# 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': "website_crm_extended",
'summary': """Send E-Mail to company mail address for contact form of website""",
'description': """

website_crm_sendmail
====================

A very simple addon to post an additional Chatter notification with better information on lead creation
if someone uses the oddo cms contact form. Also it sets the sales team for the new lead to website sales so you could
configure the follwoers and therefore the external mails send.

This is also the place to add additional extensions to the website.crm addon (the website contact form of odoo):

- Added: Add res.partner to lead if E-Mail or name matches

""",
'author': "OpenAT",
'website': "http://www.openat.at/",
'category': 'Uncategorized',
'version': '0.1',
'depends': [
'base', 'website_crm',
],
'installable': True,
}
1 change: 1 addition & 0 deletions addons-own/website_crm_extended/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import main
47 changes: 47 additions & 0 deletions addons-own/website_crm_extended/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-

# since this is no standard model.Model class but a http.Controller class the inheritance mechanisms of odoo would not
# work so we have to use classic python inheritance
# import openerp.addons.website_crm.controllers.main as main

from openerp import http, SUPERUSER_ID
from openerp.http import request

import openerp.addons.website_crm.controllers.main as main


class contactus_extended(main.contactus):
def create_lead(self, request, values, kwargs):

# Create a new Lead with correct Sales Team
# FIXME: request.registry is depricated - should use request.env instead
values['section_id'] = request.env.ref('website.salesteam_website_sales').id
newlead = request.registry['crm.lead'].create(request.cr, SUPERUSER_ID, values, request.context)

# Get a Recordset from crm.lead - in this case a singleton for the new lead
leadrecord = request.env['crm.lead'].browse(newlead)

# Search if a res.partner with the same E-Mail or with an similar name exists and add this to the
# lead. If more then one partner is found assign none for safety (assign it manually later)
partners = request.env['res.partner'].search([('email', '=', values['email_from'])])
if len(partners.ids) == 1:
leadrecord.partner_id = partners.id
if len(partners.ids) == 0:
partners = request.env['res.partner'].search([('name', 'ilike', values['contact_name'])])
if len(partners.ids) == 1:
leadrecord.partner_id = partners.id

# Post a New Message to this record
# Todo use a Mail-Template (so translation would be working too!)
recordtext = 'Neue Webanfrage: \n\nVon: %s\nE-Mail: %s\nPhone: %s\nFirma: %s\n\nBetreff: %s\nNachricht: %s' % (
values['contact_name'],
values['email_from'],
values['phone'],
values['partner_name'],
values['name'],
values['description'],
)
leadrecord.message_post(body=recordtext, subject=values['name'], type='notification', subtype='mail.mt_comment',
content_subtype='plaintext')

return newlead
13 changes: 13 additions & 0 deletions odoo-start.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env python

import sys
sys.path[0] += '/odoo'
import openerp

if sys.gettrace() != None:
# we are in debug mode ensure that odoo don't try to start gevent
print 'Odoo started in debug mode. Prevents from running evented server'
openerp.evented = False

if __name__ == "__main__":
openerp.cli.main()