Commit Graph
274 Commits
Author SHA1 Message Date
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
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
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
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
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
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
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
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
Sébastien Theys c2918c139b [IMP] web, *: improve mock server and replace most mail mockRPC
Improve mock server:

- add support for mocked `fetch`
- add support for `active_test`
- add support for x2m `in` in domains
- add support for default values computed from a function
- implement a more natural "next id" compute
- allow initial data without ids
- ensure write and x2m commands integrity
- improve bad data/bad commands error messages
- always warn for failing RPC, not only in debug mode
- fix all existing tests that had inconsistency data

Other changes done in mail (or dependents) that are not just related to tests:

- remove `direct_partner` from formatter result
  ->`correspondent` can be computed from other keys, especially `members`

- fix `livechat_visitor` convertData
  -> only process if there is value

- add `current_partner` and `current_user_id` as `init_messaging` result
  -> easier to mock than session

- remove usage of `need_moderation`
  -> that was just a search indirection to `moderation_status`

- adapt `partner_id` -> `res_partner_id` key in `_notification_format`
  -> to be consistent with field name

- add name in result of `mail_partner_format`
  -> sometimes display_name is not the same

- remove usage of `is_moderator`
  -> that was just an indirection to `moderation_channel_ids`

Enterprise counterpart: https://github.com/odoo/enterprise/pull/11523
task-2287171

closes odoo/odoo#55854

X-original-commit: 7ba3fecb3377a720d1eb70e7515a0c45da73836d
Related: odoo/enterprise#12391
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2020-08-13 16:26:35 +00:00
Michael Mattiello (mcm) a5cca2cda3 [IMP] web: add smart date input on date field
This commit adds smart date inputs for date and datetime fields.

The goal of smart date input is to provide the user some shortcuts
when setting dates.

The rule is [+-]\d+[dwmy]?
So we can enter inputs like:
  +3  to have today + 3 days
  -2w to have today - 2 weeks
  +1y to have today + 1 year
  +5m to have today + 5 months
  -4d to have today - 4 days

closes odoo/odoo#55602

Task: 2270347
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-08-11 14:15:43 +00:00
Olivier Dony 2e17c0458c [FIX] web: tests: fix typos in :{last,first}-child
Follow-up of odoo/enterprise#11881, in order to eliminate all similar
typos.

The CSS pseudo-class selectors are spelled `:first-child` and
`:last-child`, and never take any argument, as opposed to
`:nth-child(<nth>)` for example.

Ref: https://developer.mozilla.org/docs/Web/CSS/Pseudo-classes

jQuery doesn't care and matches with or without the `()`, but CSS
engines don't, and now libsass SCSS compilation crashes due to the empty
argument list (cfr. opw-2299465)

Better avoid confusion and fix the typo everywhere.

closes odoo/odoo#54685

X-original-commit: 82244e17339615615535073e6f9e1ddbcf0b57d9
Signed-off-by: Richard Mathot (rim) <rim@openerp.com>
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
2020-07-17 14:36:08 +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
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
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 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
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
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
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
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
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
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
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
fw-bot bc4b7c5036 [FIX] web: can't edit subscription with end date beyond 200 years in the future
-Import a subscription with end date beyond 200 in the future (ex: 2500-01-01).
-Open the subscription and click the Edit button.

Before this commit:

A stacktrace appears indicating that a date is not valid. It's not possible to
edit the subscription.

After this commit:

The maxDate of the date picker has been increased to 31/12/9999, allowing the
user to edit subscriptions whose end date is that far in the future.

A test `toggle datepicker far in the future` for this case has been created.

closes odoo/odoo#38527

Opw: 2079696
X-original-commit: 32b6131c04fef7a542a0ccbdb924d177627bfe38
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2019-10-11 16:12:34 +00:00
Vincent Schippefilt e06117bd85 [FIX] web: multi-hell-ditable list
only activate multi-edit on list with specific attribute.
When the attribute multi_edit="1" is set on the tree view the user
can select a/some records and it will activate the multi-edit
with confirmation dialog (even for a single record).
Also, on-change are not applied when using multi-edit

closes odoo/odoo#37525

Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
2019-09-30 08:57:23 +00:00
Martin Trigaux 2471ee506f [FIX] web: translate html fields
This commit fixes:
- body of a email.template in a small field
- translation of website_description of a product does not show the
  source of the translation
- translation of website_description of a product shows the full
  content for the current language

HTML fields are typically fields with longer of content.
If the field is an HTML field, it should be displayed in a textarea,
like the text fields.

Most of HTML fields are split in meaningful chunks of content (using
xml_translate or html_translate method).
For these fields, the source must be displayed.

Also sort the entries on the source to have a consistent order

closes odoo/odoo#37215

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-09-24 15:52:55 +00:00
Christophe Simonis d67b2483e5 [MERGE] forward port branch saas-12.4 up to 9ed4872ea0
closes odoo/odoo#37372

Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-09-24 17:45:37 +00:00
Christophe Simonis ac4fc6e7c7 [MERGE] forward port branch saas-12.3 up to bd3e510edb
closes odoo/odoo#37314

Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-09-24 09:44:56 +00:00
Andrea Grazioso (agr-odoo) 3ee3f7d497 [FIX] web: digits option not applied in list view
From the settings activate:

- Multiple Sales Prices per Product
-- Prices computed from formulas
- Discounts

Create a pricelist with discount policy "Show public price & discount to
the customer", set the price calculation formula:
- Rounding: 10
- Price discount: 10%

Modify the sale order xml list view adding 'digits="[3, 2]"' to the
discount shown in the sale order line.

Create a sale order with such pricelist and on the so line put a
product with quantity 1 and sale price 4190 (VAT 19% included in the price).

The discount will not display the requested number of decimal digits (2)
in list view, but it will when editing the field.

The cell formatting is done calling the appropriate function (formatFloat),
which search the digits option from the 'options' parameter or from the field
definition. The latter stores the default digits coming from
the DecimalAccuracy settings, which, as side effect, alter the behavior
of the discount calculation.
https://www.odoo.com/web#view_type=form&model=project.task&id=2069939&active_id=2069939

When passing into edit mode the field is created as widget, parsing its options
which have 'digits', instead when coming back in list mode it is "just a
float field" rendered directly from the list_renderer which no options,
so the formatFloat will look at the field definition
https://github.com/odoo/odoo/blob/12.0/addons/web/static/src/js/fields/field_utils.js#L172

Adding the correct parameter to the dictionary passed to formatFloat
during the list rendering is a possible solution, because it is the
"closest" point in which parsing the parameter is possible without
touching higher level code or forcing the creation of a widget (adding
widget='float' as xml parameter).

closes odoo/odoo#37167

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2019-09-20 05:37:56 +00:00
Aaron Bohy af65475a4c [FIX] web: list: multi edit input of date(time) fields
The Date(Time)Fields listen to 'input' and 'change' events (like
all InputFields) to keep track of changes. However, the datepicker
already listens to the 'change' event. As a consequence, in multi
edition in a list view, if the user changed the value of a
date(time) field by directly editing the input, the fieldChanged
event was triggered twice, and there were 2 dialogs asking the user
if he wanted to save the change.

This rev. makes the Date(Time)Fields stop listening themselves to
'input' and 'change' events, and instead completely rely on the
datepicker widget.

Task 2068280
2019-09-18 08:24:13 +00:00
Aaron Bohy ac85176ce8 [FIX] web: date(time) fields: trigger fieldChanged once
Before this rev., the 'fieldChanged' event was triggered each time
the user selected a value (a day, an hour, a minute or a second) in
the datepicker. This means that if there was an onchange on the
field, a lot of RPCs could have been done when a user set a
datetime. In addition, in a list view with multi edition, the user
was asked to save the changes at each step of the datetime
selection, making the feature unusable.

Task 2068280
2019-09-18 08:24:13 +00:00
Christophe Simonis 080f8b1f96 [MERGE] forward port branch saas-12.3 up to d8ce75466e 2019-09-17 17:49:09 +02:00
Lucas Perais (lpe) fa283d3d4e [FIX] web: progress bar feature
The progress bar was pretty broken before this commit.

> It was not possible to input the value as text
> Moving the progress bar to modify value and saving crashed
> modifying the max value crashed
> The whole feature was ill-defined

With this commit, we fix the crashed. It is now possible to write the field
behind the progress bar by moving it in RO mode
or by typing the input in RW mode
*if it is the value we want to write on*

It it is the max value that the field targets, we can do it in RO and RW mode,
only with the input as text

Note that this works *only if* the editable option on the widget is set to true

OPW 2061846

closes odoo/odoo#36928

closes odoo/odoo#36970

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2019-09-16 15:28:25 +00:00