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)
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