Skip to content

Conversation

@fw-bot
Copy link
Contributor

@fw-bot fw-bot commented Dec 12, 2024

Steps to reproduce the issue:

  • go to currencies;
  • search for a rate with something else than a date;
  • it crashes.

This happens because the currency rate model is searched with two fields, a date field (name) and a float field (rate). This crashes when converting the value to match against, because the value cannot be serialized in SQL both as a date and a float.

What we do in such a case is to explicitly convert the value to the field's type. If the conversion fails, we simply ignore that part of the domain.

opw-4278234

Forward-Port-Of: #190495
Forward-Port-Of: #187838

@robodoo
Copy link
Contributor

robodoo commented Dec 12, 2024

Pull request status dashboard

@robodoo robodoo added forwardport This PR was created by @fw-bot conflict There was an error while creating this forward-port PR labels Dec 12, 2024
@fw-bot
Copy link
Contributor Author

fw-bot commented Dec 12, 2024

@loleloup @rco-odoo cherrypicking of pull request #187838 failed.

stdout:

Auto-merging odoo/addons/base/tests/test_res_currency.py
Auto-merging odoo/models.py
CONFLICT (content): Merge conflict in odoo/models.py

Either perform the forward-port manually (and push to this branch, proceeding as usual) or close this PR (maybe?).

In the former case, you may want to edit this PR message as well.

⚠️ after resolving this conflict, you will need to merge it via @robodoo.

More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port

@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Dec 12, 2024
@loleloup loleloup force-pushed the 18.0-16.0-base_fix_currency_rate_name_search-lole-Wj6V-fw branch from fd595fd to a38a743 Compare December 13, 2024 09:00
@C3POdoo C3POdoo requested review from a team, Gorash and ryv-odoo and removed request for a team December 13, 2024 09:02
Steps to reproduce the issue:
- go to currencies;
- search for a rate with something else than a date;
- it crashes.

This happens because the currency rate model is searched with two
fields, a date field (name) and a float field (rate).  This crashes when
converting the value to match against, because the value cannot be
serialized in SQL both as a date and a float.

What we do in such a case is to explicitly convert the value to the
field's type.  If the conversion fails, we simply ignore that part of
the domain.

opw-4278234

X-original-commit: e1b02bb
@loleloup loleloup force-pushed the 18.0-16.0-base_fix_currency_rate_name_search-lole-Wj6V-fw branch from a38a743 to bae1ba9 Compare December 13, 2024 09:13
@rco-odoo
Copy link
Member

@robodoo r+

@robodoo robodoo closed this in a4c2f66 Dec 13, 2024
@fw-bot fw-bot deleted the 18.0-16.0-base_fix_currency_rate_name_search-lole-Wj6V-fw branch December 27, 2024 13:55
gamarino pushed a commit to numaes/numa-public-odoo that referenced this pull request Jan 24, 2025
Steps to reproduce the issue:
- go to currencies;
- search for a rate with something else than a date;
- it crashes.

This happens because the currency rate model is searched with two
fields, a date field (name) and a float field (rate).  This crashes when
converting the value to match against, because the value cannot be
serialized in SQL both as a date and a float.

What we do in such a case is to explicitly convert the value to the
field's type.  If the conversion fails, we simply ignore that part of
the domain.

opw-4278234

closes odoo/odoo#190596

X-original-commit: e1b02bb2864b9a14bdc80b72aa6c2397047d6830
Signed-off-by: Raphael Collet <[email protected]>
d-fence added a commit to odoo-dev/odoo that referenced this pull request Apr 11, 2025
Since babel 2.11 `babel.parse_date` handle ISO dates first.
So before 2.11 the date "1971-01-01" was raising a `ValueError` which
was ignored in the base model `_search_display_name`.

It seems that the intention of odoo#190596 was to catch the value error when
an invalid string is casted to float.

The upcoming Debian Trixie provides Babel 2.17.0 which parses the date
correctly and thus returns a `datetime.date` leading to a TypeError when
trying the float conversion. See python-babel/babel#842.

In order to have a coherent test in both versions, in this commit, the
test is modified to use a valid date to parsable by both versions.

Finally, a naive fix is done to catch the TypeError as well.

It seems that the whole feature should be rewritten in master.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflict There was an error while creating this forward-port PR forwardport This PR was created by @fw-bot OE the report is linked to a support ticket (opw-...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants