Commit Graph
350 Commits
Author SHA1 Message Date
Christophe Simonis a2f275dfc4 [MERGE] forward port branch 11.0 up to 4ea3838d89 2018-05-29 20:00:31 +02:00
Lucas Perais (lpe) 94a7bef5db [FIX] web: domain evaluation in parented m2o in o2m list
Model A has a o2m to model B
Model B has a m2o parent_id on B

In A's form, add a B item,
then in the m2o, create record
Save and New
Click on the m2o

Before this commit, the python crashed on name_search.
This was because we sent the virtual ids to it

After this commit, there is no crash

OPW 1850212
closes #24948
2018-05-29 13:44:23 +02:00
Lucas Perais (lpe) 9654f6b8e0 [FIX] web: o2m editable decorated, paged, ordered supports adds/cancel
Have a decorated (conditional on field) editable list, with a default_order.
Have more records than the pager allows.

Add an item, and hit escape to cancel addition.

Before this commit, the cancellation crashed because the first record on the other page
was trying to evaluate the decoration for its row, which is wrong in the first place.
This was because creating a record increases the limit of the list, to be able to see the record
being created.
At cancellation though, that limit was never decreased.

After this commit, the whole flow happens without problem.

OPW 1844495
closes #24682
2018-05-28 17:25:51 +02:00
Christophe Simonis 2bc6ea1b37 [MERGE] forward port branch 11.0 up to 02ee3fd88e 2018-05-23 19:33:40 +02:00
Alexandre Kühn c587c0029b [FIX] web: only abandon records on discard without savepoint
Revision on https://github.com/odoo/odoo/commit/9a9da5763b38a3bce54e9c4870af0032e38cacc3

The intent of the commit above was to no abandon records in a list on
discard when these records have been created from a `default_get`.

Also, the `default_get` may also perform an `onchange` that could create
more records. The records from this `onchange` must also be included in
the "do not abandon" rule.

However, the rule was too relax, so that any following `onchanges` from
a user interaction was also considered into this rule. As a result, it was
not possible to abandon such records.

With this fix, we restrict the rule to `default_get` (already the case) and
only the `onchange` right after a `default_get`. Any record created on an
`onchange` from a user interaction after a `default_get` should be abandoned
on discard.

Representation of creating the list:

                               savepoint
   |----------|-----------|-------||--------|------->
 create   default_get  onchange1         onchange2

record in the list is created by default_get or onchange1
    => do not abandon on discard
record in the list is created by onchange2
    => abandon on discard
2018-05-23 09:43:12 +02:00
Alexandre Kühn 8ac98fc78a [FIX] web: show names of many2one on default_get
Before this commit, some records in a list did not show the name of their
many2one fields.

This case occurs when the records in the list are created from a default_get,
and the records do not fit in a single page. In that case, the records in the
first page correctly display the names of their many2one fields, but not the
records in the other pages.

Fixes #24547
2018-05-18 17:30:34 +02:00
Alexandre Kühn 6f7031e9fb [FIX] web: pass unique ids on name_get rpc
Before this commit, when a list contains records with many2one fields that
contain the same values, duplicate ids were passed to the server on rpc
`name_get`.

For instance, if 40 records in a list refer to a Unit of Measure with id "1"
whose displayed_name is "unit(s)", the server receives a long list of ids with
simply the value "1". Also, the server responds with a list of displayed_name,
in this case a list of 40 strings "unit(s)".

With this commit, we always pass unique ids to the server on rpc `name_get`.
2018-05-18 17:30:34 +02:00
Christophe Simonis 1655202924 [MERGE] forward port branch 11.0 up to 59a8a1cd8e 2018-05-17 13:19:49 +02:00
len-odoo 25548eb7e9 [FIX] web: sort relational fields by their names
When sorting records according to a many2one field in a list view
embedded in a form view, the js would sort according to their ids,
in a seemingly arbitrary order.
Thus sorting records according to a field with values in ("a", "b", "c")
could be sorted as "a", "a", "c", "b" instead of "a", "a", "b", "c".
We make the comparison on the name of the field instead.

opw 1838860
2018-05-16 08:04:53 +02:00
Christophe Simonis 013ce7f889 [MERGE] forward port branch 11.0 up to f2e105eeca 2018-05-08 19:08:18 +02:00
Mohammed Shekha 2bd92cc581 [FIX] web: use correct href in link for m2o
With a better href, many2one in readonly mode  can be opened in new tab.

Related to task: #32919
2018-05-08 14:46:17 +02:00
Christophe Simonis ac63dfc8f4 [MERGE] forward port branch 11.0 up to 8dade01e2c 2018-05-04 16:10:50 +02:00
Aaron Bohy 6e15a9cd24 [FIX] web: one2many form view with action button
Assume a one2many field inside a form, displaying field A in its
list view, and a field B in its (dialog) form view. Moreover, there
is an action button in the dialog, which updates the value of B.

Before this rev., B wasn't correctly reloaded when the button was
clicked, because the BasicModel reloaded the fields on the list
view (i.e. field A), whereas it should reload the fields in both
views.

This fix is twofold. First, we force the viewType to 'form' when
the record is reloaded, instead of the default ('list'), so that
fields in the form view are correctly reloaded. Second, when we
open the form view in the dialog, we add the fields of the list
view to the dict of fields of the form view, so that the form
is aware of those fields and can ask the model to reload them
(still without displaying them).

Fixes #24189
2018-05-04 10:42:05 +02:00
Christophe Simonis ad802d0d55 [MERGE] forward port branch 11.0 up to c591e0de7d 2018-05-03 11:21:42 +02:00
Nicolas Martinelli f536592691 [FIX] web: inline views should share their fields
This causes issues (already 3, and counting...)

This reverts commit 27c9f838d3.

opw-1840984
opw-1841041
opw-1841000
2018-05-03 08:30:55 +02:00
Christophe Simonis 87e21ccdc5 [MERGE] forward port branch 11.0 up to 521414b1c1 2018-05-02 19:36:16 +02:00
Lucas Perais (lpe) 27c9f838d3 [FIX] web: inline views should share their fields
Have a One2Many
The views of that o2m define two inline views: the list and the form

in the list view, put a field that isn't in the form and used in a domain
Try to add an item to the list
The form pops up

Fill in the data and save & close

Before this commit:
It crashed when evaluating the domain on a field using the field that is not in the form

After this commit:
Subviews share their fields in a special object on the parent record
In our case, the form view checks in that shared resource if the fields it is supposed to initialize
are there.
Hence, this flow doesn't crash anymore

OPW 1837511
closes #24350
2018-05-02 11:09:50 +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 fed775bc0c [MERGE] forward port branch 11.0 up to 8c64159b88 2018-04-18 18:20:40 +02:00
Aaron Bohy 05589db823 [FIX] web: don't ignore required attrs on image fields
Before this rev., falsy image fields could be saved even if they
were required.
2018-04-18 17:40:09 +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 5f2d080cf8 [MERGE] forward port branch 11.0 up to ad825b673b 2018-04-16 18:34:56 +02:00
Nicolas Lempereur b8b0f947bf [FIX] web: remove ­ when saving phone number
When Odoo display a phone number number, on phone or if VOIP is
installed a invisible `­` character was added from 9.0 up to
saas-11.2 so an applications such as skype would not be concerned with
the number.

But if someone copy-pasted from this to somewhere else in Odoo, we would
get incorrect number with this invisible caracter. So this change make a
special case for the "FieldPhone" so the character is removed from data
saved.

opw-1834858
closes #24223
2018-04-13 15:35:33 +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
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
Rémi Rahir f1a884e046 [FIX] web,account,google_calendar: correcting previous commit
corrects error added in c3d1eda017 .
Non-breaking spaces were explicitely added in the tests. This commit
restores the proper behaviour.
2018-04-03 18:05:52 +02:00
Rémi Rahir c3d1eda017 [FIX] web,account,google_calendar: chasing breaking spaces
Before this commit, some breaking spaces were present in the js code.
Such spaces are misinterpreted and worked by luck.

This has become a problem with exported js bunldes (e.g. the
external_lib bundle in im_livechat).

This commit replaces breaking spaces by regular spaces.
2018-04-03 15:52:17 +02:00
Goffin Simon 1039abfbdb [FIX] web: time format without seconds
Steps to reproduce the issue in 11.0 Enterprise:

- Go to the language English
- Remove from the time format the seconds
- Refresh the page
- Go to sales
- Create a sales order;

Bug:

- You get the warning message

closes #23596 closes #22027
opw:1829577
2018-04-03 09:19:34 +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 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 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
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
Aaron Bohy a0b06afcf3 [FIX] web: 'toggle_button' widget in edit mode
The 'toggle_button' widget is one of special field widgets that
can trigger changes in readonly mode (in this case, toggle the
boolean value when clicked). It was working fine in form views in
'readonly' mode, as in this case, the new value is saved directly,
and the form view is re-rendered (a new widget is created with the
new value).

However, in 'edit' mode, the value isn't saved directly (the user
has to click on 'Save' to save the changes), the widget is reset
with its new value, and the reset wasn't correctly handled in this
particular widget.

Fixes #23400
2018-03-12 12:56:00 +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