Odoo Help

Welcome!

This community 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.

0

how to send automatic mail when project created ?

By
Ahmed elbarbary
on 8/13/14, 6:11 AM 3,681 views

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>

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

Odoo
on 9/18/14, 1:33 AM

so install module "Email template " and try again

Ahmed elbarbary
on 9/18/14, 1:54 AM

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

Odoo
on 9/18/14, 2:15 AM
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


Ahmed elbarbary
on 9/18/14, 2:42 AM

Server Traceback (most recent call last): File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\web\session.py", line 89, in send File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\netsvc.py", line 296, in dispatch_rpc File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\service\web_services.py", line 626, in dispatch File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\osv.py", line 190, in execute_kw File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\osv.py", line 132, in wrapper File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\osv.py", line 199, in execute File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\osv\osv.py", line 187, in execute_cr File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\employee_mail\customer_mail.py", line 11, in create File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\base\ir\ir_model.py", line 884, in get_object File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\tools\cache.py", line 18, in lookup File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\tools\cache.py", line 46, in lookup File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\base\ir\ir_model.py", line 876, in get_object_reference File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\tools\cache.py", line 18, in lookup File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\.\openerp\tools\cache.py", line 46, in lookup File "C:\Program Files (x86)\OpenERP 7.0-20140622-231040\Server\server\openerp\addons\base\ir\ir_model.py", line 869, in _get_id ValueError: No such external ID currently defined in the system: customer_auto_email.email_template_customer_auto

Odoo
on 9/18/14, 4:19 AM

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

Odoo
on 9/18/14, 4:22 AM

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

Ahmed elbarbary
on 9/18/14, 4:38 AM
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 ?

Ahmed elbarbary
on 9/18/14, 4:40 AM
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 ?


Ahmed elbarbary
on 9/18/14, 4:41 AM
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 ?



Ahmed elbarbary
on 9/18/14, 4:42 AM

Thanks ahmed elbarbary......................will check ,Thanks for ur replay... and modules

Odoo
on 9/18/14, 5:00 AM

i tried your module ,when invoice is created email genaration,but i got this error ValueError: No such external ID currently defined in the system: invoice_auto_email.email_template_invoice_auto

Odoo
on 9/18/14, 5:09 AM
only invoice module or all modules 

Ahmed elbarbary
on 9/18/14, 5:41 AM

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

Odoo
on 9/18/14, 5:51 AM
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


Ahmed elbarbary
on 9/18/14, 6:09 AM

Kk I will try and check...

Odoo
on 9/18/14, 6:33 AM
1

Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
Tiny ERP Pvt Ltd
http://www.odoo.com
5975
| 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/13/14, 7:32 AM

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"/>

4

Janeesh

--Janeesh--
1641
| 4 3 4
Cochin, India
--Janeesh--

Odoo Developer

Janeesh
On 8/13/14, 7:00 AM

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>

Hi ,I tried your code ,but no mail is send to customer address

Odoo
on 9/29/14, 1:30 PM
1

Med Said BARA

--Med Said BARA--
2664
| 5 5 7
Algeria
--Med Said BARA--
Med Said BARA
On 8/13/14, 9:18 AM

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 8/13/14, 6:11 AM
Seen: 3681 times
Last updated: 3/16/15, 8:10 AM