odoo/enterprise#67589

Created by Bugfix, Yolann Sabaux (yosa)
Merged at 39a55d9d915224fb764c4ff966b5fcef9bf57d9c

Statuses:

Linked pull requests
label
odoo-dev:16.0-opw-3993305-credit_note_document_ecuador-yosa
head
1e28e84ed33e547f5ea1728ed76dddd057850c31
merged
1 year ago by Accounting, Antoine Dupuis (andu)
odoo/odoo odoo/enterprise
16.0 #174950 #67589
17.0 #177597 #68775
saas-17.1 #177954 #68940
saas-17.2 #177974 #68949
saas-17.4 #178315 #69117
18.0 #181450 #70673
saas-18.1 #191668 #76129
saas-18.2 #197975 #79484
saas-18.3
saas-18.4
19.0
master #178433 #69158

[FIX] l10n_latam_invoice_document: prevent blocking foreign document number

Steps to reproduce:
[l10n_ec]
- Create a credit note from the Bill journal
- Set a foreign customer
- Set a customized document number

Issue:
An error will be raised saying that the format is not correct

But, as defined by VBE, "If a Credit Note is created from a Vendor Bill and the partner_id != "EC", [we should] allow the user to allocate any number without following the EC format."

Solution:
When we call _format_document_number we don't have any information about the initial move. Instead of using a context or adding new fields, we add a hook in which we can specify
certain conditions to bypass the document check/formatting for localisations.

We had to add partner_id to avoid the flow in wich the user set a foreign customer and a custom document type to change back the customer to an ecuadorian one; hence the second part of the test

opw-3993305