[IMP] send mail.thread to a company when document was generated

This commit is contained in:
Stepan Savelyev 2019-12-06 13:15:34 +05:00
parent 33f102598b
commit cfc0239fca

View File

@ -510,12 +510,26 @@ class ContractWizard(models.TransientModel):
path_to_template, fields).read() path_to_template, fields).read()
encoded_data = base64.b64encode(binary_data) encoded_data = base64.b64encode(binary_data)
attachment = self.env['ir.attachment'].create({ attachment_name = "Contract-{number}.{ext}".format(
"name": "Contract-{}.doc".format(self.contract_id.name), number=self.contract_id.name,
ext=self.template.attachment_id.datas_fname.split('.')[-1]
)
document_as_attachment = self.env['ir.attachment'].create({
"name": attachment_name,
"datas_fname": attachment_name,
"type": "binary", "type": "binary",
"datas": encoded_data, "datas": encoded_data,
}) })
return attachment
# Send message with attachment to a mail.thread of the company
self.env['mail.message'].create({
"model": "res.partner",
"res_id": self.partner_id.id,
"message_type": "comment",
"attachment_ids": [(4, document_as_attachment.id, False)]
})
return document_as_attachment
class AnnexLine(models.TransientModel): class AnnexLine(models.TransientModel):