Repository navigation
Conversation
…fix date handling
… date format Cells holding a date as text (e.g. 25/12/2025) were passed on as is and rejected by the import, which only accepts ISO dates. When the field is a date or datetime, the text is now parsed with the date format of the user's language and converted to ISO. Real date cells (handled by the previous commit) and text that does not match the format keep their behavior.
…mport of xls and xlsx files
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on: OCA#3479
Test coverage of the changed lines: 100.0%
Contexto
OCA#3479 fixes the cells that Excel stores as real dates (they become
%Y-%m-%d). It does not cover a date typed as text in the sheet, such as25/12/2025, which is very common in spreadsheets sent by suppliers and customers: the text is passed on as is and the import rejects it, because the standard load only accepts ISO dates.O que muda
_get_cell_valuetakes an optionaldate_format. Fordateanddatetimefields, a text cell is parsed with that format (and with the timeHH:MMorHH:MM:SSafter it) and converted to the ISO string the import expects. Text that does not match the format is kept as it was, so ISO text and invalid values behave as before.xlsx.importpasses the date format of the language of the user (res.lang.date_format), so a user inpt_BRcan type25/12/2025and one inen_US12/25/2025._get_date_cell_value) to keep the function below the complexity limit of the pre-commit, with the same behavior.For
datetimefields the converted value goes to the standard import, which decides the time zone, as it already does for any other datetime.Como testar (passo a passo na base de demonstração)
The module has no demo module in 18.0, so the check uses a template made by hand:
excel_import_exportand set the language of the user to Portuguese (Brazil).{"__IMPORT__": {"Sheet1": {"_HEAD_": {"B2": "name", "B3": "<date field>"}}}}.25/12/2025, in a cell formatted as text) in B3, and import it with the template.12/25/2025.Testes automatizados
tests/test_text_date.py(new): text date and datetime with the language format, text kept when it does not match, no conversion without a format, and the date format taken from the language of the user. 5 tests, no failures.