This question has been flagged

hi ,

i have a module to send automatic mail when customer has been created what about if i need to send mail when project created, what i should change in these files ?

__init__.py

import res_partner

------------------------------------------------------------------------------------------------------------------------------------------------------------

__openerp__.py

# -*- 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,

}

------------------------------------------------------------------------------------------------------------------------------------------------------------

res_partner.py

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

res_partner()

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

email_template_customer_auto.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
  <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[
             
          the email content

Thank you!           
            ]]></field>
        </record>
  
  </data>
</openerp>

Avatar
Discard

Whent I try to install your code It raise an error ----AssertionError: The model email.template does not exist !

Author

so install module "Email template " and try again

When I create a customer and save ,then I got this error######### ValueError: No such external ID currently defined in the system: customer_auto_email.email_template_customer_auto

is it a pop up message or it is  taceback ?


On 18 September 2014 09:15, Libu Koshy <libukoshym@mail.odoo.com> wrote:

When I create a customer and save ,then I got this error######### ValueError: No such external ID currently defined in the system: customer_auto_email.email_template_customer_auto


Author

uninstall this module and delete it from your modules and i will send u the complete module to your email now

this is send auto email when customer be created 

On 18 September 2014 11:22, Libu Koshy <libukoshym@mail.odoo.com> wrote:

Server Traceback (most recent call last) with a pop up wizard

--
Libu Koshy
Sent by Odoo Inc. using Odoo about Forum Post how to send automatic mail when project created ?

this is send auto email when project be created 

On 18 September 2014 11:40, AHMED ELBARBARY <aelbarbary152@gmail.com> wrote:
this is send auto email when customer be created 

On 18 September 2014 11:22, Libu Koshy <libukoshym@mail.odoo.com> wrote:

Server Traceback (most recent call last) with a pop up wizard

--
Libu Koshy
Sent by Odoo Inc. using Odoo about Forum Post how to send automatic mail when project created ?


this is send auto email when invoice be created 

On 18 September 2014 11:41, AHMED ELBARBARY <aelbarbary152@gmail.com> wrote:
this is send auto email when project be created 

On 18 September 2014 11:40, AHMED ELBARBARY <aelbarbary152@gmail.com> wrote:
this is send auto email when customer be created 

On 18 September 2014 11:22, Libu Koshy <libukoshym@mail.odoo.com> wrote:

Server Traceback (most recent call last) with a pop up wizard

--
Libu Koshy
Sent by Odoo Inc. using Odoo about Forum Post how to send automatic mail when project created ?



only invoice module or all modules 

really i am sorry i cannot help u i didn't know what is this error, it works fine at my system without any adding configuration just paste the module folders to addons then update module list and install those modules and every thing going well , u can check your outgoing mail server if u have the same problem u can do automated action and email templates from openerp wizard setting  instead of those modules


On 18 September 2014 12:51, Libu Koshy <libukoshym@mail.odoo.com> wrote:

Now I tried only this module(invoice module) ,and when I create a invoice then error occurs


Best Answer

Hi,

Try this code.

module name : project_auto_email

__init__.py

import project

------------------------------------------------------------------------------------------------------------------------------------------------------------

__openerp.py

# -*- coding: utf-8 -*-
{
    "name" : "Automatical email on Project Creation",
    "version" : "1.0",
    "author" : "Author name",
    "description": """
        Sends automatic when projects created
    """,
    "website" : "Author website name",
    "category" : "",
    'depends': ['base' ,'project'],
    "data" : ['email_template_project_auto.xml',],
    'js': [], 
    'css': [

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

}

------------------------------------------------------------------------------------------------------------------------------------------------------------

project.py

from osv import osv, fields

class project_project(osv.osv):
    _inherit = 'project.project'
    _columns = {}

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

        return res

project_project()

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

email_template_project_auto.xml

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

        <!--Email template-->
        <record id="email_template_project_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="project.model_project_project"/>
            <field name="auto_delete" eval="True"/>
            <field name="lang">${object.lang}</field>
            <field name="body_html"><![CDATA[
             
          the email content

Thank you!           
            ]]></field>
        </record>
  
  </data>
</openerp>

Avatar
Discard
Best Answer

Change the following line into xml file

Your line is : <field name="model_id" ref="base.model_project_project"/>

Change it by : <field name="model_id" ref="project.model_project_project"/>

Avatar
Discard
Best Answer

Why not using OpenChatter ?  By subscribing as many followers as you want.

https://www.dropbox.com/s/urgc666clpnn4jt/OpenChatter Project.png

 

 

If you want to do that by coding, hereafter a good  and simple example on how to send an automatic mail when a Task is created.

https://www.odoo.com/apps/7.0/send_mail_task/

You can try to adapt this example to your need (e.g send mail when Project is created or when a Customer is created)

Some helpful links:

https://doc.odoo.com/trunk/mail/mail_openchatter_howto/

https://github.com/vnc-biz/openerp-addons-bundle/blob/master-7.0/mail/doc/mail_openchatter_howto.rst

https://anybox.fr/blog/openerp-disable-autofollow-in-openchatter

https://doc.odoo.com/trunk/mail/mail_thread/

https://www.odoo.com/forum/help-1/question/what-is-the-track-proprerty-of-mail-thread-model-used-for-1704

Avatar
Discard
Best Answer

Hi Ahmed,

Just change the following line into xml file with my line.

Your line is : <field name="model_id" ref="base.model_project_project"/>

Change it by : <field name="model_id" ref="project.model_project_project"/>

Avatar
Discard
Author Best Answer
Avatar
Discard