[14.0] account_banking_pain_base: Wrong length in AdrLine
When generating the PAIN file, the second node AdrLine is generated as the join of zip and city. Both fields are limited to 70 char in the process, but then are joined, which can result in a >70 char AdrLine, and therefore in an error: odoo.addons.account_banking_pain_base.models.account_payment_order: Element '{urn:iso:std:iso:20022:tech:xsd:pain.008.001.02}AdrLine': [facet 'maxLength'] The value has a length of '76'; this exceeds the allowed maximum length of '70'
To Reproduce:
- Create a partner with zip and city, and length of the city field with a length of 70.
- Create an invoice to that partner
- Add the invoce to a payment order
- Generate the file, which will turn into an error
Possible solution:
There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.
I confirm this very stupid bug. It was introduced by @luc-demeyer in this commit https://github.com/OCA/bank-payment/commit/198fc3c20393f7a42869bed504d1cbad65d51932 I fixed yesterday it in my v16 PR https://github.com/OCA/bank-payment/pull/1174 (I re-wrote the code for address block generation ; it implements both structured and unstructured and I found and fixed the bug in the unstructered code).
There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.
@alexis-via @jonerikceberio A quick solution for Odoo 14.0 could be
if partner.zip:
val.append(
self._prepare_field(
"zip",
"partner.zip",
{"partner": partner},
25,
gen_args=gen_args,
)
)
if partner.city:
val.append(
self._prepare_field(
"city",
"partner.city",
{"partner": partner},
70,
gen_args=gen_args,
)
)
adrline2.text = " ".join(val)[:70]
Hence we limit ZIP to 25, City to 70 and the resulting AdrLine to 70.
If this looks OK than I can make a PR for 14.0 and we can cherry-pick this one to the newer versions. What about also limiting ZIP to 25 in your refactoring PR https://github.com/OCA/bank-payment/pull/1174 ?
About the length of the ZIP: 25 could be too much, imho 15 will probably cover all countries on this planet.
Regards, Luc