fix
This commit is contained in:
parent
c30130a3d6
commit
4d06664928
1 changed files with 16 additions and 7 deletions
|
|
@ -759,14 +759,23 @@ class IrAttachment(models.Model):
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.model
|
@api.model_create_multi
|
||||||
def create(self, vals_list):
|
def create(self, vals_list):
|
||||||
try:
|
"""Override create to handle MSG files."""
|
||||||
return super().create(vals_list)
|
if not isinstance(vals_list, list):
|
||||||
except Exception as e:
|
vals_list = [vals_list]
|
||||||
self.env.cr.rollback() # Annuler la transaction en cas d'erreur
|
|
||||||
_logger.error("Failed to create attachment: %s", str(e))
|
attachments = super().create(vals_list)
|
||||||
raise UserError(_("Failed to create attachment: %s") % str(e))
|
|
||||||
|
for attachment in attachments:
|
||||||
|
try:
|
||||||
|
if attachment._is_msg_file():
|
||||||
|
attachment.process_msg_as_email()
|
||||||
|
except Exception as e:
|
||||||
|
_logger.error("MSG processing failed: %s", str(e))
|
||||||
|
attachment._notify_error(_("MSG Error"), str(e))
|
||||||
|
|
||||||
|
return attachments
|
||||||
|
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
"""Override write to handle problematic files on update."""
|
"""Override write to handle problematic files on update."""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue