[FIX] account_edi_ubl_cii: fix edi options on journal

We only want the edi.format options to appear on the sale journals
(out_invoice, out_refund).

In addition, the warnings are no longer displayed on top of the invoice.

closes odoo/odoo#94376

X-original-commit: dca5a2844ef2e90c257b78add3e147b291a9fa18
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: Julien Van Roy <juvr@odoo.com>
This commit is contained in:
Julien Van Roy
2022-06-23 07:59:59 +02:00
parent 1d3879b6df
commit c25f8d94e5
@@ -88,7 +88,7 @@ class AccountEdiFormat(models.Model):
self.ensure_one()
if self.code not in FORMAT_CODES:
return super()._is_compatible_with_journal(journal)
return self._is_ubl_cii_available(journal.company_id)
return self._is_ubl_cii_available(journal.company_id) and journal.type == 'sale'
def _is_enabled_by_default_on_journal(self, journal):
# EXTENDS account_edi
@@ -108,6 +108,7 @@ class AccountEdiFormat(models.Model):
res = {}
for invoice in invoices:
builder = self._get_xml_builder(invoice.company_id)
# For now, the errors are not displayed anywhere, don't want to annoy the user
xml_content, errors = builder._export_invoice(invoice)
# DEBUG: send directly to the test platform (the one used by ecosio)
@@ -128,14 +129,6 @@ class AccountEdiFormat(models.Model):
'success': True,
'attachment': attachment,
}
if errors:
res[invoice].update({
'success': False,
'error': _("Errors occured while creating the EDI document (format: %s). The receiver "
"might refuse it.", builder._description)
+ '<p> <li>' + "</li> <li>".join(errors) + '</li> </p>',
'blocking_level': 'info',
})
return res