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 !
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
uninstall this module and delete it from your modules and i will send u the complete module to your email now