Friday, February 24, 2023
4 changes · master
Resolved issues and error corrections
Weekly filters now start on the correct day for the user's language and country settings, such as Sunday for U.S. English and Monday for Belgian French. This makes weekly views align with dashboard reporting and avoids confusing date ranges in business workflows like accounting bills.
Original PR description
Steps to reproduce: - Make sure language preference is 'en_US' - In accounting, in the dashboard click on bills - Filter 'due_date' by week Issue: The start day is Monday and should be, for 'en_US',…
Steps to reproduce:
- Make sure language preference is 'en_US'
- In accounting, in the dashboard click on bills
- Filter 'due_date' by week
Issue:
The start day is Monday and should be, for 'en_US', Sunday as it is the case in the dashboard view in accounting (see appendix)
Cause:
The query uses the `date_trunc('week', date)` which in postgress retrieves the first day of the week as Monday.
Solution:
Create an offset in the query depending on the first day of the locale variable.
Note:
the `web/tests/test_read_progress_bar.py` has been modified: since the default language is 'en_US' there will be an offset of one day.
To make it less confusing, I used only two anglo-saxons countries so the day offset is not the variable tested.
(for this matter, pleaser refer to `test_read_group/tests/test_read_group_process_groupby.py`)
Appendix:
Language (english-US)
VIEW (per week) | DASHBOARD
___________________________________________________________________
W23 -> 06/05 | 05/29 -> 06/04
W24 06/06 -> 06/12 | 06/05 -> 06/11
W25 06/13 -> | 06/12 -> 06/18
(Monday - Sunday) (Sunday - Saturday)
Language (french-BE)
VIEW (per week) | DASHBOARD
___________________________________________________________________
W22 -> 06/05 | 05/30 -> 06/05
W23 06/06 -> 06/12 | 06/06 -> 06/12
W24 06/13 -> | 06/13 -> 06/19
(Monday - Sunday) (Monday - Sunday)
```
First day of the week as in Babel:
>>> import babel
>>> locale = babel.Locale('en', 'US')
>>> locale.first_week_day
6
>>> locale.days['format']['wide'][locale.first_week_day]
'Sunday'
>>> locale = babel.Locale('fr', 'BE')
>>> locale.first_week_day
0
>>> locale.days['format']['wide'][locale.first_week_day]
'lundi'
```
opw-2747066This fix limits extra record-specific information sent when forms load related data. It makes form loading behavior more consistent and prepares the web client for a future streamlined data-loading approach.
Original PR description
The form view currently reads its data as follows: 1) read the main record, which returns [id1, id2...] for x2manys and [id, display_name] for many2ones. 2a) read x2manys records, with the context…
The form view currently reads its data as follows:
1) read the main record, which returns [id1, id2...] for x2manys
and [id, display_name] for many2ones.
2a) read x2manys records, with the context set on the x2many field
node, which returns records like 1)
2b) call name_get for many2ones with option "always_reload" set to
true, with the context set on the many2one field node
3) same as 2), but for records returned by 2a)
The context set on a field node is a string, and needs to be evaluated (some placeholder values need to be replaced by actual values), e.g. "{'partner': partner_id}" -> { partner: 4 }.
For 2a and 2b, the context sent is evaluated with the main record as eval context. For 3, there an additional key "parent" in the eval context which contains the values of the parent record.
The rationale of this commit is that those data related keys in the eval context are useless for read-like rpcs.
In the future, the data of the form view will be fetched with a single rpc, returning the main record and its related records, with all the values required by the UI. To achieve that, we must ensure that sub records are never read with a dynamic context depending on the parent record.
This commit thus directly imposes the limitation, by removing from the eval context the record related data when it is used to evaluate the context to send to read-like rpcs.
Part of tasks 3171453 and 3179751
Description of the issue/feature this PR addresses:
Current behavior before PR:
Desired behavior after PR is merged:
---
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-prWork order blocking reasons in Manufacturing can now appear in the user's selected language. This improves clarity for multilingual teams and helps shop floor users understand why work is blocked.
Original PR description
Blocking reasons on workorders are not translatable, this fixes that. --- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
Reports and views that group information by week now use the correct first day of the week for the user's locale. This makes weekly figures align with local business expectations and reduces confusion when comparing date-based results.
Original PR description
Companion of https://github.com/odoo/odoo/pull/93053