Commit Graph
723 Commits
Author SHA1 Message Date
Joseph Caburnay 259cf45346 [FIX] web: trying to create record based on name_create w/o _rec_name
There are orm models that don't have _rec_name defined. The orm doesn't
allow creation of record via name_create if _rec_name is not defined in
the model. This commit considers this fact, such that if name_create
returns false, we don't proceed on displaying the non-existing record.

Note: _rec_name defaults to 'name' if not specified so only few models
don't have _rec_name.

closes odoo/odoo#54270

Task-id: 2285036
X-original-commit: 676c2b8e4fdf7347d44bc5afb7ca51d39338a527
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-07-09 12:43:36 +00:00
Aaron Bohy 61a3a4d52d [FIX] web: list: buttons with attrs column_invisible
Since commit 042b4060bd, attrs 'column_invisible' on button was
ignored. This commit makes this work alongside the adjacent button
grouping feature: if all adjacent buttons have their attrs
column_invisible evaluated to true, no column is rendered for this
group of adjacent buttons.

closes odoo/odoo#53489

X-original-commit: 3110e34ab8e5ec3bf7160655af21f72b4d2179db
Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-06-23 09:03:34 +00:00
Parth ChoksiandMohammed Shekha e6730c6e92 [IMP] web: better positionning of daterangepicker
Before this commit, the daterangepicker always opened below the input,
even when there was not enough space to display it. Moreover, when the
user scrolled while the picker was opened, it wasn't stucked to the
input, so the picker was displayed at a random position after the
scroll.

With this commit, we compute the available space above the picker
when opening it, and if there is enough space, we display it above,
otherwise, we display it below. Moreover, we automatically close
the picker when the user scrolls.

task-2117229

closes odoo/odoo#42161

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Mohammed Shekha <msh@odoo.com>
2020-02-27 07:51:43 +00:00
4197ebfabc [IMP] web: add options to formatFloatTime
This commit adds noLeadingZeroHour option to formatFloatTime.
The noLeadingZeroHour option can be used to format the value
like 1:30 instead of 01:30

This format behaviour is wanted for fields in web_grid module.

Task 2261853

closes odoo/odoo#52217

Related: odoo/enterprise#10870
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Hardik Prajapati <hap@odoo.com>
Co-authored-by: Mohammed Shekha <msh@openerp.com>
2020-06-15 13:53:21 +00:00
Aaron Bohy b4ba0fc340 [FIX] *: adapt tests to env rework
This commit adapts tests following recent changes on the helpers.
The main change is that addMockEnvironment (and all functions using
it) are now async, as they need to wait for services to be started.
2020-06-12 09:47:48 +00:00
Julien Mougenot c4786fccfd [IMP] *: update notifications to optional title
closes odoo/odoo#52826

Related: odoo/enterprise#11084
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-06-12 09:01:50 +00:00
eacbec1e03 [IMP] web,*: highlight quick create feature to user
Generally, Users are not necessarily aware that they can quick create a most
records by simply typing in their name+enter in the many2xxx field input.
The exact purpose of this commit is to make sure the user discovers the quick
create feature of our many2xxx fields.

For that, when the input is empty, display 'Start typing to create a record...'
at the bottom of the dropdown when can_create is set and no_create_edit option
not set. So the user can easily understand that by typing and pressing enter
will create the new record.
Also "Search and Create" options in the dropdown only been shown to the user
when it type anything in the input box as the same case in the "Create" option.

Task : 2266557

Co-authored-by: Mohammed Shekha <msh@openerp.com>
Co-authored-by: Julien Mougenot <jum@odoo.com>
2020-06-10 13:08:33 +00:00
Nicolas Lempereur 9d40ec7d15 [FIX] web: resquencing stop at first controller
When a resequencing is done inside an object hierarchy of two
controllers, since 9b90d8727d we would call resquencing code one time
per controller.

So if for example we are in a list view inside a form view (eg. a
"Search More" modal in a form view) the resequencing would work for the
list view, but then cause traceback when it is handled by form view.

With this changeset, the first controller that get the event
`resequence_records` even gobbles it up.

Without change, added test fails because of original traceback:

  Cannot read property 'res_id' of undefined@ 202 ms
  Source:
   TypeError: Cannot read property 'res_id' of undefined
    at /web/static/src/js/views/basic/basic_controller.js:744:67
   ...

opw-2256818
closes #51827

closes odoo/odoo#52018

X-original-commit: eef4b99fdb9469c040af80d055933eda367b7b3d
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2020-05-27 16:56:19 +00:00
qsm-odoo 57ec9049e2 [MOV] web: rename colorpicker_dialog.xml file
The ColorpickerDialog will become a widget, this commit is only about
renaming the related XML file.

Part of https://github.com/odoo/odoo/pull/46088
task-2195313
2020-05-14 22:44:28 +00:00
efe10976a4 [FIX] web: correctly update input field after onchange
In a form view, have an x2many list with two fields A and B (e.g.
A is a many2one, and B is a char). There is an onchange on the
x2many that is triggered when the user sets A, and that sets B.

In this scenario, let's assume that the user first writes something
in B, but directly deletes it. Then, he sets A. Before this commit,
in this situation, B wasn't updated with the value returned by the
onchange.

Indeed, B's field widget was still flagged as 'isDirty', because
the user interacted with it, but it didn't commit its value, as it
hasn't actually changed. Basically, it remained flagged as 'isDirty'
forever, and thus couldn't be updated with the value returned by
the onchange.

This commit ensures that the 'isDirty' status is correctly updated
when the change is actually undone.

Task 1958793

closes odoo/odoo#51085

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
Co-authored-by: pka-odoo <pka@odoo.com>
Co-authored-by: Mohammed Shekha <msh@odoo.com>
2020-05-12 13:43:53 +00:00
Aaron Bohy e02a4b93e5 [IMP] web: add more accurate test on onchange scenario
In a form view, have an x2many list with two fields A and B (e.g.
A is a many2one, and B is a char). There is an onchange on the
x2many that is triggered when the user sets A, and that sets B.

In this scenario, let's assume that the user first writes something
in B, but directly deletes it. Then, he sets A. In this situation,
B isn't updated with the value returned by the onchange.

Commit [1] is an attempt to fix this, but it actually broke what
has been done in [2]. However, tests of [2] still passed, because
they didn't accurately reproduce what happens in practice (outside
the test environment).

An input field widget listens to 'input' and 'change' events. It
commits its value when both occur, but in the 'input' case, the
action is debounced with a large value (so that it actually only
commits the value on 'change', i.e. when the field is focusset
out). In the tests, the debounce value is 0, so fields actually
commit their value directly when 'input' events occur. This is
something we may want to change in the future, to remove this
discrepancy.

This commit adds a test with a large debounce value, so that we
accurately test what happens in practice, and we make sure that
this won't be broken in an attempt of fixing something else.

[1] cdca11db2ec207363df1d4fb3c87014d9c931d25
[2] a71f223702

Related to task 1958793
2020-05-12 13:43:39 +00:00
Aaron Bohy 8000e895cd [FIX] web: failing quick create in m2o inside x2m
Write something in a many2one field, and click on 'Create "..."'
to quick create a record with the given value (name_create). When
the name_create fails (e.g. because there are mandatory fields in
the model), we open a form view.

Before this commit, when this happened for many2one fields inside
x2many editable lists, it crashed, since [1].

[1] 50bf8309f8

closes odoo/odoo#50948

X-original-commit: 43c513306094444ff25ad98584b426ddb8a3b525
Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-05-08 15:38:06 +00:00
Dhruv Patel a599f1402e [IMP] web: FieldMany2one: reword and simplify dialog
This commit improves the dialog that opens when a user clicks out
of an 'un-commited' many2one. It is no longer possible to edit
the value, and the sentence has been reworded.

closes odoo/odoo#49528

Task: 2234212
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-05-05 15:19:45 +00:00
Aaron Bohy df4693e7ff [IMP] web: add Many2OneAvatar field widget
In readonly, this widget displays the image of the related record
next to its display_name. In edit, it behaves exactly like the
regular many2one.

Part of task 2195254
2020-05-05 10:05:12 +00:00
Aaron Bohy 4f8860e503 [IMP] web: add RemainingDays field widget
This widget can be used on date and datetime fields. In readonly,
it displays the delta (in days) between the value of the field and
today. In edit, it behaves like a regular date(time) widget.

Part of task 2195254
2020-05-05 08:48:34 +00:00
Aaron Bohy 1d6e4948d2 [IMP] web: add BadgeField component
This new field component displays the field's value inside a
bootstrap pill badge. Supported field types are 'char', 'selection'
and 'many2one'. The background color of the badge can be customized
by using the decoration-xxx mechanism, e.g.
 <field name="state" decoration-danger="state == 'cancel'" widget="badge"/>

Part of task 2195254
2020-05-05 08:48:34 +00:00
jvm-odoo a7ee8bc79b [FIX] web: fix can't open date picker on graph views
Issue

	- Install CRM
	- CRM > Reports > Activities
	- Add a custom filter > Created on
	- Select the date

	You can't, the date picker is not shown

Cause

	Actually, the date picker is shown but
	very quickly and it is closed by a scroll
	event thrown by Chart.js.

Solution

	Close the date picker only if the user
	scrolls manually.

OPW-2245019

closes odoo/odoo#50482

X-original-commit: bda320052ac937f5bc17c7da81d84633d72a8370
Signed-off-by: Jason Van Malder (jvm) <jvm@odoo.com>
2020-04-30 14:35:08 +00:00
Lucas Perais (lpe) 4c1feefd13 [IMP] web: Numeric fields can be non-formatted
This commit introduces a new option in fields inheriting from type Numeric
which is `format`.

By default, Numeric fields are formatted according to their subtypes and locale
Adding, in a view, the option format set to a falsy value
will prevent the field's value from being formatted.

```
<field name="int_field" options="{\'format\': false}"/>
```

Task 2050119
2020-04-17 13:56:08 +00:00
Dhruv Patel dafba22a6c [FIX] web,mail: many2many_tags_email: increase limit
A long time ago, commit [1] increased the limit of displayed badges
inside a many2many_tags widget, from 40 to 1000 (a large limit that
should never been reached with such a widget).

However, this solution was specific to the many2many_tags widget,
and didn't apply to its extensions (like the many2many_tags_email
widget). For instance, open the chatter full composer, add 40
partners in the recipients field and try to add one more: nothing
happens.

This commit sets the limit on the widget itself. That way,
extensions automatically have the same limit, and can override it
if needed.

[1] d4cf4374d1

Task : 2091027

closes odoo/odoo#49488

X-original-commit: 02e41f1131b4ea3ad977cc241a3d447c37195f6e
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-04-14 08:47:15 +00:00
Mohammed Shekha 2b776cbbb5 [IMP] do not propagate default_* key from parent context to sub view
before this commit: from commit: https://github.com/odoo/odoo/commit/d58d6e270f4106d717821438490f60bc4f71306e parent context
was propagated to sub views, propagating whole context to sub view creates
issue as it contains default_* key inside it, there is a chance that sub view
has same field name which matches with default_fieldName in context,
e.g. go to sale order form view and create sale order line, while selecting
product, write in product_id field so that Create and Edit option comes,
select Create and Edit option, so whatever previously written in product_id
field will be added in product.product form's context as default_name,
now go to Purchase tab of product form and try to create Supplier, but note
that Vendors One2many should be editable, if it is not then to produce this
issue, make Vendor o2m list editable top/bottom, as soon as you click on
Vendor o2m's create button traceback generated which comes from name_get of
res.partner, issue raised because vendor o2m has m2o of res.partner and field
name is 'name', when default_get for vendor o2m is called it will propagate context
and context has default_name='typed string in product_id', as name field is
m2o with res.partner it will generate traceback as m2o accepts (id, name) tuple
not string

after this commit: propagate context to sub view but remove default_* keys
from parent context

task-2121161

closes odoo/odoo#49075

X-original-commit: 2e3756e0ce96a9e0c5fa304632a2600cbd832ef5
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-04-06 14:42:34 +00:00
Michael Mattiello (mcm) 4520a09f2c [REF] web: convert FieldBoolean to owl
This commit does 4 things:
- adds a file for deprecated legacy fields.
- moves legacy FieldBoolean into this file.
- converts FieldBoolean to owl component.
- adds a new xml file for component fields' templates.

task id: 2193996
2020-03-31 07:11:01 +00:00
Mohammed Shekha 5353fb2496 [IMP] web: trim FieldEmail widget value
before this commit, email widget was not trimming value and due to which
space aroung email value remain as it is added by user.

after this commit, email widget will trim the value and remove leading/trailing
space.

task-2197432

closes odoo/odoo#47470

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-03-24 08:02:13 +00:00
Aaron Bohy f6c06bd0b8 [FIX] web: nested x2many with non inline views
Let's assume a form view with an x2many list, containing itself
an x2many field (no widget, so simply displaying the number of
records). When a record of the list is clicked, a form view
opens and displays the same sub x2many field, with widget
many2many_tags. Both list and form views of the x2many aren't
inline (thus have to be fetched on demand).

Before this commit, it crashed when the user clicked on a row
of the x2many list.

The bug has been introduced by a9cebd5a, which wrongly removed the
code handling this specific situation. At least, now we have a
test attesting that this code isn't useless.

Note that the diff isn't as scary as it looks like (we just added
an if/else, and thus indented the former code inside the else
clause).

closes odoo/odoo#48116

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2020-03-20 13:40:42 +00:00
Julien MougenotandMathieu Duckerts-Antoine 804507ef49 [REF] *: Adapt all module tests to the new control panel
Use of the new control panel helpers to increase consistency and change the assertions
according to the new DOM/behaviour (e.g. components removed instead of turning invisible).

Part of task 2196029

Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
2020-03-13 14:08:33 +00:00
Aaron Bohy f692a39677 [FIX] web: FieldMany2ManyTags: failing quick create record
The FieldMany2One allows to quick create record (name_create).
However, sometimes, required fields on the co-model make the
name_create crash. In this case, the FieldMany2one opens a form
view in a dialog to let the user specify those fields, and create
a new record with the 'create' method. This was working fine.

The FieldMany2ManyTags embeds a FieldMany2One to let the user
search for and select or (quick) create tags. In this case, failing
quick creation didn't fallback on the dialog form view, but
displayed a server error instead. This commit fixes this issue.

Bug introduced by 50bf8309f8

Task 2192754

closes odoo/odoo#47183

X-original-commit: 63ab065f3298c13bb19ae1245d7fd2652581b254
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-03-09 10:31:01 +00:00
Aaron Bohy 43ce727568 [FIX] web: save all values returned by onchange
Let's assume a form view with a boolean field and a one2many field,
displayed for instance with widget many2many_tags. There is an
onchange on the boolean field, which populates the one2many, e.g.
  [[5], [0, 0, {display_name: 'name', other_field: 'value'}]]

Before this commit, only the display_name was sent to the server on
save, because 'other_field' is unknown by the webclient.

Similar situations occurred with one2manys displayed as lists, and
onchanges returning values for fields that aren't in the list.

These situations probably didn't exist in Odoo yet, but a pending
task on website event adds one.

This commit ensures that all values returned by the onchange for
the x2many subrecords are sent back to the server when the user
saves.

closes odoo/odoo#46807

Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2020-03-09 14:14:39 +00:00
Aaron Bohy f894b6a1d8 [FIX] web: x2many: use correct viewType
This commit fixes two issues that occurred in the following
situation: in a form view, have a one2many field F1 displayed as a
list, that contains another one2many field F2, displayed with
widget many2many_tags (in the list), and with a list in the form
(in the dialog). In the dialog, the list of F2 displays a
field, say 'name', which has an onchange that sets 'display_name'.
Moreover, there is an onchange in the (main) form view, that
populates F1 and F2, for instance, it returns something like: {
  F1: [[5], [0, 0, {
       F2: [[5], [0, 0, {
            display_name: 'xxx',
	    name: 'xxx',
       }]]
  }]]
}

1) If the user opens a related record in F1, and adds (in the
dialog) a related record in F2, then validates the dialog, the
newly created record in F2 isn't correctly displayed in the
many2many_tags (the display_name is `false`), i.e. the onchange
hasn't been applied.

2) If field 'name' in F2 in the list is required, the new record
can't be saved, even if the user enters a correct value.

In both cases, the reason is that we use the incorrect viewType in
datapoints: as we don't specify that we specifically want 'list',
the 'default' one is taken, and we thus use the fieldsInfo of the
many2many_tags, which only knows field 'display_name'. As a
consequence, onchanges aren't correctly applied (issue 1), and
fields aren't correctly reset (issue 2).

Issue reported on task 2189529
2020-03-09 14:14:39 +00:00
Aaron Bohy 8a52f10ceb [FIX] web: BasicModel: always set a valid limit
When x2many fields are displayed with widgets like many2many_tags,
there is no limit on the number of related records to fetch and
display. In this case, the 'limit' attribute on the datapoints is
undefined. This could lead to weird issues when the limit is used
in computation, e.g.
  var index = list.offset + list.limit; // = NaN

There are several occurrences of the above examples in the code,
which can be observed in specific scenarios, e.g. the one encoded
in the test. In this scenario, when the bug occurs, new records
added to editable list views are inserted on top (even if the list
is editable="bottom"), but the edited row is the last one.

Issue reported on task 2189529
2020-03-09 14:14:39 +00:00
Aaron Bohy a9cebd5acb [FIX] web: handle nested one2manys and onchange
Let's assume the following scenario in a form view:
 - have a one2many field, say fieldA, displayed as a list,
   containing another one2many, fieldB, (no widget, thus
   displaying 'n record(s)')
 - the one2many list is not editable, so there is a sub form view,
   displaying fieldB as a list, and in this list some random field,
   say fieldC, is displayed
 - have a random field on the main form view, with an onchange to
   populate the one2many
 - set that random field s.t. the onchange returns something like
   fieldA: [[5], [0, 0, {fieldB: [[0, 0, {fieldC: 'value'}]]}]]
 - there is now a record in fieldA's list, displaying '1 record'
   as value for fieldB
 - click on that record to open it in a form view (dialog)
 - in the dialog, in fieldB's list, we expect to have a single row
   displaying 'value' as value for fieldC

Before this rev., it crashed when opening the record in the dialog,
whether the form view was inline or not.

The crash occured because fieldB was already in the list view, so
datapoints already existed for it (a list datapoint, and record
datapoints for records in the relation, in our example one record
datapoint). However, those datapoints didn't have the fieldsInfo of
the form view. When opening the form view, we added the fieldsInfo
of the form to the datapoint of the record we opened, but we didn't
recursively apply the fieldsInfo to its children. As a consequence,
when rendering the list view for fieldB in the dialog, we haven't
the information about fieldC, and it crashed.

Note that if fieldB wasn't present in fieldA's list view, it worked
fine because datapoints didn't exist before we opened the record in
the dialog.

Task 2120235
2020-03-09 14:14:39 +00:00
Mohammed Shekha a4a4ad1a39 [IMP] web: trim many2one search terms
This commit trims leading and trailing spaces in search terms of
many2one.

task-2187414

closes odoo/odoo#45282

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-03-04 14:46:18 +00:00
Lucas Perais (lpe) 8fd69c44f2 [FIX] sms, web: phone widget with sms tested in right module
Before this commit, the behavior of the phone widget was tested in web
as if it was always altered with module SMS
Giving wrong test results when sms module was not installed

After this commit, the separation is clearer, and the phone widget's
behavior is tested according to the modules it is altered by

closes odoo/odoo#45271

X-original-commit: 2e337516468797dd898c79c9669b5a90c83b56a7
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2020-02-13 10:18:33 +00:00
Michael Mattiello (mcm) c5e34d77f5 [IMP] web: show % symbol outside the input in percentage widget
Before this commit the % symbol was part of the input. We could write a
value with the % symbol to divide the value by 100 (50% = 0.5, 50 = 50)

This commit removes the % symbol from the input and adds it in a span
after the input so we do not need to write the % symbol anymore.

The value from the input will be saved as $value / 100 in database.

task-2065078

closes odoo/odoo#43995

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-02-06 11:55:13 +00:00
Lucas Perais (lpe) c98579d25a [IMP] web: many2many list editable as m2m_tags
Before this commit, there was a discrepancy between
many2many_tags widget and regular many2many list

That is, in tag mode, when someone had read access alone on the comodel
he could modify the members of the m2m relation on the current model
Which couldn't be done in m2m list

After this commit, it is possible in a m2m list to add
records to a relation, even if we don't have CRUD access on the comodel

Task 44074

closes odoo/odoo#40194

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-02-06 10:19:00 +00:00
Dhruv Patel d5d2c5524c [FIX] base,web: url widget: add protocol in href
With this commit, the url widget automatically prefixes the href
url by http:// if no protocol is specified, so that clicking on
the url will by default redirect to an external website.

To prevent this behavior, one can still specify the new option
'website_path: true' on the url field node in the view arch.

Thanks to this, we can remove a similar logic (only implemented on
res_partner model) which automatically altered the value saved in
database to force its 'http://' prefix.

task-2153184

closes odoo/odoo#42118

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-01-30 14:03:36 +00:00
Debauche Stéphane 75f7ab0608 [FIX] web: fix email and phone widgets with empty value
When the value is empty in a related field, string of the element was
displaying "false" instead of an empty string which is not what we expect.
This commit fixes that issue.

Task ID 2119333
PR #40949
2020-01-28 09:14:43 +00:00
Lucas Perais (lpe) d41d627569 [IMP] web: field phone widget deals with SMS by default
Task 2123526

Before this task, the phone widget on char fields was not
displaying the send sms button by default

After this task, the default behavior of the phone
widget is to display the send sms button
2020-01-27 09:31:52 +00:00
Mohammed ShekhaandAaron Bohy 23878ee11a [IMP] web: always display statusbar widget
By default, in readonly, unset field widgets (and their labels) are
not displayed. However, we would like the statusbar widget to be
always displayed (even when it is not set).

This commit introduces a new method 'isEmpty' on AbstractField, and
uses it (instead of isSet) to determine whether or not a field should
be hidden. By default, it uses isSet, so that it doesn't change
anything for the other fields, and we override it in statusbar to
always return false.

There was a need to make the distinction with isSet, as this one is
used to determine if a record can be saved (if the field is required,
and isSet returns false, it can't be).

task-2172272

closes odoo/odoo#43419

Related: odoo/enterprise#7929
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Aaron Bohy <aab@odoo.com>
2020-01-27 09:01:19 +00:00
370f53d8dc [IMP] web: conditional create/delete options on x2many fields
After this commit, x2many fields can have options like
create/delete which accept a domain, to make create/delete on
x2many conditional, say for example x2many field can have options
like:

options="{'create:' [('foo', '=', True)]', 'delete:' [('foo', '=', True)]'}"

With this when foo field is True, Create and Delete actions will
be available, but if foo is False then they won't.

In case of one2many fields, if 'create' is false, then 'Add a line'
(list) or 'Add' button (kanban) won't be displayed.

In case of many2many fields, 'Add a line' or 'Add' button will
always be displayed even if 'create' condition is false as it
doesn't really create records (but rather links existing ones).
Same applies for delete.

Task-2092953

closes odoo/odoo#42919

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Parth Chokshi <pch@odoo.com>
Co-authored-by: Aaron Bohy<aab@odoo.com>
2020-01-22 13:01:33 +00:00
Aaron Bohy 50bf8309f8 [FIX] web,*: fix race condition with m2o quick create
*sale,sale_product_configurator

Let's assume a form view containing a many2one with an onchange
that updates the value of a one2many. Do a quick create in the
many2one. While the name_create request is pending, add a row to
the one2many but do not leave it. When the name_create returns, and
the onchange has been performed, the one2many is reset, and the row
is no longer in edition (worse, it could be invalid, i.e. in a state
that the user could not have reached in a normal situation).

This commit fixes this issue by considering the whole [name_create +
onchange] operation as one. This operation is executed in the mutex
of the model, so the other request (adding a row to the one2many) is
delayed until the many2one value has been correctly set.

This fixes an issue with the sale and rental tours (on sale_order),
that had been deactivated for a while.
2020-01-21 11:59:22 +00:00
Andrea Grazioso (agr-odoo) bbe944c829 [FIX] web: avoid parsing value if already number
When accessing stock_barcode module to validate pickings, is not
possible to add floating point quantities for any localizaton which uses
',' as decimal separator.
The numeric field is now defined via browser tags <input="numeric"> to
make the numeric keyboard popup automatically on mobile devices
(commit 8f5840369b28962ab2be9edfce7331a836c3df22)
Adding the override to avoid further processing when the input
is already anumber

opw-2154657

closes odoo/odoo#42748

X-original-commit: 1ccc60deeb067f8d461d48cbf51719317c22cb90
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2020-01-06 12:16:10 +00:00
Carlos MayoandAaron Bohy 9f49709ef3 [FIX] web: many2many_checkboxes: react to domain changes
Let's assume a many2many_checkboxes widget in a form view with a
dynamic domain (depending on another field in the view). At first
rendering, the widget contains a checkbox for each value matching
the domain.

Before this rev., if the user changed the value of the field used
in the domain, the many2many_checkboxes wasn't redrawn, so it still
displayed the values matching the previous version of the domain.

Closes #38509
Closes #40173

closes odoo/odoo#42867

X-original-commit: 1ace56f9a8cb56fb39235468dd13447bcbbee40a
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Aaron Bohy <aab@odoo.com>
2020-01-07 14:37:06 +00:00
Vincent Schippefilt 89f213001f [REM] web: remove useless and buggy test.
Removing the test "field changes are correctly debounced in text fields"
because it doesn't represent the reality that fields are not debounced
anymore in production code.

This test was nondeterministic.
2019-12-12 13:22:19 +00:00
b0941d19a0 [FIX] web,*: fix all tests and test utils to use native events
In this commit:
- transformed test_utils helpers to always trigger native events
- introduced new test_utils_create helper: prepareTarget
- updated qunit asserts to support Owl Components
- updated all misused helpers that would crash with the updated test_utils

Co-authored-by: Julien Mougenot <jum@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: Pierre Rousseau <pro@odoo.com>
2019-12-09 11:09:10 +00:00
Kevin Baptiste 6cbe824871 [REV] web: reverts update to fontawesome 5.11.2
This reverts commit ff1c35513a.

closes odoo/odoo#41480

X-original-commit: 116057b26e71db4692280463669f3e80d813ddcc
Related: odoo/enterprise#7110
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-12-09 10:33:36 +00:00
Kevin Baptiste ff1c35513a [IMP] web: update to fontawesome 4.7.0 to 5.11.2
FontAwesome 5 introduced new names for some icons as described on
https://fontawesome.com/how-to-use/on-the-web/setup/upgrading-from-version-4#name-changes

This commit replaces the old names to the new ones.

closes odoo/odoo#35826

Taskid: 2050241
Related: odoo/enterprise#5180
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-11-28 10:05:12 +00:00
Aaron Bohy 8aba4cd406 [FIX] web: handle m2o whose comodel name field is an m2o
This is a weird situation, but the python handles it. Let's assume
a many2one field F1 on model M1 with comodel M2, and on M2 the name
field (which is the _rec_name) being itself a many2one, and the
following scenario:
 - create a new record for M1
 - for field F1, select 'Create and Edit': it opens a form view for
   M2 in a dialog
 - type something in F2 input, and click 'Quick create'
 - save the dialog

Before this rev., the value of F1 was [object Object]. Now, the new
value is properly displayed.

OPW 2091106

closes odoo/odoo#40549

X-original-commit: 5a04ea848abf50b1fb1f9893d1fcd98013bc025d
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2019-11-20 10:39:29 +00:00
svs-odoo c5fbb9cc23 [IMP] web: add widget signature
Adding a new widget to display a sign button in the form view.

task-1878607
2019-10-28 10:46:06 +00:00
Julien Mougenot e8d300723f [FIX] web: list: recompute default values for columns when visible
Before this commit, all the computation of the default widths for column
headers was done before the list was attached to the DOM, meaning that no
column was actually visible. This was a problem since columns that are
meant to stay unseen were taken into account in the calculation of relative
column widths.

Now, the same algorithm runs once the columns are visible so that invisible
columns can be properly excluded.

fixes #38744

Task 2076721

X-original-commit: 4bf98b47898b075049975dfe597f0fb92c7c14d1
2019-10-24 06:39:46 +00:00
Debauche Stéphane e981e3312d [IMP] web: many2many_binary, binary, image, add the option `accepted_file_extensions`
Purpose
=======
We want to add an option on the widgets
- many2many_binary,
- binary,
- image

This option specifies what file extensions the user can pick from the file input dialog box.

Examples
========
```xml
<field widget="many2many_binary" options="{'accepted_file_extensions': 'image/*'}"/>
<field widget="many2many_binary" options="{'accepted_file_extensions': '.png,.jpeg'}"/>
<field widget="many2many_binary" options="{'accepted_file_extensions': 'application/pdf'}"/>
<field widget="image" options="{'accepted_file_extensions': '.png,.jpeg'}"/>
<field widget="binary" options="{'accepted_file_extensions': '.pdf,.svg'}"/>
```

How
===
Add an option (accepted_file_extensions) in the template ``HiddenInputFile`` (the widget many2many_binary is using this template)
So, we can also use this new option in others widgets using ``HiddenInputFile``
In the many2many_binary, read the ``nodeOptions`` and set the widget attribute ``accepted_file_extensions``

We also have to fix some other widget, because an property ``image_only`` was already existing in the template ``HiddenInputFile``
(we just need to replace ``image_only=True`` to ``accepted_file_extensions='image/*'``

The widget ``FieldPdfViewer`` (pdf_viewer) now use the new option to filtrate PDF
(instead of removing the <input/> and adding <input accept='.pdf'/>).

Tests
=====
We also test if the option is correctly set on the <input/>
- binary
- image
- many2many_binary

Impacted widgets
===============
- many2many_binary
- image: this widget use ``options="{accepted_file_extensions='image/*'}"`` instead of ``image_only=True``
- tablet_image: same as ``image``

Task #2082815

closes odoo/odoo#38351

Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
2019-10-16 13:57:49 +00:00
Quentin Nicolay d59b67a915 [FIX] web: add 'no_edit_color' option to many2many_tags
This option, if set to True, prevents the user from modifying the
color of the tags.

Part of task 2070454

closes odoo/odoo#38848

X-original-commit: a62b65a8f9114493064d4efae92825814a880c04
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2019-10-16 08:26:10 +00:00