Commit Graph
778 Commits
Author SHA1 Message Date
Simon Genin (ges) ecfe85db84 [REF] web: static/src/(img|fonts) => static/(img|fonts) 2021-04-29 07:34:40 +00:00
Aaron Bohy b592d119e5 [FIX] web: make test pass on chrome 90
The changed test uses the drag&drop helper, and an operation does
not work as expected with the given params on chrome 90. The runbot
currently uses chrome 80, so it is not an issue, but if your chrome
is up-to-date, and you try to run the test suite, this test would
fail.

closes odoo/odoo#70032

X-original-commit: 43994da9980e4133274984f720bb58f3546ea0f9
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-04-28 14:35:07 +00:00
Xavier Morel 95128e6472 [FIX] web: test broken in Firefox
This is arguably a 20 years old Firefox bug (at the very least an
under-specified area of the spec where Firefox's behaviour is
technically allowed under spec but not super useful or convenient):
`window.getSelection()` simply doesn't work when invoked on a form
field: https://bugzilla.mozilla.org/show_bug.cgi?id=85686.

Getting the selection data more explicitly by looking up the focused
form element, then checking *its* selection, seems to work fine and be
cross-browser.

Also focus() the input while at it: according to MDN

> Calling element.select() will not necessarily focus the input, so it
> is often used with HTMLOrForeignElement.focus.

And jQuery doesn't really document whether `select()` will implicitly
`focus()`, so better safe than sorry.

closes odoo/odoo#69579

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2021-04-21 06:22:48 +00:00
Aaron Bohy facd78d5f3 [FIX] web: onchange: send correct nested x2manys values
Commit [1] recently fixed an issue with nested x2many fields and
onchanges: in some cases, all field values weren't sent to the
server as they should.

However, there is a small issue with this fix. We didn't correctly
apply the default value to option `changesOnly`: when not given,
it was considered false, whereas in this particular function it
should have been true.

It caused an issue in the following scenario:

Have a form view with an x2many field (say A) displayed as a list.
In the list, there is another x2many field (say B), and (whatever
its type) a field C with an onchange. When the user changes C, the
onchange is performed, and we send to the server the value of all
fields. In particular, in the row, we send the value for the
many2one field pointing to the main record (the inverse field of
the x2many relation). The value for that field is basically the
whole record, containing itself field A. For field A, the value is
a list of commands, and for the updated record, it is a command 1.
Before this commit, in the values sent for this command, field B
was the empty array, even if it wasn't empty.

This issue was reproducible in account.move, on an existing record
having already a line in invoice_line_ids (this is field A). In
that line, tax_ids (this is field B) must have a tax which is
included in the price. When changing the quantity of the product,
the subtotal wasn't correctly computed.

[1] https://github.com/odoo/odoo/commit/a8b43d02066b2299ac2f4b88056c37725e9ce6cd
opw~2489755

closes odoo/odoo#69227

X-original-commit: 3f54ca3e29d1537f66c6a3b56494dc065d9230e9
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-04-14 09:01:34 +00:00
Aaron Bohy c89cdcf11c [FIX] web: tests: patch form multiClickTime once for all
A lot of tests in different QUnit modules need this delay to be
patched to 0. Some of them (e.g. the 'ActionManager > Misc' module)
didn't patch it correctly. It worked before because a patch was
done in a previous test, and wasn't unpatch. The previous commit
ensures the patch is removed, so now we have at least 2 tests of
the above mentionned module that fail. This commit ensures that
the delay is patched in every tests, and allows to specify a
custom delay if necessary.
2021-03-31 09:30:07 +00:00
Mohammed Shekha 8b6063ac16 [IMP] web, *: discard unchanged record in editable list
* sale_product_matrix

Before this commit, if we created a new row in an editable list view,
do not "touched" it and clicked out of the list then the record tried
to be saved and threw error notifications.
Now, that flow will discard the record to make it consistent with the
form view which discards the record when we leave the form.

task-2431691

closes odoo/odoo#68382

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-03-30 10:44:25 +00:00
Simon Genin (ges) 51e660c47e [IMP] web: align date range widget behavior with date picker's.
The range date lib would open the selector on focus.
This is a behavior we don't want in lists, but want to keep in quickedit
forms.

Task id: 2492914

closes odoo/odoo#68390

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-03-29 09:38:07 +00:00
Nicolas Lempereur 0e004e1b7c [FIX] web: no quick edit on mouse text selection
Do not trigger quick edit when we are selection text with mouse:

- click and holding to select text
- multiple clicks selecting text

Since click on an editable field now change the edit mode, we could no
longer select the text.

With this change, quick edit is delayed by a given delay and if the edit
mode is not enabled if:

- there is a subsequent click within the delay
- there is a text selection when the click event is handled

closes #68023

X-original-commit: 2939ea4dd4736e659cc3e4df2226a3b08ac8ec48
2021-03-22 16:59:38 +00:00
Simon Genin (ges) 3d0b77a711 [FIX] web: remove memory leak in editable list used as one2many
The confirmUpdate method in list_editable_renderer would destroy all
rows' widgets and recreate them *except* the currently modified one
(this one gets updated).

The problem was that the widgets of the current row were recreated
anyway. It created a memory leak.

This memory leak isn't such a big deal, as anything is garbage
collected as soon as the view is left anyway (so it's a small leak
during the lifetime of the x2many list)

The fix consists in keeping the reference of the widgets on the
currently modified row, and when all rows' widgets are recreated, we
delete a replace by our reference for the current row.

closes odoo/odoo#68386

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-03-26 13:27:48 +00:00
Simon Genin (ges) a52d32822d [FIX] web: o2m list editable updates did not call on_attach_callback
In a list editable used as a one2many representation, inside the
confirmUpdate method, the on_attach_callback method on the field widgets
wasn't called.

It wasn't detected earlier because most of the legacy widgets didn't
implement this callback (all owl components do however).

It was problematic as the confirmUpdate function destroys and recreates
all the field widgets (with exception for the currently modified row).
Not calling the on_attach_callback would result in missing / unexpected
behavior such as _applyDecoration not being called.

The fix is simple: call the method if it exists on all the widgets after
they have been created.
2021-03-26 13:27:17 +00:00
Barad Mahendra 9a57330d06 [IMP] web: display the default label next to the icon in state_selection
Purpose of the commit is to display the default label next to the icon
for state_selection widget in list view.
also that widget support the hide_label option to hide the label in
state_selection widget of the list view.

Related Ent PR: odoo/enterprise#16559

closes odoo/odoo#66589

Taskid: 2451287
Related: odoo/upgrade#2195
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-03-22 08:42:04 +00:00
Aaron Bohy 2c69b323b1 [FIX] web: do not display falsy url field widgets
Before this fix, unset char fields with the url widget in form view
displayed "false", whereas they should simply be empty. This is a
side-effect of commit [1], which aims at reducing the shift between
readonly and edit modes in form views.

[1] https://github.com/odoo/odoo/commit/288b24cbdf54ac0dbee7e012f074fac9a0c68238

closes odoo/odoo#68330

X-original-commit: de1f7ab77d37adbbc68e640ea9877721bfc869d2
Signed-off-by: Michaël Mattiello <mcm-odoo@users.noreply.github.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-03-25 11:03:54 +00:00
Krzysztof MagusiakandAaron Bohy b08afa3475 [FIX] web: can update one2many with custom field widget
One might design a custom field widget to display/interact with a
one2many field. Before this commit, if this field widget triggered
a field_changed event to update a related record, it crashed,
because the code assumed that there was a view associated with the
field.

Closes #68276
opw~2468238

closes odoo/odoo#68309

X-original-commit: 3826a2645b94e0f62c719814c4dbe4cc6502e1f2
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Aaron Bohy <aab@odoo.com>
2021-03-24 14:38:11 +00:00
Michael Mattiello (mcm) c56324ea38 [FIX] web: display remove buttons in embedded list
Since the quick edit behaviour has added, embedded lists
can be edited and display the "add a line" buttons  in a
readonly form but not display the remove buttons
This commit fixes that inconsistency.

X-original-commit: 7cc17a345bc9cbe165d061300d91d1ac0e583fc1
2021-03-16 09:23:49 +00:00
Aaron BohyandGéry Debongnie 1988db86aa [FIX] web: nested one2manys, onchange and no command
Let's assume the following situation. We have a form view with a
one2many field A displayed as a list. In the list, there is a
one2many field B. B can't be edited, its value is computed by
an onchange. By default, it contains a single record (i.e. the
first value returned by the onchange is [[5], [0, 0, {...}]]).
When another field (say C) changes, B's value is re-computed to
[[5]]. Moreover, there is an onchange on A.

In this form view, let's assume the following scenario. Create a
new record and add a line to A. In this new line, B already
contains a record. Change C. This triggers an onchange that
returns [[5]], and B is now empty. It triggers a second onchange,
on the main record (as field A changed).

Before this commit, in this second onchange, B's value wasn't sent
among the other values of the new line.

The spec says that for onchanges, we must send all data, not only
what has really changed. From that perspective, the above scenario
highlights an issue.

That issue had two root causes. First, commit [1] wrongly fixed
another issue, and as a consequence, when building what to send
for the onchange, we didn't generate the values for fields that
hadn't changed inside an x2many (for added subrecords at least).
This commit reverts the fix of [1], and fixes it differently by
only sending a command 1 (update) after a command 4 (link to)
when the record is dirty (i.e. when it has been modified). See
[1] for context and details.

Second, the code that generates the values to send to onchanges is
the same as the one that generates the values to save records
(write or create). However, when saving, we only send what has
really changed. The values are at some point processed to remove
empty command lists from the list of changes (as it means that
nothing changed). However, here we ignored the flag that stated
whether we want all field values or just what has changed. This
commit takes the flag into account before removing the field's
value.

[1] https://github.com/odoo/odoo/commit/3e3a244e1afc4d74920a6302a14fa2590e8b6648

Issue reported in task~2352524
  Model: account.move
  One2Many (A): account.move.lines
  Nested computed One2Many (B): tax_detail_ids
  Field triggering the onchange (C): tax_ids

closes odoo/odoo#67739

X-original-commit: a3732031d38d7c7e93565cdd3cd4fdf838ae54ec
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Géry Debongnie <ged@odoo.com>
2021-03-12 09:42:21 +00:00
Aaron Bohy cd367a3967 [FIX] web: FieldMany2Many: link/unlink options
Commit [1] altered the way the FieldMany2Many behaves with respect
to 'create' and 'delete' options. Indeed, for many2many fields,
adding or removing records doesn't mean "creating" or "deleting"
records, as it is only about adding/removing records to/from a
relation. This is completely fine and correct.

Unfortunately, a feature has been lost in the process: it is no
longer possible to state that a many2many field should be editable
but should not allow to add (or remove) record to the relation.

This commit fixes the issue by adding two new options: 'link' and
'unlink' for that purpose.

[1] https://github.com/odoo/odoo/commit/c98579d25af01c14df4baf57fb4652f3e7469096

opw~2466213

closes odoo/odoo#67495

X-original-commit: df44e65bbbba55a7ee2224ad5b4f13248a39423a
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-03-08 16:37:38 +00:00
Aaron Bohy 469dd4cad9 [FIX] web: correctly edit Many2ManyCheckboxes with 100+ values
The Many2ManyCheckboxes widget displays all values that could be
in the many2many relation, with a checkbox indicating whether each
value is in the relation or not. It is designed to be set on fields
where the comodel contains a few records (typically, we don't want
to see dozens of checkboxes in the form view). This widget shouldn't
be used on many2manys with a large comodel, as we have better tools
to handle them (like a tree view).

We deal with extreme cases (when the widget is, by mistake,  set on
a field where the comodel is huge) by using the name_search limit
of 100: at most 100 checkboxes are displayed.

Before this commit, this extreme situation wasn't correctly handled.
If there were in the relation records that weren't displayed
(because they weren't inside the 100 limit), then, editing the value
by (un)selecting a checkbox would automatically remove all non
displayed values from the relation.

This commit ensures that we keep in the relation all values that
aren't displayed.

Issue spotted when working on opw~2439041

closes odoo/odoo#67400

X-original-commit: 9e9d3aa78c42ad4ffca3b56a28382ed84078cde3
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-03-05 16:59:25 +00:00
Aaron Bohy 015ad5ff73 [FIX] web: can edit many2many_checkboxes with 40+ values
Before this commit, if the widget "many2many_checkboxes" was set on
a field with more than 40 values in the comodel (i.e. more than 40
checkboxes displayed), (un)selecting a checkbox that wasn't in the
first 40 checkboxes crashed. This was due to the default x2many
limit of 40: we only created a datapoint for the first 40 values,
whereas we could have up to 100 values to process (name_search
server-side limit). Note that this limit of 40 had no other impact
than limitating the number of records processed by the BasicModel,
the maximum number of checkboxes displayed being ruled by the
name_search server-side limit.

This commit ensures that all values returned by the server (at most
100 when this message is written) are processed and can be edited
as expected.

opw~2439041

X-original-commit: d037d12753179d890459b23319b0d769fce62771
2021-03-05 16:59:24 +00:00
Géry Debongnie 2c777546a7 [FIX] web: prevent traceback when pressing TAB in color_picker widget
The color_picker widget, that can be seen for example in the track form
view for event tracks, had an issue: if the user clicked on it, then
pressed TAB, a traceback was displayed.

The problem comes from the fact that the color picker widget inherits
from FieldInput, but is not a fieldinput, so many expectations made by
the FieldInput code do not hold, such as the code run when handling
navigation (by TAB and such keypress). Because of that, the code in
_onNavigationMove crashed, because it expected an input.

Since this is a bug fix, I simply disabled the navigation in that case,
so no crash happens.  Sadly, this widget has still a big issue: it
clearly does not work as most users would expect: pressing TAB or arrows
should update the selection.  But this would be a more complicated
refactoring, for a bug which is clearly not critical, therefore this
commit implements the simple and safe solution.

Also, we disable the focus outline to minimize the wrong expectation.
Seeing them kind of implied that one could update the selection with the
keyboard.

Note that the widget color_picker was moved from another addon to web/, without
any tests nor documentation.

OPW 2467369

closes odoo/odoo#67195

X-original-commit: 580456b6ab36d16195eae9ffd776ff245ecd936e
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-03-03 22:05:10 +00:00
Michael Mattiello (mcm)andged-odoo 7086488064 [REF] web, *: remove patchMixin + imp utils.patch
* hr, hr_holidays, im_livechat, mail, snailmail, website,
  website_livechat

This commit removes `patchMixin` and improve `utils.patch`.
`utils.patch` now supports native classes and has a new parameter
used to patch class members.

`utils.patch` is now used everywhere `patchMixin` was and it must
be used to patch classes.

closes odoo/odoo#65967

Related: odoo/enterprise#16278
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
Co-authored-by: ged-odoo <ged@odoo.com>
2021-02-26 10:39:21 +00:00
Arnaud Joset 0915ac5a0e [IMP] web: Improve alignment in FieldMany2ManyTagAvatar
Before this commit, the avatar was not properly aligned with the text.

Taskid: 2342252
2021-02-25 08:25:51 +00:00
nie 87334736d4 [FIX] web: fields info for a specific view can be undefined
Steps:
- Install mrp
- Go to Manufacturing > Master Data > Bills of Materials
- Create a BoM
  - Components:
    - Add a component
- Save
- Click the component
- Close the modal window
- Click the component once more

Bug:
Traceback here:
https://github.com/odoo/odoo/blob/55a6642a9621fa9683895d5d45a015bb04c3017b/addons/web/static/src/js/views/basic/basic_view.js#L147
Error: can't convert undefined to object

Explanation:
As seen on the line just above:
https://github.com/odoo/odoo/blob/55a6642a9621fa9683895d5d45a015bb04c3017b/addons/web/static/src/js/views/basic/basic_view.js#L146
`fieldsInfo` might not have the view we are looking for.

opw:2452142

closes odoo/odoo#65998

X-original-commit: a8680ac8815575762b702917940c0b2d4dc0c4ea
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: backspac <backspac@users.noreply.github.com>
2021-02-11 16:01:17 +00:00
Ivan Yelizariev d9ff1e6c69 [FIX] web: fix duplication on phone+sms button rerendering
STEPS:

* Add related phone field to a form (e.g. partner_id.phone to sale.order form)
* Use widget "phone" + activate sms feature
* Create a record
* Click edit, select partner that has phone specified (e.g. +1 234), edit
partner's phone (e.g. +1 234 555), save

BEFORE: ``+1 234 []SMS`` is converted to ``+1 234 555 +1 234 555``
AFTER: ``+1 234 555 []SMS``

WHY:
* FieldPhone is inherited from FieldEmail

  https://github.com/odoo/odoo/blob/0de069b8ca9fb005ba5b076984f5677de25889ee/addons/web/static/src/js/fields/basic_fields.js#L1549

* sms module adds SMS button to ``$el``

  https://github.com/odoo/odoo/blob/0de069b8ca9fb005ba5b076984f5677de25889ee/addons/sms/static/src/js/fields_phone_widget.js#L91

* So this commit filters ``$el`` before updating it

This also solves the same issue but this time for the EmailField widget introduced at 2689915e3f

---

opw-2425949

closes odoo/odoo#65879

X-original-commit: b25104bae7f38d4d1de182176d239b1b7c8f803d
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2021-02-10 13:22:36 +00:00
Aaron Bohy 7a51632e39 [FIX] web: nested x2many with non inline views
This commit partially reverts commit [1], and backports commit
[2] from 14.0.

Even though [1] correctly fixes the faulty scenario, there is a
variation of this scenario which isn't handled. It has been
fixed in 14.0 by [2], and that fix also fixes the original
issue of [1]. So we keep the tests of both [1] and [2], and
the fix of [2].

[1] dd97d446ee94a32089f200bb7122139d31e69873
[2] f6c06bd0b8

closes odoo/odoo#65705

X-original-commit: f2b9a5502f5cf0ee51f193177c679889c18130a9
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-02-08 11:08:06 +00:00
ijas ahammed 2689915e3f [IMP] web,sms: limit the clickable area for email/phone/url widgets
The 'o_text_overflow' class whlie provided on any field, is used to
have classic ellipsis (...) for very long string. However, it is
implemented the way that it occupies the available width for the field
tag it even if the the string is small.

The same class is also utilized in some field widgets like  email, phone,
URL etc. But it has a small side-effect due to full width occupancy.

Because the above widgets rendered an anchor tag, the clickable area is on
the whole available width instead of simply on the content provided in anchor
tag. So even if user clicks on the empty area of that field, the click
action is performed (for example, in email field widget, default mail client
pops-up) which should not happen. It should behave like clickable m2o fields
where the action is performed only when clicking the content and not on the
empty area.

With this commit, we wrap the anchor tag, within a container div tag. Here,
the overflow class will be on the container div which will do it's job to
prevent the long strings from breaking the UI, and the anchor tag being its
child, will not be the full width, thus limiting the clickable area. This
commit also makes the related test cases more robust by checking proper
classes for particular widgets.

TaskId - 2345974

closes odoo/odoo#63735

Related: odoo/enterprise#15777
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-01-15 13:05:54 +00:00
Nasreddin (bon) 6595e770f0 [FIX] web: Not hide daterange if scrolling on mobile + unit test
Issue

	- Install "Field Service" app
	- Create new task
	- Try to select Planned start/end date and valid

	Daterange picker is hiding when trying to scroll down to valid selection.

Cause

	The daterange picker is closed when ev.target is not inside the picker,
	however ev.target always return the document element.

Solution

	Do not hide daterange picker on scrolling if on mobile.

	Note : It will only apply if scrolling on the daterange picker and
	       will still hide if scrolling outside this last one.

opw-2428099

closes odoo/odoo#65435

X-original-commit: 1d9b6f56e70faee13cda0ccb9893ed49904ab319
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2021-02-02 21:27:13 +00:00
Michael Mattiello (mcm) 2c3ac6b254 [IMP] web: add quick edit behaviour
This commit adds the quick edit behaviour.
The quick edit allows to click on fields in readonly form view to switch
into edit mode. After switching mode, the clicked field is automatically
focused.
A few fields have a custom quick edit behaviour after mode switched:
  - checkboxes automatically toggle.
  - radio buttons are set to the selected value.
  - one2many list's cell are focused.
One2many list fields now show the "add a line" in readonly mode.

task 2330101
2021-02-02 12:40:23 +00:00
Michael Mattiello (mcm) d1c56ec7c4 [IMP] web, base: auto save
This commit adds the auto save for editable list and form views
but not for settings.

Now with auto save, changing the pager, going back in the breadcrumb,
going to an other action or clicking on a menu item won't ask to
confirm changes if any but will automatically save them.

In settings, the confirm dialog has been revamped.
We can now decide to "Save" or "Discard" the changes or "Stay Here" to
do nothing.

task 2330101
2021-02-02 12:40:22 +00:00
Michael Mattiello (mcm) 288b24cbdf [IMP] web: reduce shift when switching form mode
This commit does 4 things in order to reduce the shift when switching
mode in form view:

1. modifies the render function of many2one and x2many radio
   fields to render them the same in edit mode and read mode.
2. removes margins in inner form groups.
3. sets a minimum height on rows to align them.
4. empty fields are now visible. (as a blank line)

task 2330101
2021-02-02 12:40:22 +00:00
Aaron Bohy ff1c307b59 [FIX] web: Many2ManyTags: no crash when focusing out
Commit [1] improves the focusout case of the Many2One field: if
the user typed something in the input that matches some records
(i.e. if there are records in the suggestion dropdown), the first
one is automatically set.

The Many2ManyTags field internally uses a FieldMany2One. However,
the same scenario inside a Many2ManyTags crashed. The reason is
that we sent the wrong value in this case (an id, instead of an
object).

[1] https://github.com/odoo/odoo/commit/1d4d2a6

closes odoo/odoo#65386

X-original-commit: e3cf207ecaae2785f7d0e8e3afa0fe45c9d6b88d
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-02-02 09:30:09 +00:00
Romain Estievenart c0bba7e775 [FIX] web: Auto close dropdown is broken
Steps to reproduce:
1. Go to Project App
2. Open and edit a task
3. Click on Customer => search more
5. Click on "Filters"
6. Click on "Group by"
=> The "Filters" and "Group by" dropdown are open at same time => bug

Since odoo/odoo@e4f87710e1, we added a way
to prevent bs and owl dropdown to be open in the same time.

But when the web-editor is present, the CSS selector used to match the
opened modal ("search more" in this case) conflicts with the DOM created
by the web-editor  (modals identified by the classes: .web-editor,
.note-picture-dialog, .note-link-dialog, .note-help-dialog).

To avoid this conflict, this commit uses a more restrictive CSS selector
to match only the first (active) opened modal (as web-editor doesn't
attach its modals at the root of the body).

closes odoo/odoo#65358

X-original-commit: 7cb24db622b231b89558755d9c0e7d899fc994bf
Signed-off-by: Pierre Paridans <pparidans@users.noreply.github.com>
2021-02-01 16:07:11 +00:00
Nicolas LempereurandAaron Bohy b37d005784 [FIX] web: nested x2many with no widget and onchanges
Let's assume the following situation: in a form view, there is a
one2many field A displayed as a list (non editable). In the list,
there is another one2many field B displayed with no widget (it
basically displays "X records"). In A's form view, B is also
displayed, but this time as a list.

There is an onchange on the main form view that adds a line in A,
(and simply sets B to [[5]], i.e. 'No record').

Before this commit, if the user opened the newly added sub record in
A, and clicked on 'Add a line' of B, it crashed.

The cause of the crash was that the wrong viewType was used to
create the new (default) record in B: it used the original
viewType, which was undefined (B is displayed with no widget in
A's list). With this commit, we use the viewType of B that is used
to edit it, in this case 'list'.

In the slighlty different scenario where B is displayed with
widget many2many_tags in A's list, there were no crash, but wrong
fieldNames were sent to the 'default_get' RPC. As a consequence,
default values for fields in B's list were potentially not loaded.

opw-2422806
closes #64793

closes odoo/odoo#65186

X-original-commit: 4212f84da83257419d6d98038220ce1dc322fb04
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Aaron Bohy <aab@odoo.com>
2021-01-28 09:32:12 +00:00
Aaron Bohy ce3c743299 [FIX] web, purchase_product_matrix: can open twice the matrix
Let's assume the following scenario with 'purchase_product_matrix'
module installed:
 - create a new Purchase Order
 - add a line in the one2many
 - select "Customizable desk" as product
 - [the desk matrix opens]
 - close the matrix
 - select "Conference chair" instead
 - [the desk matrix opens, whereas it should be the chair one]

It didn't work because of a small bug in the FieldOne2Many. This
field is configured to be reset when any other field in the view
changes. The product configurator feature relies on that. However,
when another field changes, the One2Many didn't update its internal
state with the new record (and it skipped the rendering, which is
fine). The matrix product configurator thus read an obsolete value
in the internal of the one2many.

Since the internal state is now always up-to-date, we can directly
read there the grid information, instead of looking inside other
fields that have been updated (attempt done in [1])

It would be nice to rethink the whole product configurator stuff
in master, to make it more robust, maybe when converting it to owl?

[1] https://github.com/odoo/odoo/commit/21bcafc053be7f80eed7a684fee2dc1e3caaafa5

opw~2421798

closes odoo/odoo#64683

X-original-commit: 69cadbe1be6320d96fe9bc5bf8dd808f87d735c0
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-01-18 12:39:24 +00:00
Francois (fge) cc67988241 [IMP] web: added option model_field to the reference field.
model_field: name of the FieldMany2One('ir.model') containing the model of the records that can be selected. If its value is different from False, the select will not be displayed.

The purpose of adding this option is to allow the creation of a reference field having its model defined in another field (Many2One).

Task-2195019
2020-12-11 09:11:11 +00:00
Achraf (abz) 61ae6a6ca1 [FIX] survey, web, web_editor, website, website_form: Prevent invalid date stock.picking
What are the steps to reproduce your issue?

1. Install "stock"
2. Go to Inventory/Inventory Overview/Internal Transfer
3. Create new record and set manually a date with year < 1000 like "0008-10-10 18:35:00"
4. Save
What is currently happening?

An error arises when saving the record, and it is then no longer
possible to reopen the records or any view containing it.
This also prevents us from correcting the date to no longer have the error
Why is this happening?

The root cause is an inconsistency in `strftime` for years < 1000 [1, 2]. To take it into
account, a zero-padding is needed in the DateTime parser.
How to fix the bug?

The missing padding is added.

However, such dates lead to problematic behaviors in Python:

```
DT_FORMAT = "%Y-%m-%d %H:%M:%S"
new_date = "0008-02-05 18:10:10"
datetime.strptime(
    datetime.strptime(
        new_date, DT_FORMAT
    ).strftime(DT_FORMAT),
    DT_FORMAT
)
```

This raises:
```
ValueError: time data '8-02-05 18:10:10' does not match format '%Y-%m-%d %H:%M:%S'
```

As of today there was no reported business cases where dates with year < 1000 would be
necessary. Therefore, we limit the range to years >= 1000.
[1] https://bugs.python.org/issue13305
[2] https://docs.python.org/dev/library/datetime.html#strftime-strptime-behavior

opw-2408260

closes odoo/odoo#62889

X-original-commit: b873bda1e560bc49ab707aa238fdc962f23bc1e4
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Signed-off-by: Achraf <abz-odoo@users.noreply.github.com>
2020-12-04 13:35:47 +00:00
Aaron Bohy 1d4d2a6831 [IMP] web: FieldMany2One: improve focusout case
Before this commit, when the user entered some text in a many2one
and then focused out (e.g. clicked outside), a dialog was shown to
ask him if he wanted to create such a value, no matter what he
wrote in the input.

After this commit, if the search triggered by the text he entered
returned records, the first one is automatically selected when the
focus is lost. However, if it matches no record, the dialog still
opens. The text in the dialog has been slightly reworded as well.

Task 2372480
Closes #61455

closes odoo/odoo#62677

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2020-12-02 09:10:24 +00:00
Aaron Bohy 608d3d87b2 [FIX] web: BasicModel: nested x2many and unknown fields
Consider the following situation:
 - have a form view with an x2many field displayed as a list
 - the x2many field has a form view that contains an x2many field,
   which isn't in the list
 - for that x2many field, we can also open a form view to see/edit
   the related records.

As the x2many field isn't in the list, when we open a subrecord, we
modify the fieldsInfo to add the information about the x2many field
we didn't know before. Doing so automatically applies raw changes
that we might have stored earlier (from onchanges) for that field,
 because we couldn't apply them before knowing the type of that
field.

Before this commit, the function that applies the raw changes was
called recursively on the dataPoint and all its children (thus on
the x2many list datapoint), which produced a crash as this function
is designed to work on dataPoints of type record.

Actually, calling it on sub datapoints is useless, as it properly
works recursively, and applies raw changes on x2many fields itself
when necessary.

This commit ensures that we don't call this function on list
datapoints anymore.

Closes #62334
OPW 2389991

closes odoo/odoo#62511

X-original-commit: 2b7670e6d709cd311c630c99cb9da7d3d6ae90f4
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-11-27 11:13:08 +00:00
Aaron Bohy 28762b79e3 [FIX] web: race condition with x2many control panel
The ControlPanel has been converted in Owl [1], and the code using
it has been adapted accordingly. However, in the FieldX2Many, we
didn't properly wait for the ControlPanel to be updated (an update
of the ControlPanel was synchronous before owl, and is now async,
like every Owl renderings, as it waits for the nextAnimationFrame).

As a consequence, we might have tricky issues because the mounted
hook of the control panel might be called multiple times for a
single call to willUnmount later on. In mobile, we bind a global
event handler (on scroll) in mounted, and unbind it in willUnmount,
so we had leftover event handlers, that crashed when called after
the ControlPanel was destroyed. Note that even if the issue popped
in mobile, calling mounted on already mounted Components isn't a
good idea, and this should be fixed anyway.

The issue could be reproduced for instance in FieldService (with
collaborative pads activated in Project), in mobile, by opening
a task in Edit mode. Then, you might get a traceback by scrolling
after having discarded the edition

Here is a description of what technically happened:
 - when clicking on Edit, all widgets (including the FieldX2Many
   are destroyed and re-instantiated in 'edit' mode).
 - the pad widget directly triggers a field_changed event which
   causes a reset of the FieldX2Many (i.e. 'render' is called
   again)
 - the FieldX2Many detects that it already has a renderer (and a
   ControlPanel) so it updates them
 - it first updates the renderer, and when it's done, it updates
   the ControlPanel BUT doesn't wait for its promise, so the
   promise returned by that call to 'render' in FieldX2Many is
   resolved before the ControlPanel is actually updated
 - note that at this point, all thoses new widgets are not in the
   DOM yet
 - when all widgets are ready, the renderer patches the view (i.e.
   the former content is removed from the DOM, and the new one is
   attached into the DOM). As soon as this is done, the renderer
   calls 'on_attach_callback' on its children, including the
   FieldX2Many, which leads to a call to 'mounted' on the CP.
 - then, just before the nextAnimationFrame, Owl complete the
   rendering of the CP, and detects that it is now in the DOM (it
   wasn't at the beginning), so 'mounted' is called a second time,
   will cause the issue described above.

This commit fixes the issue by properly waiting for the CP to be
rendered in the FieldX2Many. However, this required on cascade
changes:
 - Form view renderings with a FieldX2Many are now *really* async
   (+- 16ms), meaning that the user can easily trigger concurrent
   renderings by, e.g. clicking quickly several times on 'Edit',
   'Save' or 'Discard'. Concurrent renderings are properly handled
   so to prevent this from happening, we disable the buttons and
   re-enable them when the rendering is done (like already done in
   [2])
 - in the FieldX2Many, '_updateControlPanel' was called at several
   placed, but we never waited for it. As this method was
   originally sync, its calls have probably been naively adapted,
   whereas their should have been deeply rethought (for instance,
   as it is async, and we need to wait for it, we don't want it
   to be called multiple times sequentially when something happens).
   This commit does that work, i.e. we clean the places where this
   function is called such that it is (hopefully) never called
   sequentially twice. To do so, we changed a bit the spec of the
   pager in multi page, and we also fixed a paging-related  bug.
   In a few words, here is what we did/do when adding a new row
   in the bottom of a full page:
     - before: tweak the count in the data to fool the pager and
       make it think that no new record has been added (so
       basically, let it display something wrong)
     - now: temporarily increase the pager limit so that the new
       record is displayed on the current pager, and the pager
       values are correct w.r.t. the displayed records.
    Some tests needed to be adapted accordingly.
 - By waiting for the ControlPanel when updating the FieldX2Many,
   a bunch of QUnit tests failed. Those tests have something in
   common: they spawn an X2Many (list or kanban theoretically,
   but always list in practice) containing a FieldBoolean (only
   field widget of /web converted in owl). When the FieldX2Many
   is updated, we update the renderer (i.e. re-renderer the
   FieldBoolean, so we have to wait for the nextAnimationFrame),
   and when this is done, we update the page (again, we have
   to wait for the nextAnimationFrame). So basically, we have
   to wait for two nextAnimationFrames to see the result in the
   DOM. For this, we added a new test util which basically does
   a nextTick ('owlCompatibilityNextTick'), and called it
   everywhere it was necessary. When everything will be written
   in Owl, we could get rid of this util and its calls.

[1] https://github.com/odoo/odoo/commit/fbf347498f1cc7b74ef373179b7bcae201715c24
[2] https://github.com/odoo/odoo/commit/39f08950d6e20460e3a20a5b9c33e4ddf66dce78

closes odoo/odoo#61926

X-original-commit: e8e64f75606f1501a8be7b0bb418a296cfd8be61
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-11-18 12:18:30 +00:00
Martin Trigaux c59c10f1bc [FIX] *: correct typos and bad English
Courtesy of translators
Reexport .pot of modified modules

closes odoo/odoo#61010

X-original-commit: 62a18bdb372e234107fd2099a2df5f9e3a442c96
Related: odoo/enterprise#14489
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-10-29 19:23:41 +00:00
Nicolas Martinelli c0501bf54c [FIX] web, doc: remaining_days widget
The `remaining_days` widget is intended to be used for informative purpose,
hence it should not be editable.

opw-2362276

X-original-commit: 4c72b1536a19cd517046113a5ad93b5782774664
2020-10-20 06:08:32 +00:00
Prakash Prajapati 1edd61c160 [IMP] web: The float_toggle widget button appear in the kanban view
Currently, float_toggle widget is not applied in kanban view because kanban
the view has read-only mode.

So in this commit, enable the button to the kanban view.

closes odoo/odoo#53782

Task-id: 2264613
Related: https://github.com/odoo/enterprise/pull/11497
Related: odoo/enterprise#11497
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-09-23 09:48:15 +00:00
Priyanka Kakadiya 5d7165d4f2 [FIX] web: send utc date to server from daterange widget
When manually updating the time on a daterange widget, the value sent to the
server is not converted to UTC and is sent as it appears on the input.

currently daterange widget send datetime value as it is, written in input field
if manually entered, so if user set 10:00:00 so while sending data it will be
send as it is 10:00:00 so when next time record reloaded after save, it will
display 15:30:00 if timezone UTC+5:30.

Instead, change the string date to moment object with current user timezone.
so that datetime send to server is UTC time and when next time it is loaded
it adds user timezone difference, so if timezone is UTC+5:30 and user enters
10:00:00 then while sending data to server it sends 04:30:00 and when displayed
again after reload it adds +5:30 timezone difference.

LINKS

PR #50132
Task 2240378

closes odoo/odoo#59263

X-original-commit: a029fca2d0def06ea3f67270f0e1d654d49a0c57
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-10-06 12:27:26 +00:00
Mohammed Shekha 6dd4aca6b4 [FIX] web: do not allow to edit priority field if readonly
if readonly attribute is given on priority widget then priority widget should
not be clickable and hover effect should be removed so that user can easily
understand that field is readonly.

task-2339680

closes odoo/odoo#59199

X-original-commit: 53dbfc7a65a8eb2f41d6b2373cf628c4800d1f57
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-10-06 08:18:22 +00:00
Bruno Boi e654b32bc1 [IMP] web: use user's decimal separator for numeric fields
Until now, the numpad decimal key was not properly handled for some
keyboard layouts.

This commit will ensure that when this key will get pressed inside a
numeric field, the user's display language decimal separator will get inserted.

closes odoo/odoo#56962

Taskid: 1913999
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2020-10-05 08:21:00 +00:00
Simon Genin (ges) 2cb2e9c2a2 [FIX] web: reference field calls name_create
An older commit (50bf8309) had refactor part of the basic field _applyX2ManyOperations.
During this refactor, the reference field was forgotten to be included
in a condition that made the field no longer do the quick create behavior.
The name_create function in the backend was no longer called.

Adds a test for the reference field checking the call to the name_create
function and fixes the problem.

Task id 2322048

closes odoo/odoo#59044

X-original-commit: 1400b0b9f46a86254c166b422a0b23ed3b3c7a24
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-10-03 11:08:35 +00:00
Aaron Bohy 36da1799b5 [FIX] web: list: call mounted on subcomponents at reload
Issue was spotted in list views containing the "badge" widget with
decorations (e.g. in the Purchase Order list view). At first, the
decorations were correctly applied, but they weren't anymore after
a reload (e.g. after toggling a filter).

They weren't because the list renderer didn't called
'on_attach_callback' on its subwidgets at reload (thus, 'mounted'
wasn't called on its subcomponents, and the decorations are applied
in the mounted hook).

This commit moves the logic from the FormRenderer to the
BasicRenderer, so that it applies on List, Kanban, and Form views.

This commit also removes the transition scss rule on the badge
field widget as it caused a flickering at reload.

Task 2336440

closes odoo/odoo#57766

X-original-commit: 713bce22e8f412f2c26e663b9e30fdd64933ff0c
Signed-off-by: Michaël Mattiello <mcm-odoo@users.noreply.github.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-09-16 05:59:27 +00:00
Nisha patel 22c52e8edf [IMP] web: Prevent the dialog for x2many readonly list view
Currently, dialog is generic for all x2many tree and there is no
option to prevent the dialog in readonly for x2many tree.

So in this commit, we add new option 'no_open' for x2many tree to
prevent the dialog.

closes odoo/odoo#55255

Taskid: 2295969
Closes: #55255
Related: odoo/enterprise#11994
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-08-27 11:00:19 +00:00
wan 421acfcbb2 [IMP] web: add the raw value of selection fields
Task 2327599

It is used in the selector of a tour to know the type of a document.
2020-09-10 12:32:21 +00:00
Simon Genin (ges) 618067aa3f [IMP] base: Document layout preview improvements
The document layout preview is a complete defferent simplified template
with its own css that replicates at best the different styles.
It does not have the external layout features and lack of fidelity.

The new preview actually use the real documents templates and put the
result in an iframe. It now has a high fidelity, though not perfect.

The goal is for a better onboarding, where clients see easely how
documents will look if they had an app to generate them. Of course, the
data on the document is a false invoice.

Refactor all this from base to web.

Task ID 2304177

closes odoo/odoo#56995

X-original-commit: c121a246f16899735306266a3a12b526e08e7620
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2020-09-03 08:44:35 +00:00
Victor Feyens 1aa874aab3 [IMP] web: new widget for static image urls in char fields
This new widget allows definition of Images through static urls stored in a Char field.
It was implemented to provide a way to reduce databases footprint by using
static files instead of duplicating them in the databases (& their backups).
2020-09-02 13:57:23 +00:00