Commit Graph
580 Commits
Author SHA1 Message Date
Sébastien Theys c73efc27b7 [FIX] web: stabilize sequence for new records on last page
Before this commit, the compute sequence was relying on the fact the ID was used
as a secondary order key to get the right result.

This is necessary when adding items between pages because we don't resequence
the following elements.

However this was not necessary when adding new elements on the last page since
there are no following elements to resesquence in that case.

PR: #27639
2018-10-12 14:29:51 +00:00
Lucas Perais (lpe) cba5f7a98f [FIX] web: fetch dependency fields in x2many
Image field widget need the __last_update field alongside them
for caching purposes, though that field should never be present explicitly
in the views

Before this commit, the dependencies of field widgets were not merged into
the model's fields definition, creating a traceback when adding an image field widget
into a x2many list

After this commit, there is no traceback and the image field works properly

closes #27545
2018-10-09 14:16:56 +02:00
Sébastien Theys 57ae9428b4 [FIX] web: prevent URL click from opening a record
If we click on a link, we only want to open the URL,
and not the record when the button is on a list.

PR: #27230
2018-10-12 12:45:38 +00:00
8445baa08d [FIX]web: do not crash when dismissing a modal with escape
stopPropagation of navigation_move event for where direction=cancel,
currently if navigation_move event throws error when user press escape
in dialog where dialog is opened from editable list record

Scenario: Install website_sale -> Open Product form(variant enable) ->
open variant tab -> open Attribute m2o form popup and press Escape on dialog
Result: Error
Expected: It should close dialog and keep editable list view record open,
btw m2o field should also be focused when dialog is closed but that's
another issue, will be fixed in another ongoing task

Related to Issue: #1873919

Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
Co-authored-by: Mohammed Shekha <msh@odoo.com>
2018-10-09 09:46:39 +02:00
Lucas Perais (lpe) 889bdd3569 [FIX] web: fielddate[time] should select their value when entering them
Before this commit, when focusing on a date[time] field, the value was not selected
In v11.0, it was

This is due mostly because of the migration to BootStrap 4

After this commit, the value inside the input is selected

OPW 1911333

closes odoo/odoo#28989
2018-11-26 14:51:09 +00:00
Martin Trigaux 0aa0cec97a [FIX] web: do not warn on empty field
If no value is specified on the datefield, do not set a warnfuture message

Remove code comment that was referring the condition present at b51b0d66c2
but no longer present.

Add tests

Fixes #27551

closes odoo/odoo#27593
2018-10-10 13:59:36 +00:00
svs-odoo 078b31dc7f [FIX] web: Make datetimepicker configurable in datetime fields
The datetimepicker option was introduced to be able to customize the
datetime picker widget in date/datetime fields. However, due to the way
the _makeDatePicker function was coded, it did not work in datetime
fields.

Thank to Yajo for the initial fix

closes odoo/odoo#27541
2018-10-09 12:34:23 +00:00
Xavier Morel a47f6093f8 [ADD] auth_password_policy{_signup}: password strength widgets
* generic strenght meter widget which can be included in various
  places
* password field, taking over the isPassword special cases strewn
  throughout the codebase, this should probably become an actual thing
  in core /cc @ged-odoo, the meter is opt-in as most uses of
  `field[@password=True]` are passwords & secrets for third-party
  services or external servers for which a meter would not make sense
* separate override of the ChangePassword wizard which isn't a regular
  view for some reason
* direct implementation for signup pages (create user & reset password)

Skip/comment/remove existing testing of @password fields: the policy
replacement/augmentation needs to make an RPC call and does not
support readonly use (because it doesn't seem to be used anywhere so
that made sense?); and there currently is no way to augment or
override/replace existing tests, so the tests will either fail when
auth_password_policy is installed (current situation) or fail when
auth_password_policy is not installed (if updated to be compatible
with APP).
2018-10-02 20:54:00 +02:00
Mathieu Duckerts-Antoine 3c093a8108 [FIX] web: human numbers and percentages
A recent modification of the float and integer
formatters allowing the rendering to be human readable
causes a bug in the percentage formatter for large values.
The reason is that the latter formatter uses formatFloat (wich can
now produce 'numbers' like 3k) and then parse the result. In the case
of 3k an error is raised since 3k is not recognized as a true number.

This fixes avoid to parse the number in case it has been formatted
to be 'readable'. Note that the parsing was essentially used
to produces better percentages like 10% instead of 10.00%.
This is not necessary in our case since utils.human_number takes care
of the unwanted (not all) decimals for us (the original number is always
rounded by utils.human_number).
2018-09-27 11:58:39 +02:00
Vincent Schippefilt c2b4790be4 [FIX] web: fix date picker fields do not capture the focus event when invisible
Before this fix, in form view, when a datepicker was not visible (because
they were on another page or literally invisible), when the user pressed
TAB and the datepicker was positionned after the current field in the
form, it was capturing the focus during the activate phase of the
navigation_move.
This is not correct for invisible elements.

After this fix, only focusable datepickers get the focus during the
activation phase of the navigation_move.

co-author: aab-odoo (aab@odoo.com)
2018-09-26 11:43:38 +02:00
Vincent SchippefiltandAlexandre Kühn 1c3d7c00e0 [FIX] web: focus 1st control in editable list on ESC
Before this commit, when we click on the 1st control in
an editable list (usually 'Add an item') then press ESCAPE,
the focus was not on the 1st control.

The intended behaviour is to have the focus on the 1st control,
so that we may navigate left/right between controls solely with
the keyboard.

With this commit, when a cancel keyboard navigation event is
triggered in an editable list, it auto-sets the focus on the
first control.

Co-authored-by: Alexandre Kühn <aku@odoo.com>
2018-09-25 16:49:23 +02:00
Vincent SchippefiltandAlexandre Kühn 48a53f2ea5 [FIX] web: improve automatic creation of new lines in x2many in forms
This commit fixes a few issues with the previous implementation of the
automatic addition of new lines in x2many inside forms

1. Before this commit, when there is a change of mode in a formview
`edit` -> `readonly` -> `edit`, there may be some cases that
mistakenly and automatically opens a modal.

This case occurs in a form view with a x2many field whose 1st inner
focusable element opens a modal (e.g. "Add an item").

In `edit` mode:
	1. Open this modal from the x2many
	2. Close the modal
	3. Change mode to `readonly`
	4. Change mode to `edit`
> the same modal is automatically open.

This is due to the tracking of the last activated field that persists
after a change of mode. Since the last activated field in the 1st
`edit` is the x2many, it is granted the focus at the beginning of the
2nd `edit`, which automatically opens the modal.

This commit fixes the issue by resetting the tracking of the last
activated field when there is a change of mode. As a result, at the
beginning of the 2nd `edit`, the focus should always be on the 1st
field.

2. Before this commit, if the focus was moved out of the form (to a modal
for instance) then back, the form would re-activate the last field, which
is the x2many and would re-add a new line. This behavior is not correct
and now going back from a modal to a form does not add a new line.

Co-authored-by: Alexandre Kühn <aku@odoo.com>
2018-09-25 16:49:23 +02:00
Vincent Schippefilt e343f5f5f9 [IMP] web: x2many adds a new line by tabbing on a not dirty line
Before this change, when the focus was on the first field on a x2many
field, and the user pressed TAB, the line would be discarded and the
focus moved to the next field (at the level of the x2many) in the form.

This was an issue because if the first field was required, the focus
could not be moved out of the field with TAB so the user had to discard
the line manually (with ESC) before moving to the next field

This change works with 2 changes:
1. detecting if a line is dirty (has been modified by the user) and at
the end of the line, decide to either
    - discard the line and move the next field, if the line is not dirty
    - commit the line and add a new line, if the line is dirty

2. allow users to use TAB through required field inside x2many so they
can easilly go to the end of the line.

Task id : 1872248
2018-09-25 16:49:22 +02:00
Christophe Simonis a12c4d284c [MERGE] forward port branch saas-11.4 up to a1b384d66b 2018-09-18 11:42:52 +02:00
Christophe Simonis a1b384d66b [MERGE] forward port branch saas-11.3 up to 2de573440e 2018-09-17 19:40:47 +02:00
Christophe Simonis 0942a57b5a [MERGE] forward port branch 11.0 up to f2b8caff07 2018-09-17 18:03:41 +02:00
Aaron Bohy c63630d416 [FIX] web: datepicker: correctly use lib
The datepicker lib has been updated to tempus dominus (BS4)
recently, but our code hasn't been adapted correctly to the
requirements of the new version of the lib. As a consequence,
the datepicker didn't close itself when the input was focused
out anymore.

This required a slight change in the DomainSelector widget as it
produced a crash when a focused datepicker widget is removed from
the DOM (before the datepicker is destroyed), e.g. by a call to
html() on one of its parent.

Task 1878254
2018-09-17 15:23:33 +02:00
Aaron Bohy 8993d6ff79 [FIX] web: x2Many: remove deadlock situation
This rev. is similar to db9b91ff, but treats the x2many case.
Calls to the 'commitChange' function of renderers must not be done
inside a mutex, mainly since 241704536, as they could end up in a
deadlock. For x2manys, it was actually the case in practice in
Inventory > Operations > Inventory Adjustments > Create > select
'One product only' > select a product > try to edit the real
quantity in the editable list > focusout > deadlock.

The reason why the deadlock occurred in this view and not in, e.g.
sale.order, is due to the presence of the field_float_scannable
widget. Indeed, the barcode engine intercepts input events and
manually re-triggers them. As a consequence, the 'change' event is
not triggered on the field, and it does not notify the environment
of its new value by itself, until the field x2many asks it to
commit its value. Note that this might be an issue as well, as
onchanges are thus not triggered.

Task 1878254
2018-09-17 13:32:37 +02:00
Aaron Bohy 4393e48fec [FIX] web: navigate in editable list with custom controls
Rev. f241441 recently added the possibiliy to define custom
controls (instead of the single  'Add a line') in editable list
views. However, it didn't take into account keyboard navigation.

Suppose that the focus is on the field preceeding the list, and
the user clicks on TAB, the code assumed that there was only one
control, and focused it. However, when there were several control,
the last one was focused (which is typically the less common one),
and there was no way to navigate to the others.

This rev. focuses the first control by default, and allows to
navigate through controls with RIGHT and LEFT. Pressing TAB still
moves out of the list, to the next field.

Note that i'm not happy with this fix, as the logic doesn't seem
to be in the right place. Indeed, the notion of controls is the
concern of the editable list, not the x2many field, so the list
should handle this logic by itself. Unfortenately, this is not that
easy to change, as for now the list doesn't even know that we are
navigating to/from its control(s), until we click on it/them.
Changing that will be for later, in master.

We also did a linting pass on the concerned code.

Task 1878254
2018-09-17 13:32:37 +02:00
MOENS Alexandre b83db27135 [FIX] web: JournalDashboardGraph widget crash Mk.II
Hardening of commit:995610c065bf0242cb5023cfad2940234395739e

The JournalDashboardGraph requires nv, which is lazyloaded.
However it requires nvd3.js which is loaded after nv.d3.js.
A function called in destroy is defined by nv.d3.js,
which can make the crashhappen with the right (wrong) timing.

opw 1873749
2018-09-14 16:13:35 +02:00
Aaron Bohy 0ff2087fb9 [FIX] web: FieldMany2ManyTags: fix broken colorpicker
Before this rev., if the user clicked on a tag to open the color
picker, and then clicked in the dropdown, but not on a color, the
color picker closed itself, and it was no longer possible to open
it again.

This issue came with the migration to BS4 and its following fixes.
As the color picker is now a classical BS dropdown, it closes
itself automatically, so we don't need to manually close it on
focusout.

Task 1878254.
2018-09-11 21:05:23 +02:00
Christophe Simonis 68d36512ef [MERGE] forward port branch saas-11.4 up to d78f23df84 2018-09-07 20:20:45 +02:00
svs-odoo 74fcd3ac3b [IMP] web: FieldInteger and FieldFloat can use input of type number
This allow the browser/device to handle the experience of handling number in a more native way.

FieldInteger and FieldFloat now inherits from NumericField because we want
to format it or not dependent of the view (readonly or edit) and the
NumericField will manage it.

We do that because input type number can't take a value with comma on Chrome
(FireFox is more permissive but not perfect because comma is the separator
for decimal in this case).

Task #1880376
2018-09-07 16:18:45 +02:00
Christophe Simonis 49c3264ce0 [MERGE] forward port branch saas-11.3 up to 4850fb0838 2018-09-07 14:43:48 +02:00
Christophe Simonis 4850fb0838 [MERGE] forward port branch 11.0 up to 9b602ae648 2018-09-07 12:38:59 +02:00
Aaron Bohy a51a5b70d3 [FIX] web: FieldDomain: reset field with a new domain
Before this rev., there was a crash when a FieldDomain was reset
with a new domain (e.g. coming from an onchange). For instance, it
crashed in Email Marketing > create new Mass Mailing > select
mailing lists. Introduced by 68332a01.

opw-1882850
2018-09-07 08:37:45 +02:00
Christophe Simonis f19e6ce561 [MERGE] forward port branch 11.0 up to 213759b03e 2018-09-05 18:52:27 +02:00
len-odoo b95b4035e4 [FIX] web: tab selects first many2one entry without triggering spurious create
Suppose you select a customer for a sale order.
You type the beginning of his name "think", and a name_search is triggered
which finds matching results, with first result "Think Big Systems".
There are three ways to select it: click, enter or tab.
Now there can be a warning set on this customer
("Bad client, only accept cash", or "good client, offer discount").
In that case, clicking on tab would trigger the onchange displaying the warning,
but it would also set floating to true, which means a dialog to create client
"think" would appear.
This happens if the onchange is delayed, and thus the call to reset the floating
state is triggered only after the focusout completed, instead of before.

Coauthored with @aab-odoo

opw 1866619
opw 1874475
2018-09-03 12:09:56 +02:00
Aaron Bohy 68332a0177 [FIX] web: fix evaluation context of the domain selector
The domain was instantiated without being given any evaluation context.
As a result, the uid variable was not defined,
crashing the js if present in a user-defined filter.

opw 1866852
2018-08-30 14:55:06 +02:00
Sébastien Theys 1c59de867d [FIX] web: prevent handle from crashing with text field
289adeb63f introduced a bug where we tried to trigger an event on an element that didn't exist. Indeed there is no input if it's not in edit mode.

This commit fixes it.

PR: none
Task: none
2018-08-28 12:03:35 +02:00
Sébastien Theys a175c1d202 [FIX] web: o2m correctly left-align the first create button
When there is no handle field, there was an unnecessary margin-left. When there was a handle field, the margin-left wasn't the correct way to align it.

PR: #26566
Task: 1869469
2018-08-28 09:54:12 +02:00
qsm-odoo d578644756 [FIX] web, *: use correct DOM for m2m tags
* mail, calendar

- Fix traceback when clicking on a tag without color field (introduced
  in recent changes)
- Properly allow to delete tags on firefox (a button obviously cannot
  contain another button)

Closes https://github.com/odoo/odoo/pull/26547
Thanks to @hbh-odoo
2018-08-27 17:12:56 +02:00
qsm-odoo 9fc771dd5d [FIX] web: BS4, restore slider checkboxes
Take advantage of the new BS4 checkbox structure to simplify the
widget too.
2018-08-23 16:45:40 +02:00
XavierDo a4dfa6e354 [FIX] web, website: fix tests giving 404 error
-Some tests where moved without addapting the path to them:
path is now update and tests fixed.

-A picture was removed in commit 4dce6cc98b but
still referenced in template website_twitter_snippet.

-A test was missing a data leading to the wrong path to image beeing loaded
2018-08-22 14:41:02 +02:00
Sébastien Theys 416b810eb5 [FIX] web: prevent textarea vertical resize on chrome
Since we correctly compute the height of the field, we don't want to let the user resize it vertically.

This was already working on Firefox because it doesn't require the field to be in the DOM to read the resize attribute, but Chrome does require the field to already be in DOM.

Task: 1869469
PR: #26518
2018-08-22 14:10:06 +02:00
Sébastien Theys 14b9e9c92d [FIX] web: give correct size to o2m textarea at init
Before this commit, a textarea inside a one2many would only have the correct size after focus or on change.

When we select a line, we want all of the textarea of the line to have the correct size even if they are not directly focused.

Task: 1869469
PR: #26430
2018-08-22 11:51:30 +02:00
Sébastien Theys 289adeb63f [FIX] web: properly resize textarea when its value changes
Before this commit, a textarea would not resize when its value changed if the event was different than "input" or "focus".

This commit fixes it by also listening to the "change" event, and by triggering it at appropriate times.

PR: #26430
Task: 1869469
2018-08-22 11:51:30 +02:00
Sébastien Theys 4310b11df5 [FIX] web: compute the correct height for textarea autoresize
The box-sizing property was not correctly taken into account.

- content-box is the standard behavior: border and padding are added after the height
- border-box needs attention: border and padding must be included into the computed height

Task: 1869469
PR: #26430
2018-08-22 11:51:30 +02:00
Sébastien Theys 241704536d [FIX] web: allow o2m navigation to work from required inputs
In a one2many, pressing ENTER or TAB from a required input (of type text or char) that is on the last editable column of its line would fail to navigate to next line.

The issue was that the validation of the required field would happen before the change to its value was actually applied.

This commit fixes it.

PR: #26430
Task: 1869469
2018-08-22 11:51:30 +02:00
Vandan ShahandMohammed Shekha f4ee61f950 [IMP] web: mobile: add swipe support in form views
This rev. allows to navigate, in mobile, through records in form
views by swiping.

We also moved mobile-specific tests involving a form view to the
mobile test suite, since those tests became async because of the
lazy loading of the swipe lib (in the mobile suite, that lib is
already loaded).

Related to task #34727

Co-authored-by: Mohammed Shekha <msh@openerp.com>
2018-08-20 21:11:54 +02:00
Deep Patel 287501abbc [FIX] web: restore many2manytags colorpicker dropdown
Bug revealed with BS4.
2018-08-20 13:40:20 +02:00
Dharmraj JhalaandMohammed Shekha a105e5f208 [IMP] web,various: Add 'Remove' button to view dialogs opened from x2m fields
Currently, to remove link of x2m field from any record, sometimes there's no way.
For example, if we are on mobile and open any Quotation, it's linked quotation lines
are automatically converted in kanban, and there is no way to delete a line from
that quotation. However, in some of the manually designed kanban, there is special 'x'
for removing / unlinking x2m record, for example, Contacts of Partner.

This commit makes the behavior more consistent. During edition (mobile and desktop), if
a view dialog is opened on click of x2m field, it will have one 'Remove' button (based
on user rights) on right side of dialog footer, allowing users to delete / unlink the
record. Moreover, in mobile, the modal is opened fullscreen, with sticky header and
footer.

Related Task# : 31641
Closes PR #15857

Co-authored-by: Mohammed Shekha <msh@openerp.com>
2018-08-17 18:18:53 +02:00
Alexandre Kühn ccd94a1588 [REV] "[FIX] web:tests: do not rely on testUtils.patch in tests"
This reverts commit f1a0a32e46.

This utility function has been fixed with commit 1edea9326c
2018-08-17 16:21:39 +02:00
Simon Lejeune 3fa2ca0779 [FIX] web: no_open in field options no longer working
example: <field name="product_id" options="{'no_open': True}" readonly="1"/>

This has been broken by rev. 43d21dd9c due to misplaced parentheses
(an empty object in javascript being truthy).
2018-08-17 11:24:27 +02:00
Alexandre Kühn f1a0a32e46 [FIX] web:tests: do not rely on testUtils.patch in tests
Revision on https://github.com/odoo/odoo/commit/10f43955d81ff3e7b5ab050656b312ec19f927c5

Commit above uses `testUtils.patch` in the test.
However, this utility function does not seem to work.

That sucks...
2018-08-16 18:38:49 +02:00
Alexandre Kühn 10f43955d8 [FIX] web: render JournalDashboardGraph when in DOM
The lib 'nvd3' renders graph when they are attached to the
DOM. However, widgets are rendered in fragments and
appended to the DOM when ready (to prevent flickering).

Before this commit, we used a `setTimeout(0)` and cross
fingers that the widget was attached to the DOM when the
`render` method was called.

With this commit, the render method is called when it is
attached to the DOM.

Task-ID 1868252

Closes #26410
2018-08-16 16:52:56 +02:00
Dharmang Soni 4dfabb8f7a [IMP] web: FieldSelection: no empty value if required
From this rev., the empty value isn't available in the options of
required selection fields, thus preventing the user to unset it.

Related to task #49262
Closes #24404
2018-08-14 13:51:07 +02:00
Christophe Matthieu 61eef73b52 [IMP] base, *: use a many2one for the company report layout
Before this rev. one could set the report layout on the company using a
hardcoded list (background, clean, standard, etc.). Other modules (typically
accounting modules) could add options in this list. The used template was built
on the layout key.

Now, the layout is a many2one field to a newly created model `report.layout`,
which is linked to a view with the layout architecture.

This gives more control to customize reports and create a new layout (without
creating a python module that extend the layout selection).
2018-08-13 17:09:28 +02:00
jem-odoo 1f72644c44 [IMP] web: float_factor and float_toggle widgets
This commit provides new js widgets for list, kanban and form
views on float field.

1/ 'float_factor' displays the normal float field, but takes a
conversion factor as option. The displays value is the normal
one multiplied by the factor.

You can use the widget like
<field name="my_float_field" widget="float_factor"
option="{'factor': 2}"/>

2/ 'float_toggle' displays a button (in edit mode) looping on a
range of given value at each click. A conversion factor is optional
(default will be 1) to display a converted value, but sent to
non converted one to the server.

You can use the widget like
<field name="my_float" widget="float_toggle"
option="{'range': [0, 0.5, 1], 'factor': 2}"/>

'range' and 'factor' are put in the options.
In simple read mode, the widget display the value as a traditionnal
text (like a normal char field).

This commit provides tests and documentation for those 2 widgets.

Task #39079
2018-08-13 14:33:48 +02:00
Christophe Simonis 7499b47ffa [MERGE] forward port branch saas-11.4 up to edd586002e 2018-08-10 13:37:21 +02:00