[FIX] l10n_latam_invoice_document: Allow digitalization

Steps to reproduce:

  - Install l10n_ar module (or any l10n_* module that depends on
    l10n_latam_invoice_document)
  - Go to Accounting -> Vendors -> Bills
  - Click on Upload and select a bill file
  - Open draft bill
  - Click on `Send For Digitalization`

Issue:

  Digitalization don't start and a warning message is diplayed saying
  that some required fields are invalid.

Cause:

  When clicking on the button to digitalize the invoice, we try
  to save the form first before executing the action.
  By doing so, if some fields are required and empty, a warning message
  will be displayed.

  In this case, the issue is with the fields `Document Type` and
  `Document Number`.

Solution:

  Set `Document Type` and `Document Number` to not required if there is
  no partner_id set on the bill.

opw-2797444

closes odoo/odoo#98115

X-original-commit: b95473e3edf79796c7915afcdec5b4aa9addf273
Signed-off-by: Josse Colpaert <jco@odoo.com>
Signed-off-by: Nasreddin Boulif (bon) <bon@odoo.com>
This commit is contained in:
Nasreddin Boulif (bon)
2022-08-13 15:10:47 +02:00
parent 7418cf5eac
commit e756aa90e1
@@ -42,11 +42,11 @@
<xpath expr="//field[@name='journal_id']/.." position="after">
<field name="l10n_latam_document_type_id"
attrs="{'invisible': [('l10n_latam_use_documents', '=', False)], 'required': [('l10n_latam_use_documents', '=', True)], 'readonly': [('posted_before', '=', True)]}"
attrs="{'invisible': [('l10n_latam_use_documents', '=', False)], 'required': [('partner_id', '!=', False), ('l10n_latam_use_documents', '=', True)], 'readonly': [('posted_before', '=', True)]}"
domain="[('id', 'in', l10n_latam_available_document_type_ids)]" options="{'no_open': True, 'no_create': True}"/>
<field name="l10n_latam_document_number"
attrs="{'invisible': ['|', ('l10n_latam_use_documents', '=', False), ('l10n_latam_manual_document_number', '=', False), '|', '|', ('l10n_latam_use_documents', '=', False), ('highest_name', '!=', False), ('state', '!=', 'draft')],
'required': [('l10n_latam_use_documents', '=', True), '|', ('l10n_latam_manual_document_number', '=', True), ('highest_name', '=', False)],
'required': [('partner_id', '!=', False), ('l10n_latam_use_documents', '=', True), '|', ('l10n_latam_manual_document_number', '=', True), ('highest_name', '=', False)],
'readonly': [('posted_before', '=', True), ('state', '!=', 'draft')]}"/>
</xpath>