Skip to content

[FIX] localize and canonicalize content#8275

Open
matho-odoo wants to merge 3 commits into
saas-18.2from
saas-18.2-fix-date-locale-matho-rar
Open

[FIX] localize and canonicalize content#8275
matho-odoo wants to merge 3 commits into
saas-18.2from
saas-18.2-fix-date-locale-matho-rar

Conversation

@matho-odoo
Copy link
Copy Markdown
Contributor

@matho-odoo matho-odoo commented Apr 1, 2026

Task: 6089166

review checklist

  • feature is organized in plugin, or UI components
  • support of duplicate sheet (deep copy)
  • in model/core: ranges are Range object, and can be adapted (adaptRanges)
  • in model/UI: ranges are strings (to show the user)
  • undo-able commands (uses this.history.update)
  • multiuser-able commands (has inverse commands and transformations where needed)
  • new/updated/removed commands are documented
  • exportable in excel
  • translations (_t("qmsdf %s", abc))
  • unit tested
  • clean commented code
  • track breaking changes
  • doc is rebuild (npm run doc)
  • status is correct in Odoo

@robodoo
Copy link
Copy Markdown
Collaborator

robodoo commented Apr 1, 2026

Pull request status dashboard

@matho-odoo matho-odoo changed the title [WIP] part 1 [FIX] localize and canonalize content Apr 1, 2026
@matho-odoo matho-odoo force-pushed the saas-18.2-fix-date-locale-matho-rar branch 4 times, most recently from 8481808 to a848d61 Compare April 2, 2026 12:46
Copy link
Copy Markdown
Contributor

@hokolomopo hokolomopo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit format is wrong, otherwise LGTM :)

Comment thread src/components/composer/composer/abstract_composer_store.ts
Comment thread tests/data_validation/data_validation_core_plugin.test.ts Outdated
@matho-odoo matho-odoo force-pushed the saas-18.2-fix-date-locale-matho-rar branch 2 times, most recently from 1a8c8bf to 569930d Compare April 9, 2026 11:18
Comment thread src/components/composer/composer/abstract_composer_store.ts
Comment on lines -364 to -365
protected getCurrentCanonicalContent(): string {
return canonicalizeNumberContent(this._currentContent, this.getters.getLocale());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove it from here and copy the exact same code in the children ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One children use "canonicalizeContent" and the other "canonicalizeNumberContent"

Copy link
Copy Markdown
Collaborator

@LucasLefevre LucasLefevre Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's very weird and it's impossible to understand and know why by reading the code.

I found out it's because of dates which are not canonical on UPDATE_CELL (and then core detects the format).
If we want to be consistent and to always use canonical content on the wire, shouldn't we change that ?

At the very least, it deserves a comment.

canonicalizeNumberContent and canonicalizeContent should not both exist, only one them. It's very confusing, and you don't know which one should be used. But that's a refactoring for master.

Comment thread src/components/side_panel/data_validation/data_validation_panel.xml
Comment thread src/registries/data_validation_registry.ts
@matho-odoo matho-odoo force-pushed the saas-18.2-fix-date-locale-matho-rar branch 14 times, most recently from 4a5f361 to d791e53 Compare April 15, 2026 06:38
}

protected getCurrentCanonicalContent(): string {
return canonicalizeNumberContent(this._currentContent, this.getters.getLocale());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment to explain why you used two different canonicalize method (here and in standalone_composer_store)

@matho-odoo matho-odoo force-pushed the saas-18.2-fix-date-locale-matho-rar branch from d791e53 to b49fb7e Compare April 17, 2026 07:19
@rrahir rrahir changed the title [FIX] localize and canonalize content [FIX] localize and canonicalise content Apr 21, 2026
@rrahir rrahir changed the title [FIX] localize and canonicalise content [FIX] localize and canonicalize content Apr 21, 2026
@matho-odoo matho-odoo force-pushed the saas-18.2-fix-date-locale-matho-rar branch 2 times, most recently from eb413e9 to 684f127 Compare April 27, 2026 06:42
@matho-odoo matho-odoo force-pushed the saas-18.2-fix-date-locale-matho-rar branch 2 times, most recently from e74da37 to ef2dd7a Compare April 28, 2026 07:42
Comment on lines +25 to +26
const canonicalizedValue = canonicalizeContent(value, locale);
this.composer.setCurrentContent(canonicalizedValue);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

composer.setCurrentContent is supposed to take localized content, since it later takes this._currentContent and run canonicalizeNumberContent on it

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think it's what it does ^^

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I change it to localizedValue, Lucas is right :)
(and on top of that, value was already canonical)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read the sentence backwards, I think ><

@matho-odoo matho-odoo force-pushed the saas-18.2-fix-date-locale-matho-rar branch 2 times, most recently from 9176607 to 300be91 Compare April 29, 2026 07:49
@LucasLefevre
Copy link
Copy Markdown
Collaborator

testing Claude review skill:

Commits

7c6ed6dd7 removes .map(canonicalizeContent…) but leaves the preceding .filter(...) without a trailing ; (relying on ASI); ef2dd7a63 adds it back. Cosmetic — not a blocker, but ideally squashed.

ef2dd7a63 bundles unrelated pivot_composer_helpers.ts / auto_complete_registry.ts typing changes (adding getters to the this type) alongside CF localization work. Defensible since it's required by data_validation_auto_complete.ts in the same commit.

Findings

src/registries/data_validation_registry.ts:747 — nit

getNumberCriterionlocalizedValues has a casing typo (localizedValuesLocalizedValues) and the "Number" name is misleading — it's also used for isValueInList, which stores dates/text too. Rename to getCriterionLocalizedValues.

src/registries/data_validation_registry.ts:147 — nit

getPreview: (criterion: TextContainsCriterion, …) is used for the textIs entry; the inner field type should be TextIsCriterion. Same shape, but the wrong-name annotation is confusing.

src/registries/data_validation_registry.ts:109,131,153 — nit

criterion.values[0]?.toString()values is string[], so both ?. and .toString() are redundant. Just use criterion.values[0].

src/registries/data_validation_registry.ts:685,696 — warning

isValueInList preview/error now uses locale.formulaArgSeparator as separator (e.g. ; in FR). Display only, but it's a UX change from the old hardcoded ", " — worth a one-line comment or confirming it matches the spec for the task.

src/components/side_panel/data_validation/dv_criterion_form/dv_input/dv_input.ts:63,70 — nit

localizeContent(...) ?? ""localizeContent is typed (string, Locale) => string and never returns nullish. Drop the fallback or change the helper's contract.

src/components/side_panel/data_validation/dv_criterion_form/dv_input/dv_input.ts:60-65 — warning

onWillUpdateProps overwrites state.textInput whenever the parent's props.value changes. If the parent re-renders for any reason while the user has uncommitted input in the field, their text is lost. In practice the parent only re-renders the value on confirm, so it's fine today — but worth gating on nextProps.value !== canonicalizeContent(this.state.textInput, locale) to be safe.

tests — coverage gap (warning)

No test exercises the CF editor color-scale/icon-set localized input path added in ef2dd7a63 (typing 1,5 in FR locale should canonicalize to 1.5 in the rule). Worth a focused component test.

Before this commit:
- Set the locale to french
- Open the data validation side panel and create a rule with "Date is" 1/3/2026
- Press Enter
In the composer : the date is canonicalized to the default format 03/01/2026
In the preview (after saving): the date is correctly displayed in the localized format 01/03/2026

The displayed date should always follow the locale format
and the value stored in the model should always be in the default format.
We decided to immediately canonicalize the input and to only use the locale for display

Task: 6089166
@matho-odoo matho-odoo force-pushed the saas-18.2-fix-date-locale-matho-rar branch from 300be91 to 3a79bc6 Compare May 18, 2026 08:11
Before this commit :
Issue in the input of a "value in list" DV
1/2 was automaticcaly transformed into 1/2/2026 and no change was possible

After this commit:
The input is stocked in a state and is only transformed when the user confirms his input

Task: 6089166
@matho-odoo matho-odoo force-pushed the saas-18.2-fix-date-locale-matho-rar branch from 3a79bc6 to e3c06b5 Compare May 18, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants