Issue
If month - 1 or month - 2 are in the previous year, the filter is
incorrect.
ex: Date = Jan. 2020, Filter = Dec. 2019
=> last_year__last_month = 2018-12 instead 2019-12
Cause
If date is 2020-01-20
Selecting December => adding param "last_month"
Selecting 2019 => adding param "last_year"
Applying "last_month" => date become 2019-12-01
Applying "last_year" => date become 2018-12-01
Solution
Detect the right year to activate by default
when a month is selected and no year is selected.
With that solution it is not possible to get records in Jan. 2020
or in Dec. 2019 only for instance but the global functioning
of date filters stays the same as before.
OPW-2169528
closesodoo/odoo#44208
X-original-commit: 096fdc7d3fe0799aa761c6ad3597569a002c698e
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Co-authored-by: Jason Van Malder <jvm@odoo.com>
This commit's intention is to bring class inheritance of event handlers
to components.
Use case:
A component class may want to set generic event handlers for all classes
inheriting from it, in order to set shared event behavior from the start
It is the case in many parts of Odoo, in particular in the cases of fields
which need at least to react on some keyboard event for navigation
The way to implement such a behavior is to make use of the
`useListener` OWL hook, by passing as arguments
event name and the handler function
Before this commit, when typing something in the search view in
Japanese, and then clicking on a suggestion from the IME dropdown
menu, the search view menu did not update with selection.
Steps to reproduce:
- Enable Japanese IME in hiragana mode;
- Type "test" in search view;
- Soft-select another suggestion item, e.g. "テスト";
- Double-click on suggestion item "test";
=> The search view menu still detects "テスト".
As a result, clicking on any of these search view suggested filters
picks "テスト" instead of "test".
This commit fixes the issue by updating search menu when clicking
in a suggestion in the IME menu.
opw-2061590
closesodoo/odoo#44318
X-original-commit: 0bca4c0883f2b58842da6a8c1a4e26bf2444d5f3
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
With this commit, the url widget automatically prefixes the href
url by http:// if no protocol is specified, so that clicking on
the url will by default redirect to an external website.
To prevent this behavior, one can still specify the new option
'website_path: true' on the url field node in the view arch.
Thanks to this, we can remove a similar logic (only implemented on
res_partner model) which automatically altered the value saved in
database to force its 'http://' prefix.
task-2153184
closesodoo/odoo#42118
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
* remove misleading documentation about a "test failed" message, in
13.0 any uncaught exception or console.error will cause the current
test to be interpreted as failed
* fix tour manager to console.error its step and not add a second
useless error message
* fix menu tester to try and display the failure cause on failure
* improve qunit's test reporter to print the number of tests failed in
case of test suite failure
Should make test failures in tours a bit clearer.
closesodoo/odoo#44296
X-original-commit: 78121b68d099b16f2d775a7a8a963a2a0f474843
Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
In a list view, select some records (either by selecting them one
by one, or by clicking on the header to select all records), then
click on an action (except for the special case of 'Export') in the
sidebar. Some information about the selection is put into the
context:
- active_ids: the ids of the selected records (only those of the
current page)
- active_domain: the current domain
However, before this commit, there were no way to determine whether
the user checked the header checkbox (i.e. all records), or some of
them individually.
This commit adds the information, with a 'select_all' key in the
context.
Note that this is a quick solution, as we need it right now for an
accounting usecase. A more elaborate solution, which will allow the
user to choose whether he wants to apply the action on the selected
ids or on the whole domain, will be developped soon.
Part of Task 2146469
closesodoo/odoo#44248
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
In this commit, we add a new attribute "Delete" for user conveniency
if he don't want 'Delete' button on popover card they easily achive
by "delete=false" attribute and also add a testcase for it.
task-id:2088954
Before this commit, the CSS rule handling the "activity" of the modals
(their z-index compared to the one of their backdrop) was global and would
interfere with front-end or custom modals which do not use the static Dialog
methods giving them the "active" class.
Now, the rule has been inverted: the z-index of a modal is only changed when
it is given an "inactive" class, thus only impacting the modals instantiated
via Dialog or Owl Dialog classes.
closesodoo/odoo#44067
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
When the value is empty in a related field, string of the element was
displaying "false" instead of an empty string which is not what we expect.
This commit fixes that issue.
Task ID 2119333
PR #40949
before this commit: if only one measure is enabled then measure row not
displayed in downloaded xlsx file
after this commit: downloaded xlsx file will always have measure row
either single measure enabled or multiple measure enabled
task-2127388
closesodoo/odoo#40769
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
before this commit: file was downloaded in xls format, which supports
maximum 256 columns and 65536 rows.
after this commit: pivot returns xlsx file when table printed and
downloaded, we have support of xlsxwriter, xlsx file supports 16384
columns and 1048576 rows
task-2127388
In order to prepare the future, we want to convert everything in Owl.
This commit converts the activity renderer.
closesodoo/odoo#42278
Task: 2149408
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Now in a calendar view, if we use the color, attribute, it will use
the same color as Gantt views and the color picker widget.
The attribute color isn't more set as default in filter because it make,
in most situation, no sense to filter by color.
Now, we can add new filters in the right panel. To do that, we must
add the attribute "filter='1'" in the corresponding field line.
And if the filter has no direct link with the color of the model,
we can specify an attribute 'color' for this filter line block.
(for example color='color', and the color of the related model
will be used)
TaskID: 2153249
Task 2123526
Before this task, the phone widget on char fields was not
displaying the send sms button by default
After this task, the default behavior of the phone
widget is to display the send sms button
In Owl, 'render' is a (async) function of Component. It should not
be overriden in Component specifications, especially to do
something else (in this case, rendering the sub widget), without
calling super.
closesodoo/odoo#43980
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
By default, in readonly, unset field widgets (and their labels) are
not displayed. However, we would like the statusbar widget to be
always displayed (even when it is not set).
This commit introduces a new method 'isEmpty' on AbstractField, and
uses it (instead of isSet) to determine whether or not a field should
be hidden. By default, it uses isSet, so that it doesn't change
anything for the other fields, and we override it in statusbar to
always return false.
There was a need to make the distinction with isSet, as this one is
used to determine if a record can be saved (if the field is required,
and isSet returns false, it can't be).
task-2172272
closesodoo/odoo#43419
Related: odoo/enterprise#7929
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Aaron Bohy <aab@odoo.com>
With this commit, the start time of single day events is displayed
in the calendar view, in month mode. This only applies to non allday
events. This can be disabled by setting (already existing) option
'hide_time' to true on the calendar arch.
task-2058477
Co-authored-by: Mohammed Shekha <msh@odoo.com>
Before this commit, if the records had to be sorted according a
many2one field, and there was a sequence field on the many2one
comodel, the sequence was ignored. Now, the sequence is taken into
account like the actual server does.
Linked to odoo/enterprise/pull/7407
closesodoo/odoo#43763
X-original-commit: 714e52f98eec5c64a224523cee4b1e14463ed191
Related: odoo/enterprise#7869
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
After this commit, x2many fields can have options like
create/delete which accept a domain, to make create/delete on
x2many conditional, say for example x2many field can have options
like:
options="{'create:' [('foo', '=', True)]', 'delete:' [('foo', '=', True)]'}"
With this when foo field is True, Create and Delete actions will
be available, but if foo is False then they won't.
In case of one2many fields, if 'create' is false, then 'Add a line'
(list) or 'Add' button (kanban) won't be displayed.
In case of many2many fields, 'Add a line' or 'Add' button will
always be displayed even if 'create' condition is false as it
doesn't really create records (but rather links existing ones).
Same applies for delete.
Task-2092953
closesodoo/odoo#42919
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Parth Chokshi <pch@odoo.com>
Co-authored-by: Aaron Bohy<aab@odoo.com>
*sale,sale_product_configurator
Let's assume a form view containing a many2one with an onchange
that updates the value of a one2many. Do a quick create in the
many2one. While the name_create request is pending, add a row to
the one2many but do not leave it. When the name_create returns, and
the onchange has been performed, the one2many is reset, and the row
is no longer in edition (worse, it could be invalid, i.e. in a state
that the user could not have reached in a normal situation).
This commit fixes this issue by considering the whole [name_create +
onchange] operation as one. This operation is executed in the mutex
of the model, so the other request (adding a row to the one2many) is
delayed until the many2one value has been correctly set.
This fixes an issue with the sale and rental tours (on sale_order),
that had been deactivated for a while.
This commit changes ControllerAdapter to a mixin that inherits
WidgetAdapterMixin and RendererWrapper now extends ComponentWrapper.
This commit also changes PivotController base class/mixin and uses
the Odoo legacy custom_events because of the adapter.
closesodoo/odoo#43256
Related: odoo/enterprise#7744
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
This commit adds the ComponentAdapter, an Owl component meant to
be used as universal adapter for Owl components that embed Odoo
legacy widgets.
This component will be a precious tool during the transition phase
of converting our JS codebase from the legacy (widget) framework to
Owl.
1/ When the new database is created without demo data, the admin has a
'silhouette' as a default picture. When a new user is created without
picture given by the current user, the new user will have a 'silhouette'
as a default profile picture.
2/ web: image for fa-user-slash. This image will be used when a record is
unassigned.
3/ web, *: Change placeholder by default when record is unassigned.
We want to have a fa-user-slash icon when a record is unassigned instead
of 'placeholder.png'. A method is created in the BaseModel to have a
generic method to change easily the placeholder for other models.
4/ Adapt kanban test to keep the same behaviour. Attention the behaviour is
a bit different. Because, now the default image is given by the server to
change easily the default image when a record doesn't have an image.
Thus, we don't say if it's the default placeholder, but we can say it's
not the same image of the record (in this test, the record, it's the
partner).
5/ misc: display 'Unassigned' in the hover on kanban cards if record is unassigned
closesodoo/odoo#41356
Taskid: 2060206
Related: odoo/enterprise#7758
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Co-authored-by: jdoutreloux <jud@odoo.com>
Co-authored-by: Yannick Tivisse <yti@odoo.com>
If we have a many2many_tags widget that is writable then becomes
readonly, we can have in the code this chain of event:
- get list of widgets we need to reset some data for
- apply modifiers
- reset the widgets
but applying modifiers can delete a widget (eg. an editable field that
becomes readonly), so when resetting we could call code on a deleted
widget which caused an error.
For example, if we have an attribute:
`<field widget="many2many_tags" attrs="{'readonly': 'condition'}"/>`
if the field goes from editable to readonly and is affected by an
onchange, we will call `setIDForLabel` on the deleted instance of the
widget which will cause an error.
Added test without fix fails with error:
TypeError: Cannot read property 'attr' of undefined
at Class.setIDForLabel (/web/static/src/js/fields/abstract_field.js:324:35)
because as said, the function is called on the editable widget that is
removed and replaced with readonly widget at that point.
opw-2154471
closes#43137closesodoo/odoo#43244
X-original-commit: 6f5ca16524be7c5bb45b03e7421154a20edc4cf6
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
d06e67e748 introduces tools to use owl renderer
for a view. However, on_attach_callback and on_detach_callback were not
called on super (AbstractController), so not applied to the controlPanel
and searchPanel.
This commit fixes this issue
Task-ID 2171436
closesodoo/odoo#43165
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
d06e67e748 introduces tools to use owl
renderer in a view. However, this owl renderer is never destroyed.
This commit fixes this issue.
Task-ID 2171436
Before this commit: all dialogs would go through the static method (OwlDialog.hide)
when destroyed, regardless of wether they had been opened or not.
Now, only dialogs having an 'el' property set (= having been opened) will use
the 'hide' method.
Task 2170705
closesodoo/odoo#43124
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
Revision on https://github.com/odoo/odoo/commit/141b34f152f36d970d4ff78abe53f563555a8e69
Having async/await as a new promise constructor is an antipattern.
The reason is that it may lead to unnoticed errors: if an inner
promise is rejected, it won't propagate the error to another promise
that will handle the error. As a result, this error becomes unnoticed
and the initial promise is pending indefinitely, which also may lead
to more bugs [1].
[1] https://stackoverflow.com/a/25569299Closes#43072
When accessing stock_barcode module to validate pickings, is not
possible to add floating point quantities for any localizaton which uses
',' as decimal separator.
The numeric field is now defined via browser tags <input="numeric"> to
make the numeric keyboard popup automatically on mobile devices
(commit 8f5840369b28962ab2be9edfce7331a836c3df22)
Adding the override to avoid further processing when the input
is already anumber
opw-2154657
closesodoo/odoo#42748
X-original-commit: 1ccc60deeb067f8d461d48cbf51719317c22cb90
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
New component: the custom file input. Its purpose is to define a input of type file
with a custom trigger (button, link, etc.).
Its construction is the following:
- attributes: behaviour of the actual input (route to call, multifile, allowed
extensions etc.)
- inner template: the trigger that will fire the upload prompt when clicked
Once a file has been uploaded, the component will emit a 'uploaded' custom event
containing the files.
closesodoo/odoo#38423
Related: odoo/enterprise#6031
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
New Owl component: Dialog. It does not rely on Bootstrap but behaves the same
and does not conflict with legacy dialogs.
To call this component, you need to define it in the XML parent template instead
of calling it in the JS file, and put a flag in the parent state to toggle the dialog.
Old dialog file has also been slightly updated to ensure compatibility between both
versions.
This commit also updates a list view test which did not wait for click events to
properly trigger and would cause the new dialog system to crash.
Let's assume a many2many_checkboxes widget in a form view with a
dynamic domain (depending on another field in the view). At first
rendering, the widget contains a checkbox for each value matching
the domain.
Before this rev., if the user changed the value of the field used
in the domain, the many2many_checkboxes wasn't redrawn, so it still
displayed the values matching the previous version of the domain.
Closes#38509Closes#40173closesodoo/odoo#42867
X-original-commit: 1ace56f9a8cb56fb39235468dd13447bcbbee40a
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Aaron Bohy <aab@odoo.com>
Before this commit, pointer events were prevented on all checkboxes in readonly
list views. That meant that the boolean_toggle widget for instance could not be
properly toggled in a non-editable list (which was the purpose of such a widget).
Now, pointer events are enabled only if the checkbox :
- is in a selected row AND does not have a readonly modifier
OR
- has a widget applied on the field.
Also ensured that the field widgets in the list view multi edition confirmation
modal are not interactive.
We cannot test the `pointer-events` property interactions as it does not affect
manual event triggering used in tests.
Task 2154055
closesodoo/odoo#42848
X-original-commit: c7ee164d572e01fcb565001fd5e62fe1278b5cd8
Signed-off-by: Julien Mougenot (JUM) <Arcasias@users.noreply.github.com>
Before this commit, negative numbers are never rendered as human readable (e.g. 34000 -> 34k).
closesodoo/odoo#42789
Taskid: 2160790
X-original-commit: b51877c4c4c9d8cd873dd0205954fd807d62ee01
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Previously it was always possible to create within the calendar view.
For some modules this did not make sense and lead to confusing behavior,
for example: a new model instance created in the calendar view that was
not viewable in the calendar view, but was viewable in other views. By
adding a 'create' attribute (to be used in view xml), we allow users to
choose whether or not they want a calendar view to be able to create.
Note that this change does not affect the edit ability of calendar views
for existing instances.
Part of
Task: 2126530
Before this change, fields.Reference displayed into the popover of
a calendar view was always empty. This was because the popover view
generated from a double click on an element in the calendar view
creates its own recordModel in JS and the function to create this
record did not handle the reference field case.
This commit detects if a reference field is defined into the record
and adds the necessary processing to process its value and creates
the corresponding dataPoint.
opw 2151635
Closes#41262closesodoo/odoo#42707
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
Co-authored-by: Aaron Bohy <aab@odoo.com>
While x_name has long been automatically supported as an equivalent
of name, x_active was not.
This commit adds this behaviour OoB, both in the ORM and the web client.
On the ORM-side, a new `_active_name` attribute is supported on models.
This attribute specifies the field that should behave as an active marker
for records of the model. It is supported the same way `active` has been
until now (filtering by the `active_test` context key and toggled by the
`action_archive`, `action_unarchive` and `toggle_active` methods).
Although no check has been added on the field's type, it is assumed to
be a boolean field (the same way no check is present on the `(x_)name`
field).
On the client-side, the list view and form view now both support
detecting the presence of either `active` or `x_active` on records,
automatically adding an '(Un)Archive' button in the Action menu if such
a field is detected.
Note that the ORM implementation does actually need the field to be named
in any specific way, but since the web client has no mechanism to load
information regarding a model (the lifecycle of an action loading
includes loading the action, view and record(s) but no generic
information about the model itself besides what is included in the
views), we restrict the field's name to `(x_)active` to avoid confusion
as any other name would work at the ORM-level but not in the client.
In the future, the client might be able to more elegantly get
information about models, but this was not the scope of this change and
this solution should cover most cases.
Note that the `active` field will always takes precedence over the
`x_active` field to avoid confusing the polarity, even if both fields
are present on the model.
In the case of a custom field, it might be slightly annoying that the
default value of a Boolean field is `False`, which means that upon
adding the column, all existing records are automatically archived. This
can easily be worked around using an `ir.default` record for that
particular field and an update of existing records (e.g. through the
list view). The goal of this change was not to make it easy to add
support for custom active fields, but to make it possible - we have
therefore kept this implementation which introduces few changes while
adding enough flexibility for developers.
See https://twitter.com/zubair_shafiq/status/1202587553871880192?s=20
for more info regarding supporting any `_active_name` in the web client.
Co-authored-by: Raphael Collet <rco@odoo.com>
Revision on [1].
Commit above made changes to test helper `nextTick()`, so that it
waits for `window.nextAnimationFrame()` (shorten, 'rAF'). This was
useful to wait for OWL rendering, since OWL renders on next animation
frame.
From a theoretical standpoint, the helper should wait at least as
much time as before, as it adds either no slowdown (rAF is readily
available), or a few milliseconds wait (rAF waits for next available
animation frame).
However, some old tests show non-deterministic behaviours, resulting
to crashes [2]. It suggested, for some reasons, that `nextTick()` did
not wait long enough for re-render... Which is surprising considering
explanation above!
Some of these tests have been fixed, assuming it was caused by un-
guaranteed order of successive `setTimeout(0)` [3]. Unfortunately,
this does not explain why it never crashed before the change on
`nextTick()`...
After investigation, we think that this behaviour comes from rAFs
having their own task queue, which no longer guarantees that queued
tasks happen after queued micro-tasks:
When the requested next animation frame is readily available, the
callback of `requestAnimationFrame()` is immediately called and waits
for `setTimeout(0)`. The `setTimeout(0)` await is resolved before any
other queued async micro-tasks, so that `nextTick()` is resolved
sooner than expected. This would explain how `nextTick()` does not
wait long enough for rendering from the loads of resolved Promises,
even though there is a promise resolution after `setTimeout(0)`.
This commit fixes the issue by moving the await `setTimeout(0)`
before the rAF call, so that it correctly waits render from chain of
resolved promises (since the `setTimeout(0)` is awaited in the same
main task queue).
[1] https://github.com/odoo/odoo/commit/b0941d19a07b08fabc64a284b58e57edc46203dd
[2] http://runbot.odoo.com/runbot/build/771505 and http://runbot.odoo.com/runbot/build/752855
[3] https://github.com/odoo/odoo/commit/6cbfdbce2d0f1b567b6a6d6f637fe2a476980accclosesodoo/odoo#42123
Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
The attribute "groups" on filters and fields in a search view arch was not taken
into account anymore.
Now items that should be invisible are not anymore available for selection
in the interface (as expected) but are still activable as search defaults
(and the corresponding facets appear if needed).
Task ID: 2081450
closesodoo/odoo#42125
X-original-commit: ca2514a9fbcd693752367cb566d5c11165b40bd4
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
This commit introcudes two changes to the multi edition in list views:
1. Editing one record does not require confirmation through a dialog
2. Successfully saving multiple records unselects all currently checked records
Task 2146429closesodoo/odoo#41099
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Prior to this commit, there was no clean way to have a button
triggering asynchronous work (like asking user for confirmaton
for example) and close or not close the modal according to the
user choice. Your options were:
1. Swallow the pill and just accept that the modal will close
even if the user chose not to undertake the action.
2. Set the `close` parameter of the button to false and handle
the conditional closing by yourself from outside the dialog.
This commit introduces a way to tell the form view dialog that
the action has not been processed correctly and that the modal
should not be closed by returning a rejected promise. Prior
behavior can still be obtained (close no matter the result)
by having the handler not returning a promise at all.
closesodoo/odoo#33837
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>