Skip to Content
Menu
This question has been flagged

I was wondering if it was possible to be able to save a report to chatter when it is printed from a python method.

For some detail, at the moment my report is saved to the attachments

<report id="quote_report"
        name="quotes.quote_report_template"
        model="quote.quote"
        string="Quote Report"
        report_type="qweb-pdf"
        attachment="('Quotation - %s' % (object.name))"
        print_report_name="'Quotation - %s' % (object.name)"/>

I am currently printing my report via:

def print_quotation(self):
    [some code]
    return self.env.ref('quotes.quote_report').report_action(self) ​   ​    ​   ​     ​   ​    ​   ​     ​   ​    ​   ​     ​   ​    ​   ​
Avatar
Discard

Hi,

In this example, let's assume you have some files added to field `attachs` in your current model and after clicking on bouton Attach, they are added to the chatter. ( enabling chatter in your current model).

attachs = fields.Many2many('ir.attachment', string="Attachments", required=True)

@api.multi

def attachment_chatter(self):

subject = u"Attachment"

body = u"You will find attached the proof of payment document"

self.message_post(body,

subject=subject,

attachment_ids=[x.id for x in self.attachs])

For more options, you can /addons/mail/models/mail_thread.py

Related Posts Replies Views Activity
1
Sep 19
2512
1
Mar 16
10464
0
Apr 21
2284
1
Jan 21
2083
2
Sep 20
5079