Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions account_peppol_backport/models/account_edi_proxy_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,21 @@ def _peppol_get_new_documents(self):
# At the very minimum, the part that extracts EmbeddedDocumentBinaryObject
# should be recreated so users have at least a PDF attachment to
# work with.
attachment = self.env['ir.attachment'].create(attachment_vals)
move = journal\
.with_company(company)\
.with_context(
default_journal_id=journal.id,
default_move_type='in_invoice',
default_peppol_move_state=content['state'],
default_peppol_message_uuid=uuid,
)\
._create_document_from_attachment(attachment.id)
move._message_log(body=_('Peppol document has been received successfully'))
with self.env.cr.savepoint():
# wrap move creation in a savepoint to avoid leaving the cursor
# in an error state when an SQL constraint is raised, without
# this, the explicit commit after the exception fails
attachment = self.env['ir.attachment'].create(attachment_vals)
move = journal\
.with_company(company)\
.with_context(
default_journal_id=journal.id,
default_move_type='in_invoice',
default_peppol_move_state=content['state'],
default_peppol_message_uuid=uuid,
)\
._create_document_from_attachment(attachment.id)
move._message_log(body=_('Peppol document has been received successfully'))
# pylint: disable=broad-except
except Exception: # noqa: BLE001
# if the invoice creation fails for any reason,
Expand Down