Skip to Content
Odoo मेन्यू
  • Sign in
  • मुफ़्त में आज़माएं
  • ऐप्लिकेशन
    फ़ाइनेंस
    • अकाउंटिंग
    • इनवॉइसिंग
    • एक्सपेंस
    • स्प्रेडशीट (बीआई)
    • डॉक्यूमेंट्स
    • साइन
    सेल्स
    • सीआरएम
    • सेल्स
    • पीओएस शॉप
    • पीओएस रेस्टोरेंट
    • सब्सक्रिप्शन
    • रेंटल
    वेबसाइट
    • वेबसाइट बिल्डर
    • ई-कॉमर्स
    • ब्लॉग
    • फ़ोरम
    • लाइव चैट
    • ई-लर्निंग
    सप्लाई चेन
    • इन्वेंट्री
    • मैन्युफ़ैक्चरिंग
    • पीएलएम
    • परचेज़
    • मेंटेनेंस
    • क्वालिटी
    मानव संसाधन
    • कर्मचारी
    • रिक्रूटमेंट
    • टाइम ऑफ़
    • अप्रेज़ल
    • रेफ़रल
    • फ़्लीट
    मार्केटिंग
    • सोशल मार्केटिंग
    • ईमेल मार्केटिंग
    • एसएमएस मार्केटिंग
    • इवेंट
    • मार्केटिंग ऑटोमेशन
    • सर्वे
    सेवाएं
    • प्रोजेक्ट
    • टाइमशीट
    • फ़ील्ड सर्विस
    • हेल्पडेस्क
    • प्लानिंग
    • अपॉइंटमेंट
    प्रॉडक्टिविटी
    • डिस्कस
    • अप्रूवल
    • आईओटी
    • वीओआईपी
    • नॉलेज
    • WhatsApp
    तीसरे पक्ष के ऐप्लिकेशन Odoo स्टूडियो Odoo क्लाउड प्लेटफ़ॉर्म
  • इंडस्ट्री
    रीटेल
    • बुक स्टोर
    • क्लोदिंग स्टोर
    • फ़र्नीचर स्टोर
    • ग्रॉसरी स्टोर
    • हार्डवेयर स्टोर
    • टॉय स्टोर
    Food & Hospitality
    • बार और पब
    • रेस्टोरेंट
    • फ़ास्ट फ़ूड
    • Guest House
    • बेवरिज डिस्ट्रीब्यूटर
    • Hotel
    Real Estate
    • Real Estate Agency
    • आर्किटेक्चर फ़र्म
    • कंसट्रक्शन
    • एस्टेट मैनेजमेंट
    • गार्ड्निंग
    • प्रॉपर्टी ओनर असोसिएशन
    Consulting
    • Accounting Firm
    • Odoo पार्टनर
    • Marketing Agency
    • लॉ फ़र्म
    • टैलेंट ऐक्विज़िशन
    • ऑडिट & सर्टिफ़िकेशन
    मैन्युफ़ैक्चरिंग
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • कॉर्पोरेट गिफ़्ट
    हेल्थ & फिटनेस
    • स्पोर्ट्स क्लब
    • आईवियर स्टोर
    • फिटनेस सेंटर
    • वेलनेस प्रैक्टिशनर
    • फॉर्मेसी
    • हेयर सैलून
    Trades
    • Handyman
    • आईटी हॉर्डवेयर और सपोर्ट
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • एन्वायरमेंटल एजेंसी
    • बिलबोर्ड रेंटल
    • फ़ोटोग्राफी
    • बाइक लीजिंग
    • सॉफ़्टवेयर रीसेलर
    Browse all Industries
  • कम्यूनिटी
    सीखें
    • ट्यूटोरियल्स
    • दस्तावेज़
    • सर्टिफ़िकेशन
    • ट्रेनिंग
    • ब्लॉग
    • पॉडकास्ट
    शिक्षा को बढ़ावा दें
    • एजुकेशन प्रोग्राम
    • स्केल अप! बिजनेस गेम
    • Odoo के ऑफ़िस में आएं
    सॉफ़्टवेयर पाएं
    • डाउनलोड
    • वर्शन की तुलना करें
    • रिलीज़
    साथ मिलकर काम करें
    • Github
    • फ़ोरम
    • इवेंट
    • अनुवाद
    • पार्टनर बनें
    • Services for Partners
    • अपना अकाउंटिंग फ़र्म रजिस्टर करें
    सेवाएं पाएं
    • पार्टनर ढूंढें
    • अकाउंटेंट खोजें
    • सलाहकार की मदद लें
    • इम्प्लिमेंटेशन सेवाएं
    • कस्टमर रेफ़रेंस
    • सहायता
    • अपग्रेड
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    डेमो देखें
  • कीमत
  • सहायता

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • सीआरएम
  • e-Commerce
  • लेखांकन
  • इन्वेंटरी
  • PoS
  • प्रोजेक्ट
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
टैग (View all)
odoo accounting v14 pos v15
About this forum
Help

How to attach wizard report's report in mail

Subscribe

Get notified when there's activity on this post

This question has been flagged
mailreport
1 Reply
17009 Views
Avatar
sridhar

Hi, I want to do how to attach wizard report's report automatically in mail, In that wizard i have two fields Date from and Date to, my concept is Date From to To Date to will send to particular user's mail, I have 2 buttons in wizard report one for Print another one for Send by mail, when click on the send to mail user can select the users and send, how to do it in OpenERP7. This is my following code.

 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', '=','quality.report.wizard')], context=context)
        print template_ids,"%%%%%%%%%%%%%%%%%5"
        if template_ids:
              values = email_template_obj.generate_email(cr, uid, template_ids[0], ids, context=context)
              print values,"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`"
              val = values.get('subject')
              val1 = values.get('email_to')
              val2 = values.get('body_html')
              val3 = values.get('body_html')
              val4 = values.get('attachments')
              values['subject'] = val
              values['email_to'] = val1
              values['body_html'] = val2
              values['body'] = val3
              values['res_id'] = False
              values['attachment_ids'] = val4
              mail_mail_obj = self.pool.get('mail.mail')
              print values,'$$$$$$$$$$$$$$$$$$$$$$$$'
              msg_id = mail_mail_obj.create(cr, uid, values, context=context)
              print msg_id,"/////////////////////////////////"
              if msg_id:
                    mail_mail_obj.send(cr, uid, [msg_id], context=context)
        return True

it is correct or need some changes, it make error.

Xml is

<record id="email_template_edi_quality" model="email.template">
            <field name="name">Quality Report - Send by Email (Portalsssssss)</field>
            <field name="email_from">sridharopenerptest@gmail.com</field>
            <field name="subject">${(object.name or 'Sridhar')}</field>
            <field name="email_recipients"></field>
            <field name="model_id" ref="vv_quality.model_quality_control"/>
            <field name="auto_delete" eval="True"/>
            <field name="report_template" ref="quality_control_report"/>
            <field name="report_name">${(object.name or 'NNNNNN')}</field>
            <field name="lang"></field>
            <field name="body_html"> Successs</field>
        </record>

when i open this wizard or value only coming, object.name is not calling or empty why.

1
Avatar
Discard
Prakash

Related topic: http://help.openerp.com/question/16946/openerp-7-using-wizard-how-to-send-email-with-attachment/

Prakash

In the wizard send email button to add in the code will send email with attachment.

Prakash

In the above code have you received email?.. In your case the attachment document Is it available in the ir_attachment table?...

Prakash

save your record in the ir_attachment and pass the attachment ID in the mail obj. (already the above code is working in the way). For example in the above code ir_attachment.create(cursor, uid, attachment_data, context=context) # Create date in ir_attachment with document

Prakash

sorry currently i have not code. Your code looking correct make sure attachment table created. or testing purpose pass the attachment_ids directly into attachment_ids: [(6, 0, [1])]

sridhar
Author

when i composing mail there is no attachment then only send_mail function will call is it correct.

Prakash

In the wizard send mail button clicked the send_mail function call. If attachment ids find it will send email with attachment otherwise send email without attachment

sridhar
Author

Prakash, i attached the report successfully, but when i click on the send_mail method it make error, how to fix it. result[message['id']] = self.pool.get(message['model']).name_get(cr, SUPERUSER_ID, [message['res_id']], context=context)[0][1] IndexError: list index out of range.

Prakash

For testing purpose you add recipients details and other details manually and check have u receive email with attachment?...

Avatar
Prakash
Best Answer

Try the below code:-

Without using Email Template:-

    def custom_send_email (self, cr, uid, ids, context=None):
        mail_mail = self.pool.get('mail.mail')
        att_obj = self.pool.get('ir.attachment')
        for send in self.browse (cr, uid, ids, context = context):
            mail_ids = []
            attachment_ids = []
            email_to = send.invoice_id.partner_id.email  # your object Mail ID
            attachment_data = {
                'name': "Report Data",
                'datas_fname': send.filename, # your object File Name
                'db_datas': send.data,  # your object Data
            }
            attachment_ids.append (att_obj.create(cr, uid, attachment_data, context=context))
            subject = "Report Email: Ref-" + str (send.invoice_id.origin or '') # # your object Name ref
            body = """Hello,

FROM OpenERP SYSTEM. Please ignore

Kind regards.
OpenERP Team.
"""
            mail_ids.append (mail_mail.create(cr, uid,
                {
                   'email_to': email_to,
                   'subject': subject,
                   'body_html': '<pre>%s</pre>' % body,
                }, context = context))
            if attachment_ids:
                mail_mail.write(cr, uid, mail_ids, {'attachment_ids': [(6, 0, attachment_ids)]}, context=context)
            mail_mail.send (cr, uid, mail_ids, context = context)

        return {'type': 'ir.actions.act_window_close'}

xml File

 <button name="custom_send_email" string="Send Email" type="object" class="oe_highlight"/>

With using Email Template

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', '=','quality.report.wizard')], context=context)
        print template_ids,"%%%%%%%%%%%%%%%%%5"
        if template_ids:
              values = email_template_obj.generate_email(cr, uid, template_ids[0], ids, context=context)
              print values,"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`"
              val = values.get('subject')
              val1 = values.get('email_to')
              val2 = values.get('body_html')
              val3 = values.get('body_html')
              val4 = values.get('attachments')
              values['subject'] = val
              values['email_to'] = val1
              values['body_html'] = val2
              values['body'] = val3
              values['res_id'] = False
              #values['attachment_ids'] = val4
             # check the val4 value print val4 its equal [ interger id value ]
              values['attachment_ids'] = [(6, 0, val4)]
              mail_mail_obj = self.pool.get('mail.mail')
              print values,'$$$$$$$$$$$$$$$$$$$$$$$$'
              msg_id = mail_mail_obj.create(cr, uid, values, context=context)
              print msg_id,"/////////////////////////////////"
              if msg_id:
                    mail_mail_obj.send(cr, uid, [msg_id], context=context)
        return True
1
Avatar
Discard
Prakash

Hi Sridhar, In my code for sending email. Email Template is not used after clicking the custom wizard "Send Email" button it will send email (without using template). Suppose if you are using Email Template and default "Send" button options used i thing no need write to code. (Default options will works in template need to select document manually or set).

sridhar
Author

By the basic function, it make error AttributeError: 'quality.report.wizard' object has no attribute 'message_post', so i did some changes now email send but no attachment are received.

Prakash

I update my code use attachment ids Example: [(6, 0, [1])]

Prakash

Testing purpose set val4 = [(6, 0, [1])] # make sure id 1 is available in the ir_attachment table and let me know mail received with attachment

Prakash

Options 1) check pg_admin tools select * from ir_attachment use the ir_attachment id value. If table empty attached any record and used saved ID. Options 2) remove the code val4 attacment ids in the email template manually attached the record and send email

sridhar
Author

Thank you attachment received but one problem i put that val4 = [(6, 0, [116])] it is the id of ir.attachment. how to do it.

Prakash

using create method store your attachment in ir_attachment table. and pass the create method return id value to [(6, 0, attachment_ids)]. Based on this code available in the above Example Without using Email Template:-

Prakash

Let me know For all the customer send email u are using the same attachment (id 116)?.... or attachment will be differ based on customer?...

sridhar
Author

Actually this is wizard report, user select from date and to date, and press send mail button, then one wizard will open that is compose mail wizard here all the values are come based on Email Template attachment also based on particular date report. every month report is changed.

Prakash

based on this already code is available in the example Without using Email Template. Create record in ir_attachment table and pass the value.

sridhar
Author

where is that code, that code can fulfill my requirement?

Prakash

Refer the below link http://help.openerp.com/question/36449/how-to-programatically-run-a-report-and-add-it-as-an-attachment/

sridhar
Author

I going to take this way, i spend lot of days to this concept if i take that code means it take extra days, i got one concept from this in the send mail function res_id = False, here i'm going to pass the mail.compose.message then easily i got a link from that.

sridhar
Author

my concept went wrong, how to do it, what is the link between mail.compose.message and ir.attachment.

sridhar
Author

mail.compose.message.ir.attachment.rel table is a relation of the two table, attachment_id is there, how to pass the value in values['attachment_ids'] = [(6, 0, [116])]. 116 as that id is correct.

Prakash

mail_mail.write(cr, uid, mail_ids, {'attachment_ids': [(6, 0, attachment_ids)]}, context=context)

sridhar
Author

abc = mail_mail_obj.write(cr, uid, values, {'attachment_ids': [(6, 0, attachment_ids)]}, context=context) NameError: global name 'attachment_ids' is not defined, i got error, please update as a answer.

Prakash

Already is there Refer the above code (Without using Email Template)

Prakash

In the code 1) attachment_ids = [] # define 2) attachment_data = { 'name': "Report Data", 'datas_fname': send.filename, # your object File Name 'db_datas': send.data, # your object Data } attachment_ids.append (att_obj.create(cr, uid, attachment_data, context=context)) 3) mail_mail.write(cr, uid, mail_ids, {'attachment_ids': [(6, 0, attachment_ids)]}, context=context)

sridhar
Author

'datas_fname': send.filename, # your object File Name 'db_datas': send.data, # your object Data i didn't get that, see my code where i give this, i confused.

Prakash

give me more details about report object name, Is it pdf report? how to print the report manually using menu options?..

sridhar
Author

Yes pdf report, Actually values calling from the jasper report, why i give the object name.

sridhar
Author

Now problem solved, Thank you very much.

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
How to block Many2One value Changes
mail report
Avatar
Avatar
Avatar
Avatar
3
मार्च 15
7590
Attach automatically report to mail
mail report automatically
Avatar
Avatar
2
जन॰ 19
20870
create and attach pdf to email template
pdf mail report
Avatar
Avatar
Avatar
2
मार्च 15
11036
Report with a different footer in the first page. How to do it?
report
Avatar
Avatar
2
नव॰ 25
253
<( Servicio al pasajero)||¿Cómo hablar directamente en Volaris?
mail
Avatar
0
अक्तू॰ 25
504
कम्यूनिटी
  • ट्यूटोरियल्स
  • दस्तावेज़
  • फ़ोरम
ओपन सोर्स
  • डाउनलोड
  • Github
  • रनबॉट
  • अनुवाद
सेवाएं
  • Odoo.sh Hosting
  • सहायता
  • अपग्रेड
  • कस्टम डेवलपमेंट्स
  • शिक्षा
  • अकाउंटेंट खोजें
  • पार्टनर ढूंढें
  • पार्टनर बनें
हमारे बारे में
  • हमारी कंपनी
  • ब्रांड ऐसेट
  • संपर्क करें
  • नौकरियां
  • इवेंट
  • पॉडकास्ट
  • ब्लॉग
  • ग्राहक
  • लीगल • गोपनीयता
  • सुरक्षा
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo, बिज़नेस से जुड़े ऐप्लिकेशन का एक कलेक्शन है जो ओपन सोर्स पर आधारित है. इसमें आपकी कंपनी की हर ज़रूरत के लिए ऐप्लिकेशन हैं. जैसे, सीआरएम, ई-कॉमर्स, अकाउंटिंग, इन्वेंट्री, पॉइंट ऑफ़ सेल, प्रोजेक्ट मैनेजमेंट वगैरह.

Odoo की सबसे बड़ी खासियत है कि यह इस्तेमाल करने में बहुत आसान है और यह पूरी तरह से इंटिग्रेट किया हुआ है.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now