Odoo Help


create a module for automatic send email when customer has been created ?

Ahmed elbarbary
on 8/12/14, 6:24 AM 5,951 views

hi, i want to send automatic email when customer has been created. 

these are the modules files:


import res_partner



# -*- coding: utf-8 -*-
    "name" : "Automatical email to customer",
    "version" : "1.0",
    "author" : "Author name",
    "description": """
        Sends automatic when customer created
    "website" : "Author website name",
    "category" : "",
    'depends': ['base'],
    "data" : ['email_template_customer_auto.xml',],
    'js': [], 
    'css': [

    'qweb': [
    "active": False,
    "installable": True,




from osv import osv, fields

class res_partner(osv.osv):
    _inherit = 'res.partner'
    _columns = {}

    def create(self, cr, uid, vals, context=None):
        res = super(res_partner, self).create(cr, uid, vals, context=context)
        if vals:
            template = self.pool.get('ir.model.data').get_object(cr, uid, 'customer_auto_email', 'email_template_customer_auto')
            mail_id = self.pool.get('email.template').send_mail(cr, uid, template.id, res , force_send=True)

        return res





<?xml version="1.0" encoding="utf-8"?>
  <data noupdate="1">

        <!--Email template-->
        <record id="email_template_customer_auto" model="email.template">
            <field name="name">Send auto email</field>
            <field name="email_from">${object.company_id and object.company_id.email or ''}</field>
            <field name="subject">New Customer created ${object.name}</field>
            <field name="email_to">${object.company_id and object.company_id.email or ''}</field>
            <field name="model_id" ref="base.model_res_partner"/>
            <field name="auto_delete" eval="True"/>
            <field name="lang">${object.lang}</field>
            <field name="body_html"><![CDATA[


We are here to inform you that the request [[object.name]] you submitted on [[object.request_date]] with the following data:

        | Request - Details
        | Number: [[object.id]]
        | Responsible Person: [[object.responsible_name.name]]
        | Request description: [[object.request_description]]
        | Stating reasons: [[object.stating_reasons]]
        | Notes: [[object.notes]]

Has not been confirmed and is closed.

If you have any question, do not hesitate to contact your supervisor.

Thank you!           


i istall the module but when i create a new customer that error appears :

OpenERP Server Error

Client Traceback (most recent call last): File "/opt/openerp/server/openerp/addons/web/http.py", line 204, in dispatch response["result"] = method(self, **self.params) File "/opt/openerp/server/openerp/addons/web/controllers/main.py", line 1128, in call_kw return self._call_kw(req, model, method, args, kwargs) File "/opt/openerp/server/openerp/addons/web/controllers/main.py", line 1120, in _call_kw return getattr(req.session.model(model), method)(*args, **kwargs) File "/opt/openerp/server/openerp/addons/web/session.py", line 42, in proxy result = self.proxy.execute_kw(self.session._db, self.session._uid, self.session._password, self.model, method, args, kw) File "/opt/openerp/server/openerp/addons/web/session.py", line 30, in proxy_method result = self.session.send(self.service_name, method, *args) File "/opt/openerp/server/openerp/addons/web/session.py", line 103, in send raise xmlrpclib.Fault(openerp.tools.ustr(e), formatted_info) Server Traceback (most recent call last): File "/opt/openerp/server/openerp/addons/web/session.py", line 89, in send return openerp.netsvc.dispatch_rpc(service_name, method, args) File "/opt/openerp/server/openerp/netsvc.py", line 296, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/opt/openerp/server/openerp/service/web_services.py", line 626, in dispatch res = fn(db, uid, *params) File "/opt/openerp/server/openerp/osv/osv.py", line 190, in execute_kw return self.execute(db, uid, obj, method, *args, **kw or {}) File "/opt/openerp/server/openerp/osv/osv.py", line 132, in wrapper return f(self, dbname, *args, **kwargs) File "/opt/openerp/server/openerp/osv/osv.py", line 199, in execute res = self.execute_cr(cr, uid, obj, method, *args, **kw) File "/opt/openerp/server/openerp/osv/osv.py", line 187, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) File "/opt/openerp/server/openerp/addons/customer_auto_email/res_partner.py", line 10, in create template = self.pool.get('ir.model.data').get_object(cr, uid, 'customer_auto_email', 'email_template_customer_auto') File "/opt/openerp/server/openerp/addons/base/ir/ir_model.py", line 884, in get_object res_model, res_id = self.get_object_reference(cr, uid, module, xml_id) File "/opt/openerp/server/openerp/tools/cache.py", line 18, in lookup r = self.lookup(self2, cr, *args) File "/opt/openerp/server/openerp/tools/cache.py", line 46, in lookup value = d[key] = self.method(self2, cr, *args) File "/opt/openerp/server/openerp/addons/base/ir/ir_model.py", line 876, in get_object_reference data_id = self._get_id(cr, uid, module, xml_id) File "/opt/openerp/server/openerp/tools/cache.py", line 18, in lookup r = self.lookup(self2, cr, *args) File "/opt/openerp/server/openerp/tools/cache.py", line 46, in lookup value = d[key] = self.method(self2, cr, *args) File "/opt/openerp/server/openerp/addons/base/ir/ir_model.py", line 869, in _get_id raise ValueError('No such external ID currently defined in the system: %s.%s' % (module, xml_id)) ValueError: No such external ID currently defined in the system: customer_auto_email.email_template_customer_auto



Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. A ray of relief & satisfaction to  our customers heart by our successful deployment in their organization, purely represents our success in Odoo platform. Hence, we take pride for being an Odoo partner with a vision of expanding our strategic alliances with our customers to offer them high value-added, trustworthy & cost effective solutions.


Since establishment, our business has span across 11 countries of the world. Our customers are companies of all sizes ranging from start-ups to large enterprises, who realize that they need a professional business solutions to generate revenue streams, establish proper communication channels or streamline business operations. Standing with strong determination of customer satisfaction, observing each minute detail of their business processes, providing proper guidance and moving forth to develop product accordingly adds our value and reliability among our customers. 


We are blessed with efficient, passionate & eclectic young developers who have come across almost all kinds of business profiles, working with full dedication, applying creativity & new features in existing modules and completing customer's projects successfully on predefined target. Our in-depth knowledge while giving business solutions in Odoo allows us to offer following services to our customers :


  • Consulting
  • Installation, Configuration & Customization
  • Training & Support
  • Maintenance
  • Upgradation
  • Documentation
  • Crafting community modules
  • Drafting videos on demand
  • Smart Apps development

We will be :) to welcome you @ www.emiprotechnologies.com to solve any kind of your business needs around Odoo. However we are just an inch away from you by email info@emiprotechnologies.com or a tweet to @EmiproTech

Emipro Technologies Pvt. Ltd.
On 8/12/14, 6:37 AM


Please see the ID into xml file is : "email_template_auto_customer" and you are using the ID for fetch that record is : "email_template_customer_auto".

1) So, you need to change into following code : 

template = self.pool.get('ir.model.data').get_object(cr, uid, 'customer_auto_email', 'email_template_auto_customer')

2) Or you need to change the ID into xml record as like below :

<record id="email_template_customer_auto" model="email.template">

Ahmed elbarbary
On 8/12/14, 6:48 AM

thank you very much, it works now. small changes can make a big difference

 do u have any idea about what i have change in this module if i want it to send a mail to the company if "a project created" not customer ??

hi chirag , do u have any idea about what i have change in this module if i want it to send a mail to the company if "a project created" not customer ??

Ahmed elbarbary
on 8/12/14, 10:03 AM

Hi, I have write down the answer for the project. Just have a look and make it running.

Emipro Technologies Pvt. Ltd.
on 8/13/14, 7:42 AM

thank you for the second time chirag

Ahmed elbarbary
on 8/13/14, 8:29 AM

your always welcome :)

Emipro Technologies Pvt. Ltd.
on 8/13/14, 8:46 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

3 follower(s)


Asked: 8/12/14, 6:24 AM
Seen: 5951 times
Last updated: 4/5/16, 12:44 AM