Commit Graph
245 Commits
Author SHA1 Message Date
04c44c479d [IMP] base(_import),web: mute Add/Create button in x2m
... by setting it 'btn-default', because users hesitate between
that button, and those in the control panel.

Task 32950

Co-authored-by: dbh <dbh@odoo.com>
Co-authored-by: aab-odoo <aab@odoo.com>
2018-04-25 15:09:35 +02:00
Christophe Simonis 1f22b81203 [MERGE] forward port branch saas-11.2 up to 7113b70762 2018-04-23 19:36:25 +02:00
Christophe Simonis e8bf128318 [MERGE] forward port branch 11.0 up to 3ab25b60bc 2018-04-23 18:15:25 +02:00
Christopher Ormaza 30490cae89 [FIX] web: handle nested x2m default values
The initial rev. odoo/odoo@2d3ecf2 that was supposed to handle this use case
was in fact only dealing with one command as default value for nested x2m, not
more.

The basic model can now handle multiple commands.

Closes #24241
2018-04-23 17:35:03 +02:00
Christophe Simonis c309ccd7b3 [MERGE] forward port branch saas-11.2 up to fed775bc0c 2018-04-18 18:30:35 +02:00
Christophe Simonis fed775bc0c [MERGE] forward port branch 11.0 up to 8c64159b88 2018-04-18 18:20:40 +02:00
Martin Geubelle cd934f307d [FIX] web: handle x2m commands with reference as default
Before this rev. it was not possible to define a value for a reference field
in x2m commands as default value.

Courtesy of @kaerdsar.

Closes #24070
2018-04-17 15:31:33 +02:00
Martin Geubelle 9e6c616130 [FIX] web: focus select in reference widget
In the reference widget, the focus was always on the input (many2one) even
though the first select (with the model) was not set.

Thanks to @kaerdsar for the original PR.

Partially closes #24070
2018-04-17 15:31:32 +02:00
Christophe Simonis 74033eb007 [MERGE] forward port branch saas-11.2 up to 90f8f17fb4 2018-04-16 19:50:50 +02:00
Christophe Simonis 5f2d080cf8 [MERGE] forward port branch 11.0 up to ad825b673b 2018-04-16 18:34:56 +02:00
Aaron Bohy 52cd52e624 [FIX] web: BasicModel: default_get on o2m with date field
Before this rev., a crash occured when a default_get returned a
command 0 (CREATE) for a one2many, with a value for a date(time)
field (e.g. [0, false, {some_date_field: '2018-12-08'}]). This
was because the related values (inside the commands) weren't
parsed. This only impacted date and datetime fields, for which the
parsing converts the string into a moment instance.

Fixes #23672
2018-04-13 14:59:48 +02:00
Lucas Perais (lpe) 8e5156938a [FIX] web: o2m list with field datetime from server
Have the create_date field displays on a one2many list
Try to add a record onto the list

Before this commit, when the virtual record is added onto the list
it crashes because the datetime field is undefined and cannot be parsed

After this commit, It doesn't crash though the value would have to wait the save on the main record
to be updated (because it is the create_date)

OPW 1834250
closes #24097
2018-04-13 13:41:39 +02:00
Aaron Bohy 9c1c2c55c2 [FIX] web: one2many: add new record with 'Save & New'
Consider the following scenario involving a one2many list (non
editable) inside a form view:
 - click on 'Add an item', a model opens,
 - fill the fields and click on 'Save & Close',
 - reopen the freshly created record,
 - maybe make some changes (this is optional, but makes sense),
 - click on 'Save & New',
 - fill the fields and click on 'Save & Close',
 -> the second created record isn't added to the list.

The problem comes from the fact that when the dialog is opened for
the second time (in this case by clicking on a record), the 'save'
handler registers an 'UPDATE' command. While this is correct for
the 'Save & New' click (as we update an existing record), this
isn't for the second record which doesn't exist yet, and thus
requires an 'ADD' command.

This rev. ensures that the two cases are handled in the 'save'
handler given to the dialog.

OPW 1829723
2018-04-12 14:37:35 +02:00
Vincent Schippefilt 02a063fd73 [IMP] web: keyboard navigation in form view
The goal of this commit is to allow fast entry of the same model using
the keyboard for navigating through the form once, by blocking the user
from advancing in the form if there is a required field or once they
went through the form once to get them to a primary action (button)

This commit includes the following changes
    1) Enable moving forward from field to field using the TAB key
    2) Entering the one to many and many to many using the TAB key
        a. When entering it, set the focus on the "add new line" link or
            button
		b. When adding a new line, set the focus on the field visible
            editable field of the new line
        c. Discard adding a new line with ESC key
        d. If the user leaves the first field empty and uses TAB, we
            will cancel the adding of a new line and move to the next
            field of the form
    3) When a field is required and not filled in, do not allow the user
        to move out of the field using the TAB key (the user is still
        allowed to use the mouse though), mark the field as invalid
        instead
    4) After going though the form once, using the TAB key on the last
        field will move the focus to the first primary button of the page
    5) When the focus is on a primary button (EDIT/SAVE), the user cannot
        move the focus forward using the TAB key. Hitting TAB again will
        display a tooltip telling to hit ENTER to activate the button.
        The mouse is still available to move the focus.
    6) When the user saves, the focus is placed on the first primary
        button of the form renderer (like VALIDATE for a new invoice)
    7) On dialogs, primary buttons should stop the users from moving out
        of them, and showing a popup if the user tries
    8) When closing a dialog, the focus will be moved back to the widget
        that opened it.

This commit does not include the following features
    1) Navigation with the keyboard on a selection one to man
    2) Navigate between tabs in a form using the keyboard
    3) Cancelling the adding of a new line in a many to many using the
        ESC key do not set the focus correctly
    4) Enhancing the focusses fields (like blue underline)
2018-04-10 09:39:08 +02:00
Christophe Simonis 860dfb5586 [MERGE] forward port branch 11.0 up to d277adf4d5 2018-04-06 15:36:10 +02:00
Alexandre Kühn 9a9da5763b [FIX] web: no record abandon on discard from default_get/onchange
Before this commit, when some records were created from an `onchange`,
we have the following weird behaviour:

    Suppose that this record has some required fields that are empty.
    When we click on this record, then somewhere else, the record
    disappears from the list.

This is because the records contains invalid fields, and it is wrongfully
assuming that the record to be discarded comes from "Add an item".

A previous commit [1] fixed a bit this issue with `default_get`, but since
it relied on a fragile heuristic, we decide to apply the correct fix with
this commit.

[1] https://github.com/odoo/odoo/commit/b09f0c99be2b13d33986414485556d87da186d65
2018-04-05 17:14:57 +02:00
Dharmraj Jhala b67331fc18 [IMP] web: Allow user to set custom 'create_text' for x2m fields
For x2many relational fields(of type kanban), we shoud be able to set custom label for
'Create / Add' button by adding 'create_text' node option on particual field from xml.

Right now, 'create_text' is only handled for many2many fields, preventing users to set
custom label for one2many fields.

This commit allows users to set Create Button label for both m2m and o2m fields.
2018-04-05 15:15:07 +02:00
Lucas Perais (lpe) 07435b1104 [FIX] web: correctly display reference field in subview
Have a form view with a O2M.
The model at the 'many' end has a reference field

Have a record of the second model display in a modal
(by clicking on a record in the o2m list)

Before this commit:
The field reference was not filled up
This was because the fields to fetch on the modal creation weren't correctly set.
Obvisouly, it also created problem when trying to change the record on the modal:
spawning tracebacks because the reference field was not present in the local datas

After this commit:
The display of the reference field is as expected both in the original form and in the modal

OPW 1829822
closes #22468
closes #23896
2018-03-28 09:18:07 +02:00
Christophe Simonis 845f4ef7d3 [MERGE] forward port branch saas-11.2 up to 8a7b845353 2018-03-23 10:31:00 +01:00
Christophe Simonis 8a7b845353 [FIX] web: correct forward-port of ef540eb006
Adapt tests and classes
2018-03-23 09:46:46 +01:00
Christophe Simonis cdbee48888 [MERGE] forward port branch 11.0 up to 39d9c362c5 2018-03-22 20:05:14 +01:00
Lucas Perais (lpe) 8df055b584 [FIX] web: don't loose focus when editing cell in list
Have a list with readonly modifiers on at least one column.
Have the first record of the list be readonly as computed by the modifier
Create and edit a second record
Enter a value in the cell and hit TAB

Before this commit:
The focus on the targetted cell was lost and the rendering of the cell was in mode readonly
This was because the baseMode of the modifier dict was applied to one and only one node (== one column) and hence to *all* the records

After this commit:
The rendering and keyboard TAB navigation works as expected in the list editable
The baseMode concept has been sharpened and each cell now has one

OPW-1816569
OPW-1824979
closes #23809
closes #22859
closes #23436
2018-03-22 22:51:57 -08:00
Luis González ef540eb006 [FIX] web: Make accessible with keyboard the delete button on o2m fields (#23719)
* [FIX] web: Make accessible with keyboard the delete button on o2m fields

Currently, the delete button in one2many fields (trash icon) is not
reachable when using the keyboard, because it's neither a link, nor a
button or any other interactable HTML element, but a `<span>`.

This change causes that button to be an actual HTML button keeping the
same appearance, so it may be reached when using the keyboard.

* [FIX] web: Modify test to expect button instead of span as o2m trash icon

Since buttons to delete records in o2m fields (the trash icon) were
changed from `<span>` to `<button>` to be able to access them with the
keyboard, the test need to be modified so it expect the new element
type and doesn't break.
2018-03-22 12:18:35 +01:00
Christophe Simonis b51f2d38c2 [MERGE] forward port branch saas-11.2 up to 500e3f4970 2018-03-21 11:04:48 +01:00
Christophe Simonis a4a16f3ab6 [FIX] web: correct test to satisfy new class for remove button in m2m lists 2018-03-20 14:20:59 +01:00
Christophe Simonis e0345a4a3f [MERGE] forward port branch 11.0 up to 2835d29979 2018-03-20 11:45:11 +01:00
Lucas Perais (lpe) 61216f116a [FIX] web: add many records in m2m list
Have a model with a m2m (field A)
  this m2m has also a m2m (and displayed as m2m tags in the view) (field AA)
Have a domain on field A, to trigger the search view selection
Click on add an item
Select everything in the modal, making sure that there is more than 40 records

Click on Select

Before this commit:
There was a traceback indicating the local data did not contain records >= 40
This was because the internal data repository was constrained by a limit

After this commit:
We adapt the limit of the local data repository and there is not traceback

OPW 1823400
2018-03-15 15:11:08 +01:00
Géry Debongnie 7287c672f5 [FIX] web: x2m: properly reset limit/offset to initial value
When we discard an element, we want to make sure that the new state is
not corrupted by previous user operations.  In our case, we possibly had
a limit and an offset values modified by the user.

This could lead to unpleasant situations, with incorrect data displayed
on the form view.

Note that this actually fixes a new bug introduced by commit
https://github.com/odoo/odoo/commit/e7fab234201e357da52c3576ad2e8fc9ceee9359
(this is the commit that introduces the tempLimitIncrement attribute)
2018-03-14 17:03:23 +01:00
Géry Debongnie 4586b876f2 [FIX] web: unselect current row before changing page
The issue here is quite simple.  If we are editing a multipage one2many
field, then we click on the pager, we need to properly unselect the
current row.

If we do not do that, then we can enter invalid data.  For example,
assume that there is a readonly field. We click on add, it creates a
(virtual) record with no value for that field.  When we click on the
pager, we select the next page, and bypass all validation.
2018-03-14 17:03:18 +01:00
Géry Debongnie 4fd9db52a2 [FIX] web: prevent issues with pager and x2m and limit
When we are in the process of adding a record, we do not want to update
the pager count.  The reason is that if the user is at the limit (so,
1-40/40, no pager visible), then click on add, there will be a pager
shown with 1-40/41.  Now, imagine that the record currently being added
as a required field, and the user clicks on the pager. In that case, we
need to discard the newly added record (bringing the total back to 40),
then move to next page, which does not exist anymore.

So, to fix this issue, we simply consider that a record being added
does not count, from the point of view of the pager.
2018-03-14 17:03:11 +01:00
Martin Geubelle 7afc5fd6ad [REF] *: put clickable in widget options for statusbar
The widget statusbar was using an attribute `clickable` on the field widget
to define if the statusbar was clickable.

This attribute is in fact not a field attribute but a widget option so it
has been moved accordingly.

Note that a retro-compatibility adapation is done in the field widget.
2018-03-14 09:38:23 +01:00
Géry Debongnie e7fab23420 [FIX] web: better experience for one2many edition (paged)
A big problem with the o2m edition happens when the user has a full page
(so, in general, 40 records) and click on add.

If the o2m is in editable="bottom" mode (which is actually a really
common usecase), then the next record will be added at the end.
However, since we have a limit of 40, it will immediately go to the next
page.

The effect is even weirder when there is a required field in the tree
view.  In that case, the new record appears correctly, the user can edit
it, then, as soon as the required fields are set, it will immediately
disappear from the current screen.

In this commit, we have a really simple solution: we simply increase the
limit in this case.  An interesting thing is that it is actually temporary:
when the user goes to the next page, the limit is back to its original
value (due to the pager click: it resets the value to what the pager knows).
2018-03-12 13:53:39 +01:00
Christophe Simonis 36945a5853 [MERGE] forward port branch 11.0 up to c2e878e34c 2018-03-01 19:43:25 +01:00
Géry Debongnie 132137939c [FIX] web: prevent footer from being rerendered
In some cases, the footer in a form view dialog could be duplicated.
The reason was that the form view was rerendered completely, footer
included, by the renderer, out of the formcontroller control (it is the
formcontroller's job to move the footer buttons to the footer).

A possible fix is to work on the form renderer to make it aware that the footer
buttons are expected to be only rendered once, but it has the disadvantage to
be a fix specific to this issue, and any other form view behaviour with some
side effects may have the same issue.

This commit tries to prevent the form view from rerendering itself
completely in those cases. This also has the disadvantage of possibly
not being a complete fix, if some edge cases are missed.  However, I
have the feeling that we still want to avoid rerendering the full view
if possible.
2018-03-01 16:08:22 +01:00
Aaron Bohy a16013be66 [FIX] web: multi pages ordered o2m with onchange
Let's assume a one2many displayed over several pages with a default
order such that a record, say R, that would normally be on page 1
is actually on another page. Moreover, there is an onchange on that
one2many which converts all commands 4 (LINK_TO) into commands 1
(UPDATE), which is standard in the ORM.

When the first line of the one2many was edited, the record R was
fully loaded, whereas it shouldn't have been (as it is not on the
current page). So basically, a useless read was performed.
Moreover, if there was an x2many field in the one2many list, a
crash occurred because relational data of R that shouldn't have
been read wasn't postprocessed by the BasicModel.

The useless read occurred because the one2many subrecords weren't
correctly sorted before checking if some of them/some of their
fields should be read. This is not the case anymore.

OPW-1816800
2018-02-26 08:14:08 +01:00
Aaron Bohy ad1cceb4fb [FIX] web: one2many and onchange corner case issue
Let's assume a one2many list view inside a form view, displaying
a single char field A. There is an onchange on the form view
returning a command 0 (CREATE) for the one2many. The command 0 only
specifies a value for field A. The one2many list isn't editable, so
when a sub-record is clicked, it is open in a form view (in a
dialog). In this form view, an x2many field B is displayed in a sub
list or kanban view.

Before this rev., it crashed when the user tried to open the
created one2many sub-record (returned by the onchange) in the form
view, because of the presence of the x2many field B, which wasn't
correctly processed by the BasicModel (its value was undefined,
whereas it must be a valid, empty, dataPoint).

Moreover, the limit of the x2many field B wasn't set, so a pager
was displayed as soon as it contained at least one record.

Fixes #22050
2018-02-23 10:01:39 +01:00
Christophe Simonis 9a84ba5533 [MERGE] forward port branch saas-11.1 up to e750bb6e11 2018-02-22 10:39:15 +01:00
Christophe Simonis ae6a65753e [MERGE] forward port branch 11.0 up to dbb713c2f8 2018-02-21 20:19:26 +01:00
Aaron Bohy ff019aa52f [FIX] web: BasicModel: onchange on X2M: handle command 6
Before this rev., when an onchange returned a command 6 for an
x2many field, it was completely ignored by the BasicModel.
2018-02-16 14:28:50 +01:00
Aaron Bohy cf03101447 [FIX] web: BasicModel: fetch nested x2manys after onchange
When onchange RPCs return a command 4 (LINK TO), the res_id of the
record to link is given, and the BasicModel has to read the fields
in the view for that record. When one of those fields is an x2many
(for instance, displayed with widget many2many_tags), the
subrecords in the relation must be read as well (at least their
display_name).

Before this rev., this last part wasn't done by the BasicModel, and
as a consequence, the many2many_tags widget was always empty, even
though there were records in the relation.

Same thing applied to reference fields, but this is way more
uncommon.

This rev. ensures that x2manys and reference fields are correctly
fetched in this scenario.
2018-02-16 14:28:50 +01:00
Alexandre Kühn b09f0c99be [FIX] web: discard new record with empty required field
Before this commit, there is an issue with one2many lists with records that
have been created on 'default_get': if the record has a required field that
is empty, when the user clicks on this empty required field and then somewhere
else, the record is removed from the list.

The cause of this bug is that these records have invalid field changes, here
the required field that is empty. As a consequence, it checks whether the
record is "new", and if so, removes it visually from the editable list.
(Note: a record is "new" when it is not stored in DB).

This behaviour is expected when discarding records created from "Add an item".
However, that is not intended for records that have been created as default
items of the list. These records are still considered as "new"  items, because
they are not stored in DB, but they should stay in the list on discard.

This commit solves the issue by making an additional check before assuming
that the record for which we discard changes comes from "Add an item":
if the record in the list has been created before user interacts on the list
(in other words, the record has been added in the list when the user accesses
it), then we should not remove the record from the list, even though the record
has some invalid fields from the savepoint (e.g. empty required).

opw-806650
2018-02-16 11:17:36 +01:00
Alexandre Kühn 7339ae978f [FIX] mail,web,*: Cleaning some JS code
- Whitespace trailing
- Split long lines
- Replace some 'self' to 'this'
- Improved some JS docs
- DRY in tests using services
2018-02-12 16:09:38 +01:00
Géry Debongnie 13c885195d [FIX] web: make sure onchanges are properly triggered
The issue adressed by this fix was observed by a problem with a missing
onchange. The situation only happens when we have a one2many in a form
view with an onchange in a field in the list view, and the arch of the
list view is not inline.  In that case, the onchange was not properly
triggered.

There are two causes for this bug:
- the BasicModel does not exactly receive the same data when loading a
  record in a one2many with a non inline view.  More specifically, there
  is a confusion with the fields/viewFields in that case.  This is done
  because the postprocessing of the fields is slightly different when a
  sub view is not inline (not ideal situation, we should fix it btw)
- when it construct a subrecord, the BasicModel did not use the correct
  fields value, when there was a subview.  More specifically, it used
  the view.fields (which does not contain onchange informations) instead
  of the view.viewFields (which contains processed/view specific
  informations, including the onchange data.

This commit fixes the second issue, because this is clearly a bug, and
it actually fixes the problem.  The first issue is actually okay,
because we already have a difference of behaviour between the main view
and sub views (in the first case, we have the fieldget information, not
in the second case, so the processing is already a little bit different
anyway)

Notes:
- This bug was discovered only because we added a test in 11.0, which
  was forwardported and broke in master.  The breakage occured because
  of a recent refactoring in master which moved the arch processing
  inside the views and out of the data manager.
- It is good that we discovered this bug, but I want to say that it really
  sucks that forwardports are done, break the master/saas.11.2, then I
  have to fix it in emergency, and it completely break my own
  schedule...

wip

wip
2018-02-03 07:40:24 +01:00
Christophe Simonis 3d73f18aa9 [FIX] web: correct draganddrop call in new test.
The test doesn't still pass as onchange is not call on `sequence` field.
2018-02-01 19:52:26 +01:00
Christophe Simonis e00a447e2c [MERGE] forward port branch saas-11.1 up to 7e469eb77a 2018-02-01 18:20:28 +01:00
Christophe Simonis 7e469eb77a [MERGE] forward port branch 11.0 up to f5e7b86686 2018-02-01 18:15:21 +01:00
Lucas Perais (lpe) 9fa597c7ec [FIX] web: sequence handlers on modal's one2many list
From a form view (say Bill of materials)
Edit the form
Click on a bom line
Click on the external button that makes the product form pop up
change the order of suppliers on that product

Before this commit, a JS traceback was raised
This was because the changing object was not present in the localData that the Model object holds
or more accurately, it was not the **right** model object that was targetted
and this was due to the propagation of the resequence event

After this commit, no error is thrown, and the resequencing works as expected

OPW 807196
2018-02-01 13:53:52 +01:00
Christophe Simonis 88a87240a6 [MERGE] forward port branch saas-11.1 up to 8613724bfc 2018-01-25 17:38:41 +01:00
Christophe Simonis cb50970f3f [MERGE] forward port branch 11.0 up to eefe879a37 2018-01-25 15:41:45 +01:00
Martin Geubelle 2d3ecf29b3 [FIX] web: handle nested x2m default values
A `default_get` for a x2many field can return a new list of commands for one of
its x2many field, like

[[0, 0, {
    'groups_id': [[6, 0, [1, 2, 3]]],
}]]

where [1, 2, 3] is a list of existing ids.

This use case was not correctly handled by the BasicModel because
`_makeDefaultRecord` was not recursive.

Closes #22401
2018-01-24 10:59:45 +01:00