diff --git a/.gitignore b/.gitignore index 4eefa2c..90d468c 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,10 @@ o8_*/ /*.conf /*.init /*.log +/*.pid + +#pycharm +.idea/ #Mac OSX .DS_* diff --git a/addons-loaded/website_crm_sendmail b/addons-loaded/website_crm_sendmail new file mode 120000 index 0000000..2f1311a --- /dev/null +++ b/addons-loaded/website_crm_sendmail @@ -0,0 +1 @@ +../addons-own/website_crm_sendmail \ No newline at end of file diff --git a/addons-own/website_crm_extended/__init__.py b/addons-own/website_crm_extended/__init__.py new file mode 100644 index 0000000..355939a --- /dev/null +++ b/addons-own/website_crm_extended/__init__.py @@ -0,0 +1 @@ +import controllers \ No newline at end of file diff --git a/addons-own/website_crm_extended/__openerp__.py b/addons-own/website_crm_extended/__openerp__.py new file mode 100644 index 0000000..8464c16 --- /dev/null +++ b/addons-own/website_crm_extended/__openerp__.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). +# Copyright (C) 2010-2012 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 +# 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 . +# +############################################################################## + +{ + '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, +} \ No newline at end of file diff --git a/addons-own/website_crm_extended/controllers/__init__.py b/addons-own/website_crm_extended/controllers/__init__.py new file mode 100644 index 0000000..8ee9bae --- /dev/null +++ b/addons-own/website_crm_extended/controllers/__init__.py @@ -0,0 +1 @@ +import main diff --git a/addons-own/website_crm_extended/controllers/main.py b/addons-own/website_crm_extended/controllers/main.py new file mode 100644 index 0000000..10c9469 --- /dev/null +++ b/addons-own/website_crm_extended/controllers/main.py @@ -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 \ No newline at end of file diff --git a/odoo-start.py b/odoo-start.py new file mode 100644 index 0000000..55798cc --- /dev/null +++ b/odoo-start.py @@ -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()