mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[FIX] account_credit_control: Unknown field attachments
WARNING prod odoo.models: mail.mail.create() includes unknown fields: attachments
This commit is contained in:
@@ -166,6 +166,16 @@ class CreditCommunication(models.TransientModel):
|
||||
# of storing res_id
|
||||
email_values.pop('model', None)
|
||||
email_values.pop('res_id', None)
|
||||
|
||||
# Remove when mail.template returns correct format attachments
|
||||
attachment_list = email_values.pop('attachments', None)
|
||||
email_values['attachment_ids'] = [(0, 0, {
|
||||
'name': att[0],
|
||||
'datas': att[1],
|
||||
'datas_fname': att[0],
|
||||
'type': 'binary',
|
||||
}) for att in attachment_list]
|
||||
|
||||
email = emails.create(email_values)
|
||||
|
||||
state = 'sent'
|
||||
@@ -179,20 +189,6 @@ class CreditCommunication(models.TransientModel):
|
||||
|
||||
comm.credit_control_line_ids.write({'mail_message_id': email.id,
|
||||
'state': state})
|
||||
attachments = self.env['ir.attachment']
|
||||
for att in email_values.get('attachments', []):
|
||||
attach_fname = att[0]
|
||||
attach_datas = att[1]
|
||||
data_attach = {
|
||||
'name': attach_fname,
|
||||
'datas': attach_datas,
|
||||
'datas_fname': attach_fname,
|
||||
'res_model': 'mail.mail',
|
||||
'res_id': email.id,
|
||||
'type': 'binary',
|
||||
}
|
||||
attachments |= attachments.create(data_attach)
|
||||
email.write({'attachment_ids': [(6, 0, attachments.ids)]})
|
||||
emails += email
|
||||
return emails
|
||||
|
||||
|
||||
Reference in New Issue
Block a user