Bug 267331

Summary: finance/odoo export to XLSX/CSV fails
Product: Ports & Packages Reporter: Dimitri Kaparis <dimitri>
Component: Individual Port(s)Assignee: Jose Alonso Cardenas Marquez <acm>
Status: Closed FIXED    
Severity: Affects Only Me Flags: bugzilla: maintainer-feedback? (acm)
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   

Description Dimitri Kaparis 2022-10-25 10:04:34 UTC
Attempting to export items to CSV or XSLX format (e.g. products list) fails with the following error message in the front end:

```
UncaughtClientError > TypeError

Uncaught Javascript Error > invalid parameter format

TypeError: invalid parameter format
    parse@https://erp-stage.poype.io/web/assets/1563-d1f4fe4/web.assets_common.min.js:4547:45
    get_file/xhr.onload@https://erp-stage.poype.io/web/assets/1563-d1f4fe4/web.assets_common.min.js:4678:241
```

No error appears in the server's log.

The same issue is reported upstream: https://github.com/odoo/odoo/issues/94110.
A comment there points that the reason is incompatible version of `Werkzeug` module.

https://github.com/odoo/odoo/blob/15.0/requirements.txt lists `Werkzeug==0.16.1` dependency for Python 3.9 and lower. This port applies corrections to some Odoo modules to work with the current 2.* version of Werkzeug. To fix this issue, either adjustments need to be similarly applied to the relevant js generation code, or the whole thing reverted to use Werkzeug 0.16.
Comment 1 Jose Alonso Cardenas Marquez freebsd_committer freebsd_triage 2022-10-31 23:02:33 UTC
(In reply to Dimitri Kaparis from comment #0)

Could you test change line into js file instead of delete it?

Look at https://github.com/odoo/odoo/issues/103232 it is a similar issue on odoo 16 but it replace the "if" line to the following:

(index == -1 && index !== string.length)

Test it and tell me if it works for you
Comment 2 Dimitri Kaparis 2022-11-14 15:21:40 UTC
(In reply to Jose Alonso Cardenas Marquez from comment #1)

The above issue references file `addons/web/static/src/core/network/download.js` line 225.

The file is installed by the port at `/usr/local/lib/python3.9/site-packages/odoo/addons/web/static/src/core/network/download.js`. The mentioned condition is on line 220, the whole block is:

```
    if (index !== -1 && index !== string.length) {
        throw new TypeError("invalid parameter format");
    }
```

As directed, I changed the condition line to:
`if (index == -1 && index !== string.length) {`

This did not solve the issue for my install and the error persists, also after
rebooting the server and clearing cache and site data of the browser.
Comment 3 Jose Alonso Cardenas Marquez freebsd_committer freebsd_triage 2022-11-14 15:29:51 UTC
(In reply to Dimitri Kaparis from comment #2)
I know it is a download.js file but the same function check/validation is used by addons/web/static/src/legacy/js/libs/content-disposition.js

I mean you must change this similar line at content-disposition.js too instead of remove them
Comment 4 Dimitri Kaparis 2022-11-14 15:41:02 UTC
(In reply to Jose Alonso Cardenas Marquez from comment #3)

Changing the same condition in file
`/usr/local/lib/python3.9/site-packages/odoo/addons/web/static/src/legacy/js/libs/content-disposition.js`,
line 214 solved the issue for me. A quick test with that change shows item exports are running successfully.
Comment 5 commit-hook freebsd_committer freebsd_triage 2022-11-15 16:47:42 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=5870c06b97934edd150809f8c75cff0d2345fd29

commit 5870c06b97934edd150809f8c75cff0d2345fd29
Author:     Jose Alonso Cardenas Marquez <acm@FreeBSD.org>
AuthorDate: 2022-11-15 16:44:46 +0000
Commit:     Jose Alonso Cardenas Marquez <acm@FreeBSD.org>
CommitDate: 2022-11-15 16:47:03 +0000

    finance/odoo: Fix issues with latest version of py-werkzeug

    - Fix path to odoo.conf file
    PR:             267331 266478
    Reported by:    Dimitri Kaparis <dimitri .at. kaparis.name>

 finance/odoo/Makefile      | 5 ++++-
 finance/odoo/files/odoo.in | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)
Comment 6 Jose Alonso Cardenas Marquez freebsd_committer freebsd_triage 2022-11-15 16:48:19 UTC
Committed thanks!