Steps to reproduce:
- Insert a list/pivot in a blank spreadsheet from a module (say Sales).
- Apply a global filter on it.
- Insert an odoo chart in the same sheet but from a different module (eg. CRM)
This works just fine when chart is inserted from the same model because it matches
the existing filter (from the pivot/list), and directly returns that field matching
without check the field matching from charts.
However in case of different model, the issue is that when there are no charts in the
sheet, the existing code of `getOdooChartIds` retrieves the incorrect chart ids
(`getChartIds` getter returns all chart ids, including the id of chart being inserted).
This leads to a traceback as the code tries to fetch fieldMatchings for a non-existent
chart within the sheet.
This commit resolves the issue by modifying the `getOdooChartIds` method to now utilize
`this.charts` instead of `getChartIds` getter, which correctly provides the ids of
charts already present in the sheet.
Task ID: 3573402
closesodoo/odoo#140700
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
In order to identify an ODOO.PIVOT.TABLE formula cell, we set the
display name of the pivot as the evaluated value of the cell containing
the formula.
closesodoo/odoo#140674
Task: 3580153
Related: odoo/enterprise#50003
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
Purpose
=======
This task answers two use cases making text filters more useful and easier to
use:
Always using the same few values
--------------------------------
The text filter allows to type any arbitrary text. However, some users will
always use the same few values. They will always again and again type the
same values, every time they want to set or change the filter value. That's
cumbersome. There's also a risk of making a typo while typing.
Parametric dashboards
---------------------
Some dashboards are built to be parametric (our business analysts do that a
lot). e.g. They put the measure field in a cell, then reference that cell in
PIVOT functions. If you want to have the same dashboard, but with another
measure: just update the cell with the new measure and that's it.
In read-only mode however, you can't update that cell :(
But you can mimic a variable parameter with a text filter. Create the text
filter, then get the filter value in a cell with the function
=ODOO.FILTER.VALUE("..."). Now you can update the cell value by setting
different values in the filter input.
However, you need to know exactly what value would be correct/valid for the
parameter. Typing any arbitrary text would lead to errors or unexpected
results. Business analysts can know that kind of technical stuff, but
lambda users don't. The solution is currently to duplicate the dashboard and
change the cell value with the exact parameter value you want.
Specification
=============
In the filter config side panel, allow the user to restrict the set of
possible values to values in a range of cells in the spreadsheet. Let's say
A1, A2, A3 contains Paris, Brussels, Berlin. If the user chooses A1:A3 in the
side panel, the text filter input is no longer a free text input, but becomes
a select with the 3 cities.
If a value from the range is selected, then the cell with this value is
changed to another value: keep the previous selected value selected.
display the values with their cell format but use their raw format for the
logic behind it (using the value as a cell value from ODOO.FILTER.VALUE)
closesodoo/odoo#139191
Task: 3554062
Related: odoo/enterprise#49204
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
If a chart was linked to an odoo menu, but the odoo menu didn't have
an action, the user would get a traceback when clicking on the chart.
This commit:
- Improves dashboard validation. Now we test that the menu is linked
to an action, in addition to testing that the menu exists
- Send a "danger" notification when the user clicks on a chart with
a menu without an action linked to it, rather than a traceback
closesodoo/odoo#139324
Task: 3563450
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
In the goal of simplify assets loading, in this commit we create a new
assets bundle for chartJS and its luxon adapter.
With this, we can now use loadBundle instead of load these two libraries
with loadJS.
task-3562357
closesodoo/odoo#139544
Signed-off-by: Michaël Mattiello (mcm) <mcm@odoo.com>
Adds in date type global filters a new category
"From / To" allowing to define a domain between
two dates.
closesodoo/odoo#138507
Task: 3516362
Related: odoo/enterprise#48855
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
Most tests that need the user id simply use `uid=7`, which will fail
if the default user id ever change in the tests. This commit replaces
it by `sessuin.user_context.uid`.
closesodoo/odoo#138733
Task: 3553122
Related: odoo/enterprise#48965
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
When importing a pivot with a date field in week format, the date was
formatted as "W2023 40" instead of "W40 2023".
closesodoo/odoo#137682
Task: 3539629
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
Allows to "See records" or "Set matching filter" on ODOO.PIVOT.TABLE
cell results.
(from the context menu in "spreadsheet mode" or by clicking on cells
in dashboard mode)
Task: 3318865
Part-of: odoo/odoo#138594
This commit introduces a new pivot function:
ODOO.PIVOT.TABLE(<pivot_id>, [row_count], [include_total], [include_column_headers])
Purpose
-------
It answers several current limitations:
- The pivot in spreadsheet not being "dynamic" (growing as new groups/records
are created) is a *very* frequent feedback
- sorted pivots are very cumbersome (# syntax) and takes a lot of cells
- cannot easily compute arbitrary aggregates (max, avg). You only get the
total. ... as soon as new groups appears that are not reflected in the
spreadsheet, you can't guess data is missing and that it's not taken into
account.
Specification
-------------
Add a single and simple function =ODOO.PIVOT.TABLE(<pivot_id>) that would
display the entire table (dynamic, as more groups and records are added).
We can achieve almost everything we want:
- by combining with other functions (INDEX, CHOOSECOLS, CHOOSEROWS, XLOOKUP,
...) if we want to target a specific row or column.
- by using infinite ranges (e.g. =MAX(B2:B)) to account for a growing table
- we could remove all the positional PIVOT version of the function
(=ODOO.PIVOT.HEADER(7,"#country_id",1)). The implementation is a mess
(lots of ifs everywhere to account for the #). Just replace it by a single
function SORT(ODOO.PIVOT.TABLE(1), 1) (or with NSORT, or sorted from the
pivot view directly)
For some situations though, there would be the "Totals" in the way:
if you want =MAX(ODOO.PIVOT.TABLE(1)), you don't want to have totals in the
way (with infinite ranges). We add an optional parameter 'include_total'
(default to true)
For dashboards, we want to have custom header names, we don't want to use
the headers from the pivot. To only have data and not the headers:
new parameter 'include_column_headers' (default to true)
All in all: here is what it looks like:
ODOO.PIVOT.TABLE(<pivot_id>, [row_count], [include_total], [include_column_headers])
Task: 3318865
Part-of: odoo/odoo#138594
Co-authored-by: Lucas Lefèvre <lul@odoo.com>
This commit removes the default exports from the spreadsheet module.
They don't bring anything except confusion when importing a mix of
default and named exports.
closesodoo/odoo#139071
Task: 3559536
Related: odoo/enterprise#49129
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
Fixed cumulative attribute not passing from odoo and also added a checkbox to
the odooLineChart side panel, enabling users to easily switch between cumulative
and non-cumulative display modes.
the chart shows cumulative data, offering a comprehensive view of data progression.
Deselection displays regular non-cumulative data.
Task-3420844
closesodoo/odoo#138708
X-original-commit: 90eeb7318a6ac1b0d1a4a41715f3a895f3d5d8b6
Related: odoo/enterprise#48954
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
When the side panel of a pivot is opened while the side panel of
another pivot is already open, the datasource of the first pivot is
used instead of the datasource of the second pivot. This can lead to
tracebacks, or to wrong data being displayed.
closesodoo/odoo#138338
Task: 3463289
X-original-commit: b6df2d807f7ffe0f0f89d894307e31d779f138e2
Related: odoo/enterprise#48775
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
Signed-off-by: Adrien Minne (adrm) <adrm@odoo.com>
This commit allows to reorder global filters via drag and drop. The
fact that global filters have a concept of order means that the
structure of the global filters in the core plugin need to change from
an Object<string, GlobalFilter> to an Array<GlobalFilter>.
closesodoo/odoo#135869
Task: 3502684
Related: odoo/enterprise#47583
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
The commands `ADD_GLOBAL_FILTER` and `EDIT_GLOBAL_FILTER` had the filter id
once in cmd.id, and once in cmd.filter.id. This made it possible to send
a command with 2 different ids, which can have arbitrary behaviour depending
on the implementation details of the command.
Changed it so we only use cmd.filter.id, and removed the cmd.id field. Also
simplified the commands helpers for the tests.
Task: 3502684
Part-of: odoo/odoo#135869
Task Description:
This PR aims to add the possibility to edit the evaluation domain of
an Odoo chart, the same way it can currently be done for other
datasources like `List` or `Pivot`. This revision ensures that the chart
datasources are properly reloaded their domain update.
closesodoo/odoo#135242
Task: 3384872
Related: odoo/enterprise#47336
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
Previously, when users selected the month or quarter filter and saved
it, the filter would only return data from the current year. This issue
has been fixed in this commit.
Merge the month and quarter data filters into a single month/quarter
filter. This will allow users to select a year which behave as year filter.
If a user only selects a month or quarter, the filter will work accordingly.
The year filter will be removed, as the month/quarter filter can now
be used to filter data by year.
In addition, a checkbox will be added to the relation filter that will
allow users to automatically select the current user. This checkbox
will only be displayed if the model is res.users.
closesodoo/odoo#126935
Task: 3370627
Related: odoo/enterprise#43426
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
Co-authored-by: Lucas Lefèvre <lul@odoo.com>
Purpose
-------
Currently, views with a contextual filter/domain are not well managed: e.g.
Today Activities
=> domain=[('my_activity_date_deadline', '=', context_today().strftime('%Y-%m-%d'))]
My pipeline
=> domain=[('user_id', '=', uid)]
Currently, 'context_today().strftime('%Y-%m-%d')' or 'uid' would be replaced by
their values when the view is inserted into a spreadsheet.
If the view is inserted on the 1st June 2023, the date "01/06/2023" is
hard-coded in the spreadsheet.
Specification
-------------
Preserve the domain dynamic parts when inserted into a spreadsheet.
Implementation note: I force the readable format at export just to be sure it
exported that way, no matter the domain origin.
closesodoo/odoo#131874
Task: 3414027
Related: odoo/enterprise#45748
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
The method is no longer used by the web client:
=> it should be private
See enterprise commit
closesodoo/odoo#133500
Task: 3483938
Related: odoo/enterprise#46460
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
This commit fixes two issues with the ´date´ argument for
the ODOO.CURRENCY.RATE function.
First, the helper to cast the date is `toJsDate`, not `toJSDate`. Using
the wrong function name obviously crashes.
Second, the date was actually given to the server as a full ISO datetime
string, including timezone (UTC).
For function `ODOO.CURRENCY.RATE("EUR","USD", "12-31-2020 00:00:00")`, we
actually sent to the server "2020-12-30T23:00:00.000Z" (Brussels local time)
Notice that it's the previous day!
The field of `res.currency.date` is a date field, so it doesn't make sense
to send a datetime.
Now, only the date is sent ("2020-12-31")
opw-3498115
closesodoo/odoo#136411
X-original-commit: 6a4b7e7f216dc9a6372f5cc382262ff09cb317f3
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
- When a new pivot is added, and if the user has already defined
field matching in a previous pivot, the new pivot will inherit the
field matching from the previous pivot as default values.
- If multiple pivots are added from different models, will check the
model of the new pivot against previous pivots. If the model matches,
the field matching from the matching previous pivot will be used. If
no matching model is found, the field matching will be left empty.
- Same will also done in case of list and odoo chart.
closesodoo/odoo#135841
Taskid: 3373163
Related: odoo/enterprise#47570
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
See enterprise PR ;)
Property fields are not supported in spreadsheet.
In saas-16.2, it even completely ruins the entire list
if it contains one property field.
With this commit, until we support properly property fields[1],
we ignores property field when the list view is inserted
in spreadsheet
[1] in master, see task 3329490
opw-3284273
opw-3465243
closesodoo/odoo#132138
Task: 3329490
X-original-commit: ada541d6c4a8d0a5b515c4f1f7e9d71c54b992d5
Related: odoo/enterprise#45844
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
Change version of Chart.js from V2.9.3 to V4.3.0
You can find changelog on
https://www.chartjs.org/docs/latest/migration/v4-migration.html
Version 4.3.0 of chart.js no longer uses moment.js. This task is a
prerequisite to completely remove the use of moment.js (task 3391739)
Why add aspectRatio : 2 ? => Canvas aspect ratio (i.e. width / height,
a value of 1 representing a square canvas). Note that this option
is ignored if the height is explicitly defined either as attribute
or via the style. The default value varies by chart type; Radial charts
(doughnut, pie, polarArea, radar) default to 1 and others default to 2.
Why no more Chart.animationService.advance(); ?
There is no longer an equivalent in this version.
However, we have verified that the problem is no longer present in this
version.
Why use now getElementsAtEventForMode ?
It's clearly noted in the changelog. follow the link above.
task-3392075
Part-of: odoo/odoo#127259
This commit introduces models related to sharing dashboard, and
implements the sharing from dashboard view.
The basic idea is the same as sharing normal spreadsheet. The major
difference is that sharing a dashboard will direct to the dashboard view
instead of read-only spreadsheet view. A button and a side panel which
shows the global filters show up only in the dashboard view.
task 3378150
closesodoo/odoo#127370
Related: odoo/enterprise#43664
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
Co-authored-by: Lucas Lefèvre <lul@odoo.com>
This commit improves the way months are recognized in pivot functions.
It also removes the use of `moment.js` which will be removed in the future
(see task 3391739)
Currently, months in a pivot function must follow a very specific
format.
It must be mm/yyyy
`ODOO.PIVOT(1, "amount", "date:month", "01/2020")`
Among other things: "1/2020" does not work, it must be prefixed by a
leading zeros.
Now, any date-like value would work:
month: "1/2020"
first of the month: "1/1/2020"
any day in the month: "1/2/2020"
using the DATE function: DATE(2020, 12, 1)
using NOW()
Future work: `PIVOT.HEADER` should return a the date as a number
when the date is a month. But it's currenctly quite a mess.
because we use the same method for a million things (`getGroupByDisplayLabel`).
Task 3413243
closesodoo/odoo#129782
Related: odoo/enterprise#44684
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
This commit add a small indicator in the spreadsheet's control panel
to indicate if the user's locale is different from the spreadsheet's.
closesodoo/odoo#129857
Task: 3389491
X-original-commit: 5c776994f7bd230816369be3899989e7ab780906
Related: odoo/enterprise#44665
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
luxon and moment are both used in the solution, but
these two libraries facilitate the manipulation of dates.
It was decided to replace all uses of moment with
luxon so we can then remove moment.js from the
code and lighten the assets.
task-3391739
closesodoo/odoo#127406
Signed-off-by: Mathieu Duckerts-Antoine (dam) <dam@odoo.com>
Rationale
=========
Since v8, the `display_name` field is present on all models. By default,
`display_name` uses `name_get` which has pretty much the same purpose
(return record name used by the web client). Gradually, many (backend)
developers (and the ORM: https://github.com/odoo/odoo/commit/6da1c3ac4c036eac289597602976538e243cb939)
started using `display_name` (more convenient than
`record.name_get()[0][1]`) but it still had the `name_get` override.
It becomes more complex than necessary and poeple start to misunderstand
the two (and sometimes override both, leading to inconstiencies between
`display_name`/`name_get`).
To simplify the ORM and the API, we decided to keep only one of them,
the `display_name` field:
- It is much more convenient from a backend point of view
(`record.name_get()[0][1]` vs `record.display_name`)
- It is cached during the same transaction (and invalidated if
its dependencies change)
- It can be overridden like any other compute field (override
`_compute_display_name` with any extra dependencies)
- `name_get` is replaced by `read(['display_name'])`
(API perceptive), which can actually be more efficient
(if `display_name`'s depends are correct, the ORM will only fetch the
fields it needs instead of every prefetchable field)
Changes
=======
- Deprecates `name_get` for the v17 and based the method on
`display_name` (the opposite of before)
- Converts all usage of `name_get`
- Overrides of `name_get` are now overrides of `_compute_display_name`
- For `res.partner`, rename the field store `display_name` into
`complete_name` because `display_name` context-dependent and it makes
no sense to have a compute store that is context-dependent.
- Previously, it was possible to return multiple names for the same
record with `name_get`, but it was tricky and most of the usage of
this `name_get` didn't take this into account. The only example of
this is the `name_get` of `product.product`
(now use `", ".join(<names>)`).
Part-of: odoo/odoo#122085
The menus added in the server data which are used in mockServer did not
reflect a realistic menu configuration. This was brought to light when
trying to fix the addition of links to ir.ui.menu inside a spreadsheet.
See task 2821480
Related ENT pr: https://github.com/odoo/enterprise/pull/42885closesodoo/odoo#126497
X-original-commit: 128475e8c29f8493b01710342179a5c468897c61
Related: odoo/enterprise#43209
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
Task Description
When autofilling a pivot/list cell from another pivot/list cell,
the format of the target wasn't overwritten. This can lead to some
strange behaviour where the user set the desired format to a cell
then autofill the remaning cell of the column/row to apply the same
format once and nothing happen.
We now propagate the set format with the pivot/list autofill, but
we still don't propagate the style and border definition, as it
could break the currently defined pivot/list style.
Related Task
task-3252442
closesodoo/odoo#124984
X-original-commit: 8678b716a9fe2b38e9ed5d399d89df2343ee239c
Related: odoo/enterprise#42542
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
Signed-off-by: Hendrickx Anthony (anhe) <anhe@odoo.com>
We make the class DisplayNameRepository use the name service instead of
BatchEndpoint. This makes the code simpler and allow to avoid a lot of
rpcs (in some occasions) when fetching display names.
closesodoo/odoo#124090
Related: odoo/enterprise#42124
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: Lucas Lefevre <lul@odoo.com>
The json fields are not supported in lists at the moment because they
require additional RPC to fetch the display value as long as its
formatting.
closesodoo/odoo#122074
Task: 3324679
X-original-commit: 9e6d598e6a96434c68634149ecf1acf3e714ca03
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
In this commit we add the makeServerError utility which allows you
to easily create a valid RPCError in the tests.
We have added this utility to prevent the use of invalid or incomplete
errors. We will give default values for all the parameters needed for
a valid RPCError.
For example, in some tests, we only check the presence of an error
dialog and not the expected one. So there was a set of tests that were
green because the failure was in the RPCError handling. So we had an
error dialog but it was not the right one. In general, the crash occurred
because the RPCError contained no data.
closesodoo/odoo#121932
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit implements the functionality of using backspace key to
delete values in relation filter.
task 3324738
closesodoo/odoo#121513
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
Before this commit, the pivot's dataSources were managed by the core plugin
`PivotCorePlugin`. This didn't make sense since dataSources aren't core data:
- they are neither exported nor imported
- they can be different for each user (their ids were generated via uuidv4
at import)
- managing them required to handle local command in the core plugin
Moved the dataSources management to the UI plugin `PivotUIPlugin` and moved
the relevant getters inside this plugin. Changed the ids of the dataSources
to be the same as the pivot's id + a prefix, to avoid having to maintain a
mapping `pivotId` <=> `dataSourceId` .
This commit also removes the dataSourceId from the `INSERT_PIVOT`
command, which have no place here since this is a core command and the
dataSources are now a pure UI concept.
This is slighly more tricky than for lists, because the datasource need to
be loaded before the `INSERT_PIVOT` command to fetch the table structure.
The component dispatching the command need to make sure it creates a
dataSource with the id given by the getter `getPivotDataSourceId`,
or else the dataSource will be loaded twice.
Task: 3293491
Part-of: odoo/odoo#120136
Before this commit, the list's dataSources were managed by the core plugin
`ListCorePlugin`. This didn't make sense since dataSources aren't core data:
- they are neither exported nor imported
- they can be different for each user (their ids were generated via uuidv4
at import)
- managing them required to handle local command in the core plugin
Moved the dataSources management to the UI plugin `ListUIPlugin` and moved
the relevant getters inside this plugin. Changed the ids of the dataSources
to be the same as the list's id + a prefix, to avoid having to maintain a
mapping `listId` <=> `dataSourceId` .
This commit also removes the dataSourceId from the INSERT_ODOO_LIST
command, which have no place here since this is a core command and the
dataSources are now a pure UI concept.
Task: 3293491
Part-of: odoo/odoo#120136
Steps to reproduce the issue:
1. Project> select Project > Task> List view
2. Studio list view > Add existing properties field
3. Go back to list view > Favorites > add to spreadsheet
4. New Spreadsheet > Will receive error
opw-3284273
closesodoo/odoo#120473
X-original-commit: 5eb80e34db2e54b56164ea4b98bea3cebb09312b
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
This commit adds YTD (year to date) filter to global period filters in
dashboard.
YTD filter gets the data from Jan 1st of the current year to
today (included). The unit of its offset is year.
task 3215947
closesodoo/odoo#118466
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
This commit includes the ongoing day in the current period filters.
Now the start date (time) of each period filter is the start of next day,
and the end date (time) is the end of today.
task 3267525
closesodoo/odoo#118326
Related: odoo/enterprise#39641
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
Before this revision, a date/datetime field was displayed in UTC instead
of in the user timezone.
This revision fixes this issue.
opw 3127742
closesodoo/odoo#117623
X-original-commit: c07b450594f7e3e1f093d0b5a5a083f915f75310
Signed-off-by: Lucas Lefèvre (lul) <lul@odoo.com>
Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>