Commit Graph
103 Commits
Author SHA1 Message Date
Odoo's Mergebot 4e82c45abd [IMP] core: store translated fields as JSONB columns
[IMP] core: store translated fields as JSONB columns

Translated fields no longer use the model ir.translation.  Instead they store
all their values as JSON, and store them into JSONB columns in the model's
table.  The field's column value is either NULL or a JSON dict mapping language
codes to text (the field's value in the corresponding language), and must
contain an entry for key 'en_US' (as it is used as a fallback for all other
languages).  Empty text is allowed in translation values, but not NULL.

Here are examples for a field with translate=True:

    `NULL`
    `{"en_US": "Foo"}`
    `{"en_US": "Foo", "fr_FR": "Bar", "nl_NL": "Baz"}`
    `{"en_US": "Foo", "fr_FR": "", "nl_NL": "Baz"}`

Like before, writing False to the field makes it NULL, i.e., False in all
languages.  However, writing "" to the field makes its value empty in the
current language, but does not discard the values in the other languages.

Here are examples for a field with translate=xml_translate:

   ` NULL`
    `{"en_US": "<div>Foo<p>Bar</p></div>", "fr_FR": "<div>Fou<p>Barre</p></div>"}`

Change for callable(translate) fields: one can now write any value in any
language on such a field.  The new value will be adapted in all languages, based
on the mapping of terms between languages in the old values.  Basically the
structure of the value must remain the same in all languages, like before.

Reading a translated field is now both simpler and faster than the former
implementation.  We fetch the value of the field in the current language by
coalescing its value with the 'en_US' value of the field:

    `SELECT id, COALESCE(name->>'fr_FR', name->>'en_US') AS name ...`

The raw cache of the field contains either None or a dict which is conceptually
a subset of the JSON value in database (except for missing languages).  For the
sake of simplicity, most cache operations deal with the dict and return the text
value in the current language.

Trigram indexes have been adapted to the new storing strategy, and should enable
to search in any language.  Before this change, only the source value of the
field ('en_US') could be indexed.

Computed stored translated fields are not supported by the framework, because of
the complexity of the computation itself: the field would need to be computed in
all active languages.  We chose to not provide any hook to compute a field in
all languages at once, and the framework always invokes a compute method once to
recompute it.

Code translations are no longer stored into the database.  They become static,
and are extracted from the PO files when needed.  The worker simply uses a cache
with extracted code translations for performance.  This is reasonable, since
fr_FR code translations for all modules takes around 2MB of memory, and the
cache can be shared among all registries in the worker.  Changing code
translations requires to update the corresponding PO file and reloading the
worker(s).

Performance summary:
(+) reading 'model' translated fields is faster
(+) reading 'model_terms' translated fields is much faster (no need to inject
     translations into the source value)
(+) searching translated fields with operator 'ilike' is much faster when the
     field is indexed with 'trigram'
(+) updating translated fields requires less ORM flushing
(-) importing translations from PO files is 2x slower

Some extra fixes:
- make field 'name' of ir.actions.actions translated; because of the PG
   inheritance, this is necessary to make the column definition consistent in
   all models that inherit from ir.actions.actions.
- add some backend API for the web/website client for editing translations
- move methods get_field_string() to model ir.model.fields
- move _load_module_terms to model ir.module.module
- adapt tests in test_impex, test_new_api
- because env.lang is injected into SQL queries, its returned value is
   now guaranteed to correspond to a valid active language or None
- remove wizard to insert missing translations (no longer makes sense)

closes odoo/odoo#97692

Task-id: 2081307
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-09-16 14:25:13 +02:00
Achraf (abz) 8d4bb8c109 [FIX] web: Allow to hide model in ReferenceField
In legacy, hide_model attribut on FieldReference was used to hide
the model input, but it was not implemented in ReferenceField
(new version).

closes odoo/odoo#99819

Signed-off-by: Michaël Mattiello <mcm@odoo.com>
2022-09-16 10:09:26 +02:00
Chong Wang (cwg) b43d117e0e [IMP] web, web_editor: translation dialog for new translate api 2022-09-15 22:37:50 +02:00
Aaron Bohy 66d9fe67a6 [FIX] web: Many2OneField: do not display a link if unset
Before this commit, an empty many2one field in readonly rendered
an empty `<a href"...">` node. Even though that link was no visible,
it had a non null width, and was thus clickable (the cursor changed
when hovering it). When clicked, it opened the form view of the
comodel, in create mode.

This commit fixes the issue by not rendering anything if the value
is false.

closes odoo/odoo#100158

Signed-off-by: Géry Debongnie <ged@odoo.com>
2022-09-15 12:41:07 +02:00
Romeo Fragomeli b6a36df34a [IMP] web: convert many2one_barcode to OWL
Before this commit there is a widget `many2one_barcode` that allows
to scan a barcode.

After this commit, we have converted it to OWL, but it's more than a new
component. From now, the logic is in the basic Many2One as a
property/option (`canScanBarcode`) and we also have the equivalent
Component (`widget="many2one_barcode"`). This choice has been made to
support multiple use cases (e.g. having the product_configurator and the
barcode on the same product field).

Note:
now we use the `browser` class to allow to patch the browser feature
during testing.

Part-of: odoo/odoo#100082
2022-09-15 11:05:22 +02:00
Simon Genin (ges) ddfd141165 [FIX] web: use command hook in component
Before: the command service was used inside components instead of the
hook. It introduced problems as the commands were not unregistered.
The commands were added multiple time to the registry.

closes odoo/odoo#100135

After: It uses the hook, "it just works".
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-09-15 01:23:21 +02:00
Aaron Bohy dd72a40926 [FIX] web: can't save o2m with not new dirty invalid record
Imagine a form view with a one2many editable list, containing a
required field. Open an existing record, s.t. in the one2many
there's already a sub record. Modify that subrecord, s.t. the
required field is unset (e.g. empty it, or it can be unset from
the beginning, but then modify another field). Then save the main
record. Before this commit, the record could be saved.

In this situation, the modified one2many record isn't valid, so
we shouldn't be allowed to save. The view should remain in edition
and the invalid field should be indicated.

This commit fixes this issue.

closes odoo/odoo#100059

Signed-off-by: Géry Debongnie <ged@odoo.com>
2022-09-13 22:16:08 +02:00
Aaron Bohy 69a72aa4e1 [FIX] web: Many2ManyField: use correct title in dialog
Before this commit, the title of the SelectCreateDialog opened
when clicking on "Add a line" in a Many2ManyField was always
"Select Records" (the default value), whereas in this case, we
want to see "Add: something", where `something` is the `string`
attribute of the field (which can be overriden by an attrs on the
field node in the arch). This commit restores the desired behavior.

closes odoo/odoo#100046

Signed-off-by: Géry Debongnie <ged@odoo.com>
2022-09-13 13:53:36 +02:00
Aaron Bohy c313c25ff1 [FIX] web: x2many: send field context to x2many dialogs
Have a x2ManyField displayed as a (non-editable) list view, and
with a context defined on the x2m field node in the arch. Before
this commit, this context wasn't propagated to the dialog opened,
for instance, when adding a new record. It is now the case.

To make the tests pass, we also needed to make a slight change in
the BasicModel, as it didn't correctly process the context when
adding a new record with additional contexts (e.g. in x2many list
views with custom `<creates>`.

closes odoo/odoo#100000

Signed-off-by: Géry Debongnie <ged@odoo.com>
2022-09-13 13:53:30 +02:00
Florian Damhaut b3489af4c1 [FIX] web: basic_model: save a paged nested o2m
In a form view, have a o2m field (A), with a nested o2m field (B).
The A field should have multiple pages, with each record having at least one record
in their B field.

Have a (C) field that will modify a record in the nested o2m when changed.

Change the C field, and save.

Before this commit, the record's nested o2m from the other page had a wrong value
(a mere 4 command).

After this commit, their value is a command 4 and a command 1, with the right values.

closes odoo/odoo#99986

X-original-commit: e45e3b83f0f3116cc983c6bd8a9212e815b4d4f5
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-09-12 13:49:31 +02:00
stefanorigano (SRI) eb1fa44652 [IMP] web: o_optional_columns_dropdown, move into thead
This commit moves the element inside the table to avoid that the
dropdown may overlap thead column labels.
Part of the overall v16 SCSS optimization/restyle, task-2704984

task-2946835

Part-of: odoo/odoo#98234
2022-09-12 10:06:56 +02:00
Aaron Bohy e28c581a62 [FIX] web: fix tests failing randomly
This commit fixes several tests involving the Autocomplete
component that would sometimes fail because it delays its
next rendering on input (by a setTimeout 0 in the tests). This is
sometimes not enough as it may imply that the next rendering
occurs after the next animation frame, which isn't what we wait
for in the tests (we expect the next rendering to be applied
before the next animation frame).

This commit fixes remaining tests that we forgot in [1]

[1] de6cd189a4

closes odoo/odoo#99919

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-09-09 17:29:55 +02:00
luvi cbdea4010e [FIX] web: hide the phone field if empty
This commit hides the <a> representing the phone
number if it is unset. Before this commit, it
could display "false" instead of being invisible.
Now, the <a> element is no longer added to the DOM.
A test has been added to assert that behavior.

closes odoo/odoo#99905

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-09-09 14:41:34 +02:00
luvi 6217126c5e [FIX] web: fix size option for image field
This commit fixes the size of an image being set with
a 0 when it was given using the 'size' option.
In legacy, when 0 was given to one of the parameters,
it was simply ignored and not set on the image. Since
the fields has been converted, it was set and the image
was not visible, because of an height/width equal to 0.
A test has been added to assert this behavior.

closes odoo/odoo#99613

Signed-off-by: Simon Genin (ges@odoo) <ges@odoo.com>
2022-09-08 18:31:20 +02:00
Aaron Bohy de6cd189a4 [FIX] web: tests: fix non deterministically failing tests
Before this commit, these tests sometimes failed because the
autocomplete dropdown updated itself after a delay. These tests
patch it s.t. there's no delay in the tests. Something similar is
done in the Many2oneField test suite.

Example of impacted staging and nightly builds:
 https://runbot.odoo.com/runbot/build/19121210
 https://runbot.odoo.com/runbot/build/18976006

This commit also removes unnecessary patches that set the delay of
the Autocomplete component to 0, but this has no impact as this
property doesn't exist (this was done in addition to a patch of
setTimeout which is enough anyway).

Closes #99781

closes odoo/odoo#99788

Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
2022-09-08 13:50:51 +02:00
luvi bd80c4138e [FIX] web: fix BooleanField in editable list
This commit fixes the BooleanField which didn't
turned the row in edition when clicked on it since
the event was stopped by the Checkbox component.
The disabled input should not stop the event, since
the component do not need to handle a click being
done on it.

The test in editable list has been adapted to add
this assertion.

closes odoo/odoo#99759

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-09-08 13:50:48 +02:00
Jérémy Hennecart (jeh) f13b8897fd [FIX] web: fix can create option m2m
Since the "canCreate" option was not propagated this was leading
to a traceback with the autocomplete.
Indeed the option "No records" was never added because it was always
in a loading state.

closes odoo/odoo#99689

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-09-08 12:46:44 +02:00
Lucas Perais e940f14ccb [REF] web: Many2ManyTagsField: only edit color in Form
One can edit the color of a tag in a Many2ManyTags field only in form view.
This commit refactors that field so that the standard field Component doesn't allow for it,
and conversely implements a specialization of the field that can, and should be
selected by the form view.

closes odoo/odoo#99499

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-09-06 10:58:16 +02:00
luvi 73e2cf08a4 [FIX] web: displays the right status on hover
This commit fixes the StateSelection field, which
displayed the wrong value on hover. In legacy, the title
attribute was set to display that value. Now, it has been
replaced by a tooltip, since it can be used with touch
and is more convenient to use. A test has been modified
to assert the presence of the data-tooltip attribute.

closes odoo/odoo#99561

Signed-off-by: Simon Genin (ges@odoo) <ges@odoo.com>
2022-09-05 22:51:57 +02:00
Lucas Perais 7f0f7bcdce [FIX] web: Many2One in list: keeps input after record create
Have a many2one in an editable list view. Type something in the input and click
on "Create and edit".

Confirm the record creation in the modal.

Before this commit, the input of the field disappears.

After this commit, the input stays.

closes odoo/odoo#99480

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-09-05 16:54:16 +02:00
Lucas Perais f4a8d5bf9b [FIX] web: legacy Many2ManyTags in list view: add/remove records
Have a list view (new RelationalModel inside a WOWL list view) that has
a legacy many2many tags field in its arch.

Try to add or remove some records from that many2many.

Before this commit, there was a crash, because the legacy field wrapper
doesn't use the model the right way for that case.

After this commit, there is no crash.

closes odoo/odoo#99431

Signed-off-by: Georis François (fge) <fge@odoo.com>
2022-09-02 10:16:01 +02:00
Julien Mougenot d3eff197a5 [FIX] web: Fix binary and pdf_viewer fields
This commit aims to make the BinaryField and PdfViewerField appear and
act the same way as they did before their conversion to Owl.

This mostly consists of a few tweaks in the conditional rendering of
certain elements in the template, and the rest of the changes are meant
to clean and simplify the values the component is working with.

closes odoo/odoo#98251

Signed-off-by: Bruno Boi (boi) <boi@odoo.com>
2022-09-01 19:17:00 +02:00
FrancoisGe c70d01f429 [FIX] web: save a x2m with an invalid new record
The purpose of this commit is to prevent saving to a form view
if you have created and edited a new invalid record in an x2many.

How to reproduce
- go to a form view with an x2m
- create a new record with at least one required field empty in the x2m
- edit another field than the required one
- click on the save button

Before this commit:
- The view is switched to readonly mode and the new record is deleted.

After this commit:
- The view stays in edit mode, the new record is not deleted and
a notification indicating invalid fields is displayed.

closes odoo/odoo#99288

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-09-01 17:11:08 +02:00
Bruno BoiandJulien Mougenot 0f49724436 [IMP] web: simplify format/parse/deserialize date(time) utils
The goal is to improve the dates utility functions (parse/format) by removing the timezone option, which is difficult to understand and has proven to be error prone.

- Rationale
When manipulating DateTime objects on the JS side, associated timezones
must be always coherent.
Until now, there were several code parts that had to check the DateTime
timezone and handle things differently in a case or another.
This sometimes lead to wrong code.
E.g. there was a bug in the DatePicker component because the DateTime
object it receives in props is in local timezone, but once it updates it
through the parse utility, the new object is in UTC.

- After this commit
The DateTime objects you'll get through deserialization or parsing are
always set in the user's local timezone.
The formatted strings you'll get through formatDate and formatDateTime
utils will always be expressed in the user's local timezone.
The formatted strings you'll get through serialization utils will always
be expressed in UTC.

- serializeDate and serializeDateTime
  - expected input: a DateTime object (its timezone does not matter)
  - outputs: a string formatted for the server expressed in UTC

- formatDate and formatDateTime
  - expected input: a DateTime object (its timezone does not matter)
  - outputs: a string formatted for the user, expressed in the user's TZ

- deserializeDate and deserializeDateTime
  - expected input: a date(time) string provided by the server, in UTC
  - outputs: a DateTime object in user's TZ

- parseDate and parseDateTime
  - expected input: a date(time) string provided by the user, in its TZ
  - outputs: a DateTime object in user's TZ

- Other changes in this commit
As the timezone option has been removed from parsing/formatting utils,
all their usage had been adapted in the codebase.
The large diff in dates_tests.js is because some tests were reorganized,
others were removed/adapted/joined.
A test has been removed from daterange_field_tests.js, because it has
no sense: it displays a date field as a datetime, but a date field does
not have any time information.

Part-of: odoo/odoo#98980
Co-authored-by: Julien Mougenot <jum@odoo.com>
2022-09-01 17:10:59 +02:00
luvi 679739a63d [FIX] web, *: fix ProgressBarField behaviors
*: survey

This commit brings back the correct behavior on blur
to the progressbar field. It turns as a text value as
soon as the user has focused out of the input. It
also removes the wrong usage of the max_value option.

The behavior was wrongly adapted from the legacy
progressbar implementation. Tests have been adapted
to assert the correct behavior.

closes odoo/odoo#98902

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-09-01 11:32:32 +02:00
Aaron Bohy 0b3212c4b6 [FIX] web: Many2ManyTagsField: honnor options
In the legacy implementation of FieldMany2ManyTags, we instantiated
a FieldMany2One with the attrs of the many2many field node. As a
consequence, the FieldMany2ManyTags honnored its own options and
all options supported by the FieldMany2One.

In the new implementation, before this commit, we lost the support
of the Many2ManyField's specific options, in particular "no_create"
and "no_create_edit". This commit fixes that issue.

With this commit, the FieldMany2ManyTags also takes into account
the "can_create" attribute that is automatically set to "0" by the
framework if the user hasn't the required access rights.

Note: Many2OneField options is a mess, it would be nice to
refactor and simplify them in the future.

closes odoo/odoo#99283

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-08-31 21:11:58 +02:00
Bruno Boi 0ae158bf43 [LINT] web
closes odoo/odoo#99295

Related: odoo/enterprise#30900
Signed-off-by: Samuel Degueldre <sad@odoo.com>
2022-08-31 18:53:51 +02:00
Mathieu Duckerts-AntoineandMichael Mattiello a29691bfd8 [FIX] web: DomainField: debug input value lost on blur
Edit a domain in the debug text area of a domain field in debug mode
was possible but the value displayed in the text area was reset to the
value displayed in the part above. For instance, starting with a domain
field value like "[('id', '=', 1)]" then editing it in the text area to
be "[('id', '=', 3)]", the value for the domain field would be correctly
updated but the value displayed in the domain field would be the initial
value "[('id', '=', 1)]". We fix that by making the DomainSelector
component accept an extra prop "debugValue" to be displayed in the debug
area instead of the prop "value" if it is defined.

closes odoo/odoo#99207

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Co-authored-by: Michael Mattiello (mcm) <mcm@odoo.com>
2022-08-31 12:37:51 +02:00
FrancoisGe 1f43844549 [FIX] web: save an empty many2many_tags required
Before this commit, the required attribute has no effect on the x2many
fields. It will always be valid unless one of its records is invalid.

Problem:
In some cases, we would like to be able to make some x2many fields
required. For example, many2many_tags should be invalid if it contains
no records.

In legacy, if a field is required, then it has the responsibility to
evaluate if its value is valid. To do this, each field contained the
isSet function which returns true if the value is set.

In our new architecture, it is the model that evaluates if the value of
a field is valid based on the field type. It is therefore no longer
possible to customise the evaluation of the validity of a field based
on the FieldComponent.

Solution:
This commit will reintroduce the possibility to customize the evaluation
of the validity of a field based on the FieldComponent.
To do this, we add the possibility to define a static isSet function
on the FieldComponent. If this function is present, it will be used
to evaluate if the field value is set or not.

closes odoo/odoo#98873

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-08-31 12:37:35 +02:00
Lucas Perais 11c1bbbdd0 [FIX] web: changing the priority of a new record in kanban
Have a grouped kanban which display a priority field widget.
Quick create a record.

Click on any priority widget to change the priority.

Before this commit, the model was still considered in edition, preventing any change
in other record. Hence, the priorities did not change (at least, there was no write operation)
when clicked on.

After this commit, this flow works as expected.

closes odoo/odoo#99199

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-08-30 21:25:15 +02:00
Simon Genin (ges) 5e754ffd4d [FIX] web: fix field update
When a field in readonly view can be modified, it should write to the
backend immediately. (No changes are stored to be comited later)

For some reason, a bit of code was preventing this if the field was
required and had a falsy value. Furthermore, the code seemed incorrect
or at least misplaced. Removing these lines didn't affect the test.

The fix simply remove this extra check.

There was a condition in the update code for required field in readonly
views that prevented the correct flow to be executed. Since no test are
broken removing this check but it fixes the problem, it is removed.

closes odoo/odoo#98978

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-08-30 09:23:13 +02:00
FrancoisGe e50bee88c4 [FIX] web: touch a record in a x2m
Before this commit, if a touchstart event is performed on a row in an
x2many, then a crash is displayed.

We also use this commit to rename the hasSelector props to allowSelector.
allowSelector is true if checkboxes can be present.

How to reproduce:
- go to a form view in mobile mode with an x2many field
- touch a row in the x2many (trigger an event touchstart)

Before this commit:
    An error is displayed

After this commit:
    Nothing happens.

closes odoo/odoo#98893

Related: odoo/enterprise#30773
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-08-30 03:44:56 +02:00
FrancoisGe 1ecdbfcfbf [FIX] web: empty a many2one field
Before this commit, it was impossible to empty a many2one in a list view.

How to reproduce:
- go into a list view with a many2one
- empty a many2one containing a value
- click outside the line

Before this commit:
The record goes into readonly mode and its many2one returns to
its original value.

After this commit:
The record is saved and its many2one is empty.

closes odoo/odoo#99140

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-08-30 02:51:12 +02:00
luvi 33925701aa [FIX] web: fix the copied tooltip of CopyButton
This commit fixes the style of the field, which was
pretty broken since the Owl conversion.
It also bring back the tooltip (as in legacy) when
the button is clicked.

The button now only shows the tooltip if the text
has been copied successfully to the clipboard, and
not appear when it is not allowed or not available
in the browser.

Tests have been added to assert those behaviors.

Enterprise PR to adapt a selector in tests:
https://github.com/odoo/enterprise/pull/30832

closes odoo/odoo#98340

Related: odoo/enterprise#30832
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-08-30 00:46:26 +02:00
std-odoo f26cae6db5 [IMP] web: allow non administrators to use relational properties
Purpose
=======

Allow non administrators to use relational properties.

Standard internal users can not read ir.model. Because of that we
created a component that simulate the behavior of a many2one, but
that call custom public method that check which model the user can
access.

Task-2852259

Part-of: odoo/odoo#95184
2022-08-29 23:46:07 +02:00
std-odoo 3961038ddb [IMP] web: create a properties field component
Purpose
=======

Create a component for the new Properties field. This component instantiates
the right sub-component based on the property type (e.g. a DatePicker for a
DateTime, a Many2XAutocomplete for relational properties, etc).

This component also allow changing the properties definition (default
value, model, property type, etc).

Note that currently it is limited to children properties, assuming definition
is done from children to containers.

Add unit tests to ensure that behavior of the properties component is correct.

Task-2852259

Part-of: odoo/odoo#95184
2022-08-29 23:46:06 +02:00
Julien Mougenot b8d4c41331 [FIX] web: Fix behaviors of ProgressBarField
This commit fixes behavior issues in the progress bar field:

- the progressbar would not write on a field if it was declared as
'readonly' on the server (it sounds counter-intuitive but this widget
was supposed to write on records unless given the 'readonly' flag in the
field options);

- the "isEditable" prop was incorrectly computed, resulting in the field
not being editable in kanban views when it should be;

- when editing a value in the field, the focus should be automatically
given to the first input.

These issues have been fixed in this commit.

closes odoo/odoo#97411

Signed-off-by: Bruno Boi (boi) <boi@odoo.com>
2022-08-25 12:05:03 +02:00
FrancoisGe c200b0cc8a [FIX] web: many2one close "No records"
Before this commit, when a many2one's input shows the choice
"No records", the dropdown does not close.

Cause:
When blurring, the many2one will select its first item. In our case,
"No records" is not selectable and it will not close the dropdown.

How to reproduce:
- go to a form view with a many2one field
- insert a non-existent value in the many2one ("No records" is displayed)
- leave the many2one input ("blur" event)

Result before:
The dropdown containing "No records" is still open.

Result after:
The dropdown containing "No records" is closed.

closes odoo/odoo#98799

Signed-off-by: Michaël Mattiello <mcm@odoo.com>
2022-08-25 10:32:04 +02:00
FrancoisGe 15a032e84a [FIX] web: placeholder in required SelectionField
This commit adds the possibility of having a placeholder in a
required SelectionField.

Solution:
We always add a false option with the placeholder but it is "display:none"
if the field is required.

How to reproduce:
- create a new record in a form view with a required selection field

Result before:
    The first option of the selection field will be selected

Result after:
    The placeholder of the selection field will be selected

When editing the selection field, the selection field does not propose
the placeholder.

closes odoo/odoo#98823

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-08-25 09:06:30 +02:00
Bruno Boi a7fb02e3fa [FIX] web: autocomplete should keep input value on search more
# Before this commit
When searching more in an autocomplete component,
the input value is emptied before opening the Search More dialog.

# After this commit
The input value keeps its content when the Search More dialog opens.

closes odoo/odoo#98639

Signed-off-by: Michaël Mattiello <mcm@odoo.com>
2022-08-25 01:54:04 +02:00
FrancoisGe 211a38b4b0 [FIX] web: ReferenceField with model_field option
Before this commit, if we have a reference field with a "model_field" in
X2many in list mode and we modify this record, then the value of the
reference field is set to false.

Cause of the problem:
The reference field assumes that the preloadedData are always available.

How to reproduce :
- Go to an x2many in list mode containing a reference field with a
 "model_field" already containing a value
- edit another field than the reference
- click outside the record

Result before :
The record switches to readonly mode and its reference field contains
the value false

Result after:
The record switches to readonly mode and its reference field has not
changed value.

closes odoo/odoo#98630

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-08-23 17:55:28 +02:00
Dardenne Florent (dafl) d3905b5bb7 [IMP] web: improve statusbar widget performance
Purpose:
Improve performance/reduce server load for the status bar widget when
the underlying field is a m2o.

Before this commit:

The status bar widget does two calls:
- a search_read request to retrieve ids and folds
- a name_get to retrieve names

With this commit:

The name_get can be avoided to save a call by fetching display_name in
the search_read.
This commit removes the name_get call to retrieve the name directly
from search_read.

task-2919535

closes odoo/odoo#98164

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-08-23 17:55:18 +02:00
Bruno Boi fff7334d09 [FIX] web: use right datetime format in daterange field
- First issue
The format passed to the daterangepicker locale options could have been
wrong as the daterangepicker lib uses moment and we would pass to it
the date(time) format expressed with luxon's format tokens.
Furthermore, there was no need to pass the format to the daterangepicker
library as the DateRangeField component already handles this.

- Second issue
There was also another issue with the DateRangeField component:
When applying the daterangepicker values, the conversion between a
moment object to a luxon DateTime object was wrong because of the format
used to convert the moment object to a string.

- Explanation
The format tokens are different between luxon and moment.

- After this commit
An helper function has been introduced in order to transform a luxon format into a moment format.
The DateRangeField component now properly converts a moment object to
a luxon's DateTime object when applying the daterangepicker selection.

- Additional note
Also, the DatePicker component was locally converting the luxon's
datetime format and thus has been adapted to use the new helper.

closes odoo/odoo#98578

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-08-23 16:29:22 +02:00
Bruno Boi 83719ce376 [FIX] web: make daterange field work with empty initial value
- Before this commit
Using a daterange field with an empty start/end date(time) will result in an unusable field.
The datepickers shown are set with invalid moment.js objects.

- Explanation
A formatted empty value yields an empty string.
Calling `moment("")` results in an invalid moment objet.

- After this commit
When the formatted empty value yields to a falsy value (i.e. an empty string), we call the global moment function without arguments.
Calling `moment()` results in a valid moment object representing the current date and time.
This is what we are looking for, and thus our issue is resolved.

Part-of: odoo/odoo#98578
2022-08-23 16:29:21 +02:00
FrancoisGe e1d60b9161 [FIX] web: x2m open form dialog with the correct context
Before this commit, when you want to modify or add a record in a
non-editable x2many, the call to get_views to receive the arch for the
FormViewDialog did not contain a context.

Problem:
The arch of the form view that is received for adding or editing a
record in a non-editable x2many is not evaluated correctly.

Cause:
An empty context is passed to the "get_views" to receive the arch
for the FormViewDialog.

Solution:
We use the context of the StaticList that represents the x2many for
the "get_views".

Part-of: odoo/odoo#97558
2022-08-23 16:28:57 +02:00
FrancoisGe a11dafc99c [IMP] web: add control action button in x2many
This commit adds the possibility to define control action buttons in the
arch of a list view for a x2many. These buttons are action buttons that
will be placed in the same place as the control create ("Add a line").

The goal of this new feature is to offer the possibility to define
buttons that execute actions linked to an x2many.

Here is an example where we define a control create and a control action
button:
<tree>
    <control>
        <create string="Create" context="{}" />
        <button string="Action Button" name="do_something"
            class="btn-link" type="object" context="{'parent_id': parent.id}"/>
    </control>
    <field name="display_name"/>
</tree>

Part-of: odoo/odoo#97558
2022-08-23 16:28:57 +02:00
FrancoisGe 268c949f89 [FIX] web: create record with x2m invisible
Before this commit, when creating a record containing an invisible
x2many, the fields related to this x2many were not asked during the
creation onchange.

Problem:
Some required values were missing when igniting a new record.

Cause:
The arch related to an invisible x2many was ignored.

closes odoo/odoo#98086

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2022-08-22 10:27:07 +02:00
Michael (mcm) f20e3d13fc [FIX] web: fix state selection field position
Before this commit, the state selection field was positioned
on the left of the sheet, just above the title. Now, it is
positioned on the right of sheet.

This commit also fixes the text displayed by this field by
using the value of the fields (normal;blocked;done)_legend.

Finally, this commit removes the last uses of the deprecated
field `kanban_state_selection`.

closes odoo/odoo#97765

Signed-off-by: Bruno Boi (boi) <boi@odoo.com>
2022-08-18 15:07:47 +02:00
Bruno Boi df05f8f91d [FIX] web: restore correct m2m_tags style
This commit completes the style of the tags of m2m_tags field.
Tags did not have correct colors and had border.
The commit also fixes the m2m_tags_avatar field for the same reason
as well as a traceback when clicking on the remove tag button.

closes odoo/odoo#96654

Related: odoo/enterprise#30012
Signed-off-by: Bruno Boi (boi) <boi@odoo.com>
2022-08-18 15:07:43 +02:00
luvi c94e38ca16 [FIX] web: ImageField style
This commit fixes the style of the field broken
since the introduction of the "display: contents"
rule in css.

closes odoo/odoo#97906

Related: odoo/enterprise#30073
Signed-off-by: Samuel Degueldre <sad@odoo.com>
2022-08-17 11:21:08 +02:00