bank-payment icon indicating copy to clipboard operation
bank-payment copied to clipboard

[14.0] account_banking_pain_base: Wrong length in AdrLine

Open jonerikceberio opened this issue 1 year ago • 4 comments

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:

  • Modify line 550, slicing the result of the join to 70
  • Modify line 546, substracting to 70 the length of the first element in val (if it exists) + 1 (for the space of the join)

jonerikceberio avatar Jan 17 '24 10:01 jonerikceberio

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.

github-actions[bot] avatar Jul 21 '24 12:07 github-actions[bot]

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).

alexis-via avatar Aug 23 '24 20:08 alexis-via

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.

github-actions[bot] avatar Feb 23 '25 12:02 github-actions[bot]

@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

luc-demeyer avatar Apr 16 '25 07:04 luc-demeyer