Odoo Help

3

5
3 Answers
1
Avatar

Atchuthan - Technical Consultant, Sodexis Inc India

--Atchuthan - Technical Consultant, Sodexis Inc--
4377
| 6 6 10
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc India
8/22/13, 6:04 AM

Try to modify code :

        template_id = ir_model_data.get_object_reference(cr, uid, 'sale', 'email_template_edi_sale')[1]

here sale implies folder name of your module

        'default_model': 'sale.order',

here specify the model name i.e. table name

7
Avatar

Ghanshyam Prajapati India

--Ghanshyam Prajapati--

1423
| 4 4 10
Pune, India
--Ghanshyam Prajapati--
OpenERP Developer
Ghanshyam Prajapati India
6/19/13, 4:18 AM

Use Following simple method for send email,

def send_mail(self, cr, uid, ids, context=None):
    email_template_obj = self.pool.get('email.template')
    template_ids = email_template_obj.search(cr, uid, [('model_id.model', '=','your.object.name')], context=context) 
    if template_ids:
          values = email_template_obj.generate_email(cr, uid, template_ids[0], ids, context=context)
         values['subject'] = subject 
          values['email_to'] = email_to
          values['body_html'] = body_html
          values['body'] = body_html
          values['res_id'] = False
          mail_mail_obj = self.pool.get('mail.mail')
          msg_id = mail_mail_obj.create(cr, uid, values, context=context)
          if msg_id:
                mail_mail_obj.send(cr, uid, [msg_id], context=context) 
    return True
9 Comments
Ghanshyam Prajapati India
6/19/13, 7:59 AM

Hi atchuthan, If your problem is solved please mark the answer as solved.

Ghanshyam Prajapati India
6/19/13, 9:06 AM

Suppose you have created one template for sending emails, under your template, you can see Applies To(model_id). Now in my answer, you can see 'your.object.name' in template_ids line, Replace 'your.object.name' with your current template's model_id's object name.

Atchuthan India
6/20/13, 4:08 AM

Hi dude, I am getting error when I tried your suggestion as "IndexError: list index out of range"

Ghanshyam Prajapati India
6/20/13, 4:15 AM

in server you can see error line number with file name, please check your error location, or debug your code. see http://www.youtube.com/watch?v=RTg8VvyEVak

Ghanshyam Prajapati India
6/20/13, 8:53 AM

See my updated answer, Try to print template_ids, you can see template_ids=[], it means search method cant find your template. try hardcode, Put your template's id in blank list and then check, for example, template_ids = [1]

Odoo India
10/24/14, 12:56 AM

I got this error when I use above code-----------Odoo 8.0-20141016-000205\server\openerp\addons\email_template\email_template.py", line 219, in get_email_template_batch TypeError: unhashable type: 'list'

Odoo India
10/24/14, 1:05 AM

I got this error when I use above code-----------Odoo 8.0-20141016-000205\server\openerp\addons\email_template\email_template.py", line 219, in get_email_template_batch TypeError: unhashable type: 'list'

Anand India
11/29/14, 5:05 AM

It worked for me... superb.. I upvoted you.. Also help me to create a template using xml or python code....

Dexciss Technology Pvt Ltd, Apoorv Soral India
1/5/17, 10:15 AM

how to use this method in new API odoo9

3
Avatar

ClueLogics Technologies Pvt. Ltd. India

--ClueLogics Technologies Pvt. Ltd.--
6223
| 7 5 10
Delhi NCR, India
--ClueLogics Technologies Pvt. Ltd.--

 ClueLogics Technologies Pvt Ltd is a Software product and services provider. We are positioned to deliver robust, rapid and reliable Information Technology solutions that work. What we succeed upon is Technology and Technical Expertise. The industry review of ClueLogics has been commendable for the past years as most of its business comes from repeat orders by highly satisfied clients.

ClueLogics Technologies Pvt. Ltd. India
6/19/13, 3:50 AM

Hi

Try to use send function of email.template , this will be better and easy for you just need to include current record ID and template id and another field of true and false for send immediately or later

that's it

Thanks
Sandeep

7 Comments
Atchuthan India
6/19/13, 3:55 AM

can u provide me with appropriate code with send function of email.template for my module "addition".

template_id = "email_template_edi_addition"

ClueLogics Technologies Pvt. Ltd. India
6/19/13, 3:58 AM

templateobject.send(cr,uid,template_id,your_record_id,True) this is the simple method

Atchuthan India
6/19/13, 4:03 AM

can u tell me where to add this code and what to write in the body of this method

ClueLogics Technologies Pvt. Ltd. India
6/19/13, 4:05 AM

this method is of email.template object , you just need to cal this , call this method from your code

evon_dun India
10/9/13, 7:43 AM

Can you help writing a simple send email function code that runs on a button, as simple as it can be as. I want to use this code in partner ledger webkit wizard, it should read the selected partner's email and use the report as attachment. Its very urgent.

Torvald Baade Bringsvor, Torvald B. Bringsvor Norway
4/25/14, 8:50 AM

Look at account_invoice.py, method action_invoice_sent - this is what happens when you click Send as Email on an invoice.

evon_dun India
4/25/14, 9:37 AM

Hi could not find such a method!

Ask a Question
Writer
Tag
Keep Informed
2 follower(s)
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.

Register
Odoo Training Center

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

Test it now