This commit refactors the patch function in order to simplify its code
but also and most of all remove the `this._super` bound on each patched
method call.
The patch function now supports the javascript keyword `super` to
get the parent's property.
This removes constraints we had with `this._super`. We had to create a
rather complicated intermediate function to bind `this._super` and this
function was called each time before we called a patched method.
It was annoying for debugging but necessary. Because of this
intermediate function `this._super` was also had to re-bind each time
we entered a patched method which was annoying with async method, we
had to save the parent method in the patch before awaiting its
execution. Finally, not a big issue but still, objects could not have a
`_super` property as it would be hidden in the patch.
task 3410198
Part-of: odoo/odoo#125716
The goal of this commit is to complete the list of activeFields for
an x2many in list mode when a record is opened with the fields present
in its form view. This ensures that there is always an activeField
for all the data in a record. Before this commit, when the x2many's
form view was not inline, when the form view was closed, the fields
not present in the list view no longer had an activeField, which could
cause crashes.
closesodoo/odoo#130453
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Before this commit, in some cases (many2one invisible) unity returned
an integer as value.
Now, to be consistent, unity always return an object for many2one.
Note that, web_read_group still returns an array as value for many2one.
part-of task-id~3179751
closesodoo/odoo#130340
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit adds the "show weekends" functionality to calendar which
allows the user to choose whether weekends should be shown in the calendar
or not (defaults to false).
task-3425523
closesodoo/odoo#129107
Signed-off-by: Luca Vitali (luvi) <luvi@odoo.com>
In odoo/odoo#120893, the mail team changed their test utils so that they
would always start all services. This can cause issues because services
do not have any built-in destruction/cleanup mechanism, as in a
production application they are only supposed to be started once. Some
services add event listeners on global objects, in particular, the
tour service adds an event listener on the tour registry which is
global. If this event listener is not cleaned up, every time the tour
service is started, a reference to the environment in which this tour
service is being started is leaked. Since the environment contains all
started services, it is typically a pretty heavy object, especially
since in this context, all services are started instead of a select
subset.
This commit fixes that by patching the EventBus class to automatically
remove event listeners that were added on an event bus after the test,
in a similar fashion to what we do for some global objects like window
or the document's body.
closesodoo/odoo#130373
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Now that most of the webclient codebase (fields, views, client
actions...) has been converted to owl, the legacy extra next tick
used in a lot of tests is no longer necessary. This commit removes
the helper and its usage. At some places, a real tick was needed,
but we didn't see it because of the use of the legacy extra next
tick.
Part of task~3439226
closesodoo/odoo#130236
Related: odoo/enterprise#44869
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
In a previous commit 8bfa76a, _lt() returns _t().
So, in this commit, all usages of _lt() are replaced by _t().
task-3292454
closesodoo/odoo#130179
Related: odoo/enterprise#44906
Signed-off-by: Luca Vitali (luvi) <luvi@odoo.com>
Previously, we have accidentally made some core modules depend on some
modules outside of the core folder (eg views), this is undesirable as it
can make assets bundle hard to write using globs, and can make it easy
to introduce circular dependencies, it also doesn't make sense from a
code-organisation perspective.
This commit introduces a QUnit test that checks the modules in some
folders only depend on other whitelisted folders.
closesodoo/odoo#129982
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Purpose
=======
Currently, when we want to add a properties selection option, we need
to focus another option and press enter. This will add the new option
at the end, but we want to add it just after the focused option.
Task-3338157
Part-of: odoo/odoo#123216
This commit allows the correct activeFields to be used depending on the
view used to open an x2many field.
Before this commit, if we had an x2many field with a list view and a form
inline view with the same field containing a different context depending
on the view. The context of the form view will always be used.
This is a problem:
If we have an inline form view with fields common to the list view,
the context of the activeFields in the form view will always be used
and we will try to combine the different modifiers (required, readonly, etc.).
We don't want to do this, we want to use the activeFields of the list view
when we open the record in the list and the activeFields of the form view
when we open the record in the form view.
Solution:
When we create the activeFields, we'll use the activeFields from the
list view and complete them with those from the form view. We will
therefore no longer replace or merge them.
Then, when we open a record in form view, we'll use the activeFields
from the form view and when the form view closes, we'll restore the
activeFields from the list view.
closesodoo/odoo#129989
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
- open a grouped kanban view with progressbar;
- select a progressbar;
- the records are filtered and the count/aggregate is updated;
- change the filter/domain that will reduce/increase the filtered
records.
Before this commit, the records are correctly update but the
count/aggregate is not update.
Now, the count/aggregate of a selected progressbar is updated if the
domain changes.
task-3422009
X-original-commit: 95a94e0d928729bbbc80a627f816f9e575121f8d
This commit adds the possibility to see additional information about a
user with a card that appears when hovering avatar user fields for a
set amount of time. This card contains the following information:
- Avatar
- Chat status
- Name
- Email
- Button to send message
and with HR installed:
- View profile Button
- Job position
- Department
- Phone number
- Advanced chat status (when hr_holidays is installed)
Task-3167110
closesodoo/odoo#121943
Related: odoo/enterprise#44563
Signed-off-by: Mathieu Duckerts-Antoine (dam) <dam@odoo.com>
The DataManager is no longer used as all views and models have
been converted to wowl.
Part of task~3439226
closesodoo/odoo#129725
Related: odoo/enterprise#44611
Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>
Steps to reproduce
==================
- Enable debug mode
- Go to Settings / Technical / Automation / Automated Actions
- Set "Action To Do" to "Execute Python Code"
- In the code editor, type really quickly
The code is briefly focused and when the next input is processed,
everything is erased.
Cause of the issue
==================
The AceField makes a debounced commit with the current editor value.
This triggers an onChange event, and upon receiving the results,
we update the editor value with the resolved value.
Although the editor value may have changed in the meantime,
we still revert it to the previous value.
Solution
========
There is no need to update the record every 10ms. We can simply to that
on blur. This is also what was done in 16.2.
opw-3379740
closesodoo/odoo#129694
X-original-commit: 4047ed03117fbcd5634843e29dc82e7ffb71b910
Signed-off-by: Luca Vitali (luvi) <luvi@odoo.com>
Before this commit, in a kanban view grouped on a x2m, when we created
a new column, we had a crash.
Why did this happen?
When a column is created, a resequence is triggered on the columns in
order to have the correct position. Currently, we always use the
DynamicGroupList handle field, which is not correct because if we are
grouped on an x2m we use another resModel, so we want to use the default
handle field (sequence).
closesodoo/odoo#129510
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Before this commit, discard management was incorrect when you had a
non-editable x2m. This could result in changes not being completely undone.
How to reproduce:
- Go to a form view with an uneditable x2m
- Click on a record in the x2m
- Edit the record in the form view dialog
- Click on save
- Reopen the same record
- Click on discard
- Click on the discard in the main form view
- Reopen the same record
Before this commit:
The change applied is still present
After this commit:
The applied change is no longer there. The original state has been restored.
closesodoo/odoo#129509
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit removes a lot of legacy code that we kept for the few
legacy client actions that were still to be converted to owl. Now
that the last one has been converted, we can finally get rid of a
lot of legacy code (ActionAdapter, ActionMixin, ControlPanel,
ActionMenus, DropdownMenu(Item), Pager, DomainSelector...).
Part of task~3439226
closesodoo/odoo#129314
Related: odoo/enterprise#44465
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit adds a shortcut in the orm service to call the new
"web_read" python method and adapts the few calls to use it.
closesodoo/odoo#129502
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
With this commit, we ensure that the resId of a Record datapoint
never changes. The only exception is for new records: their resId
can go from `false` to their actual id when they are created. When
we want to load another record, we must use the `load` function of
the model, which now accepts `resId` (and `resIds`) as param, when
the root is a "mono record".
As a consequence, the instance of record datapoint now changes when
using the pager. This required some changes in the AceField, to
make it properly react in that case. We took the opportunity to
simplify its implementation (several keys in the state were useless).
Part of task~3179751
Part-of: odoo/odoo#114024
Now that the RelationalModel is based on unity, datapoints expect
to receive their data as returned by unity read (i.e. x2many values
are list of records, not ids, and many2one values are objects with
keys id and display_name, not tuple, or simple ids). As a
consequence, the Record component needed to be slightly adapted for
current usecases to continue working (e.g. using a Record component
for a Many2ManyTags field, and providing the value of the many2many
as a list of ids, like in the studio action editor sidebar).
This commit completes the relational values received by the Record
component with the related records, like if they were read by
unity.
The Record component's API will be reworked soon, now that the
new RelationalModel has been merged, to be more compliant with the
new unity concept.
Part of~3179751
Part-of: odoo/odoo#114024
Have a many2many field with widget many2many_checkboxes. Before
this commit, the widget notified the model (i.e. called replaceWith
on the static list) for each change of one of its checkboxes. This
means that if the was an onchange on the field, the onchange rpc
was done once for each click. With this commit, we debounce the
call to replaceWith, which allows to tick/untick multiple
checkboxes, and a single onchange is done with the resulting value.
This allows to mitigate another issue, which is that consecutive
calls to replaceWith are error prone, because they might send a
list of ids which isn't up to date with the one of the last call
to replaceWith (if the list is computed from the value in the
datapoint), as replaceWith uses the model mutex and thus updates
the datapoint in an async way. This specific issue will be tackled
later.
Part of~3179751
Part-of: odoo/odoo#114024
Have a field x2many without relation_field.
Before this commit, a server error was raised because, we send changes
for the non-existing field (relation_field).
Now, we only send to the server the changes for relation_field only if
they exist.
Note that, this commit will also add an exception on the server mock
onchange if we sent changes for non-existings fields.
Part of task~3179751
Part-of: odoo/odoo#114024
Have a view with many2many_checkboxes field (e.g. product.template
form view with inventory installed, and some routes). Tick a
checkbox. Before this commit, a read was done, but the field spec
was empty (there was no field to read). So basically the read only
returned the id. This is obviously useless. This commit prevents
from doing read rpcs when the spec is empty.
Part of task~3179751
Part-of: odoo/odoo#114024
Have a form view with an x2many field A displayed as a non editable
list view. In A's form view, there's an x2many field B, which isn't
in the list. B is itself displayed in the dialog form view as a
list, which contains an x2many fields C displayed as many2many_tags.
A contains a record. For this record, B contains also a record,
which contains two tags for C.
Have an onchange on the main record which triggers an update command
for the record in A, such that the command also updates the record
in B, which deletes (or forgets), i.e. commands 2 or 3, a tag C.
Before this commit, if the user opened the x2many record of A after
the onchange, it didn't displayed the remaining tag in C. The
reason is that we received commands to remove the tag before we
actually fetched them (as we don't need them for the list of A).
The tags were then fetched when we opened the record in a dialog,
but we didn't correctly merge the values read from the server with
the commands we received earlier.
With this commit, we properly store the commands and apply them
after reading the values.
Part of task~3179751
Part-of: odoo/odoo#114024
Have an x2many list or kanban with several page, and an onchange
on the main record that returns forget or delete commands for
x2many records that aren't on the first page. Before this commit,
it crashed, because the code expected the records to be in
this.records (the record of the current page).
Part of task~3179751
Part-of: odoo/odoo#114024
With the image field widget, the image is reloaded each time the record
is updated (when `write_date` is updated). This is not always desirable
as some images are not supposed to change.
This commit adds an option to bypass the image reloading. This option
is called `no_reload` and is set to `false` by default.
Part-of: odoo/odoo#114024
- On an one2many;
- drag and drop two records;
- a resequence is called, with an onchange;
- click save;
Before this commit, if the network was a little too slow, the return of
the onchange wasn't taken it into account for the save.
Now, we await the onchange of the resequence before executing another
action.
Task 3179751
Part-of: odoo/odoo#114024
Before this commit, going into a view with a record that had no properties displayed a crash.
Why ?
If no properties exist, the value is false and was not handled.
Part-of: odoo/odoo#114024
Before this commit, there was a hook, named useModel, which eases
the use of a model in views. The main (and almost only) role of the
hook was to deal with sample data (determine whether or not they
can be enabled, fallback on the sample orm when necessary, leave
sample mode at reload...). This hook is used by all views except
form and activity as they do not implement sample data.
This commit renames that hook into "useModelWithSampleData" and
introduces a new hook "useModel", which is a lot simpler that the
other one, as it's only goal is to do the plumbing between the
component using the hook and the model (i.e. spawning required
services and loading the data on willStart and willUpdateProps).
This new hook is used in form and activity views.
Note that useModel doesn't trigger deep renderings, as it is only
used on the RelationalModel which is based on fine-grained
reactivity.
Part-of: odoo/odoo#114024
...when using the pager.
When a record is dirty and the user clicks on the pager to go to
the next/previous one, it is automatically saved. Before this
commit, the record was reloaded after the save, which is useless
as we're leaving it anyway. This commit ensures we only save, and
we do not reload.
Part-of: odoo/odoo#114024
Before this commit, the x2m present in a record's evalContext was
represented by the resIds defined in the config. It therefore did not
contain the current changes. It should therefore be represented by the
currentIds of non-virtual records.
How to reproduce:
- Create a new record with a m2m field having at least one default record
- Edit a field which triggers an onchange with a context depending on the
value of the m2m
Before this commit:
The domain and context used contain an empty list for the m2m.
After this commit:
The domain and context used contain a list with the default id for the m2m
Part-of: odoo/odoo#114024
In form views, the "display_name" field is automatically added to
the list of activeFields as we need its value to display in the
breadcrumbs. However, this isn't necessary when there's no control
panel, in particular in dialogs. Without this commit, the test
"test_addremove" of addon test_apikeys didn't pass.
Part of task~3179751
Part-of: odoo/odoo#114024
Be on an existing record containing an x2many field. Add a row
or click on an existing one to edit it. The changes sent for
onchange done for the subrecord contains a key with the changes
in the parent record. Before this commit, this object didn't
contain the id of the parent record. As a consequence, the
onchange (in py) couldn't correctly link the sub record with
its parent to compute field values. This commit ensures that we
always provide at least the id when the parent record exists.
Part of task~3179751
Part-of: odoo/odoo#114024
Before this commit, when a field of type one2many or many2many, was
added and afterward deleted, on the onchange or write call to the server
the field wasn't added as a change (because the add and delete command
cancel each other). This can cause issues because when adding the x2many
field, the onchange on the server can have side effects that we want to
remove when deleting the x2many.
Now, we follow the following rule : If a field has been modified, its
value must always be sent to the server for onchange and write.
This commit also avoid to call update on the parent record if the chil
record didn't have changes.
Task 3179751
Part-of: odoo/odoo#114024
Before this commit, the save button in the x2m form view dialog does
not wait for ongoing updates.
Why is this?
When you click on the "Save and Close" button of a form view dialog
in an x2m, you check the validity of the record to know whether you
should save or not. The askChanges function called does not wait for
ongoing updates.
Solution:
Just wait until the model mutex has finished processing all the current
functions. This ensures that the record has applied all its updates.
How to reproduce:
- Go to a form view with a non-editable x2m
- Add a line
- Edit a required field with a slow onchange
- Click "Save and close" before the onchange is complete
Before this commit:
The form dialog remains open and a notification appears telling us that
a required field is invalid.
After this commit:
The dialog is closed and the change has been applied.
Part-of: odoo/odoo#114024
Before this commit, it crashed if an x2many field inside another
x2many field had a context with a key referencing the parent
record:
```xml
<form>
<field name="foo"/>
<field name="outer_x2many">
<tree></tree>
<form>
<field name="inner_x2many" context="{'key': parent.foo}">
<tree></tree>
</field>
</form>
</field>
</form>
```
The crash occured because we tried to evaluate the context of the
static list representing inner_x2many before setting the parent
key on the eval context.
Part of task~3179751
Part-of: odoo/odoo#114024
Have a required many2manytags field and a slow network. The field
is initially empty. Add a tag to the relation and directly save.
An invalid field notification is displayed, because the field is
still considered empty. This commit ensures that we wait for the
operations done in the static list before saving.
Part of task~3179751
Part-of: odoo/odoo#114024
For char/text fields, the server can return false or "" (empty
string) depending if the field isn't set in db (NULL) or set to
the empty string. This makes no difference in the UI, but it
matters when evaluating modifiers.
Before this commit, the value of char/text fields was automatically
set to the empty string if it was falsy, as it doesn't impact the
UI, and it is cleaner type-wise. Unfortunately, we cannot do that
for the eval context, as we must be able to make the difference
between False and "" evaluating modifiers. A solution would have
been to stop fallbacking on the empty string when the value was
false, but we wanted to keep the clean API. So this commit fixes
the issue by keeping an internal structure in Record to track
the exact values we received from the server for those fields, and
use that structure to generate the eval context.
Part of task~3179751
Part-of: odoo/odoo#114024
Have an x2many field displayed with a kanban view containing sub
fields with widgets (widget="..."). Click on a record to edit it
in a form view dialog. Before this commit, the fields of the kanban
card displayed in the background were switched to "edit" when the
dialog was open. With this commit, we ensure they always remain
displayed in "readonly".
Part-of: odoo/odoo#114024
From a list or kanban view, open a form view with a statusbar
field (e.g. in crm.lead). Go back to the list. Open another record
for which the domain of the statusbar is different. Before this
commit, it crashed, because the component bound to the orm service
used by the specialData cache (i.e. the previous FormController)
is destroyed.
Part-of: odoo/odoo#114024
Have an x2many with an x2many editable list inside the form view
containing at least a row. Open a record, click discard. Open it
again, and click on a row of the x2many to switch it to edit mode.
Before this commit, the row could never be switched back to
readonly. This was the list renderer didn't correctly compute its
active element (it must wait for a micro tick for the mounted hook
of the dialog, its ancestor, to be called).
After fixing this issue, a second one arise: the row can now be
unselected, but it disappears if it is a new record. This is
because we lost the dirty flag when clicking on discard. This is
fixed by storing the dirty state alongside changes in the
savepoint.
Part-of: odoo/odoo#114024
Before this commit, x2m in list mode with several pages did not work
correctly when sorted. The order was lost when the page was changed and
any values not used for sorting were missing.
How to reproduce:
- Go to a form view with an x2m in list mode with at least 2 pages
- Sort on a column
- At least one record not present before sorting is displayed
Before this commit:
This record only contains the values used for sorting
After this commit:
This record contains all the values
- Click on next page
Before this commit:
The records displayed on the page are not ordered and contain only
the values used for sorting.
After this commit:
The records displayed are the correct ones for the sort and contain
all the values.
Part-of: odoo/odoo#114024
Before this commit, go to a form view with an x2m displayed in list mode.
If you sort the x2m on two differents fields, a crash is displayed.
How to reproduce:
- Go to a form view with an x2m in list mode with at least 2 columns sortable.
- Click on a column to order
- Click on a second column to order
Before this commit:
We have a crash
After this commit:
The list is ordered correctly
Part-of: odoo/odoo#114024