Commit Graph
173 Commits
Author SHA1 Message Date
Christophe Simonis 50860317cc [MERGE] forward port branch saas-11.2 up to b170a753e1 2018-06-15 11:30:27 +02:00
Christophe Simonis b170a753e1 [MERGE] forward port branch 11.0 up to b05e4d5f95 2018-06-15 10:15:27 +02:00
Jairo Llopis 71334b13bd [IMP] web: Expose datepicker configuration to view declarations
The lower-level widget itself supports passing options to the underlying
datepicker library. However this is not exposed to higher-level view
declaration. With this patch, one can declare a field in a view such as:

```xml
<field name="datefield" options='{"daysOfWeekDisabled": [0, 6]}'/>
```

That option would land in the widget and disable those weekdays.

Documentation has been updated accordingly.

Closes #25044.
2018-06-13 14:53:11 +02:00
Vincent Schippefilt a017946737 [FIX] web: allow focus to move to a field monetary
In the chart of account editor, which is an editable list with 2
contiguous monetary field, we could not change the first then move to
the second using the TAB key: the focus was not set on the input of the
second monetary field, and when it is, that input is destroyed and
recreated so the focus was lost

Before this fix, the user needed to hit TAB twice to move to the next
field.
After this fix, the user can navigate between fields monerary with TAB
2018-05-02 14:49:23 +02:00
Christophe Simonis c309ccd7b3 [MERGE] forward port branch saas-11.2 up to fed775bc0c 2018-04-18 18:30:35 +02:00
Christophe Simonis fed775bc0c [MERGE] forward port branch 11.0 up to 8c64159b88 2018-04-18 18:20:40 +02:00
Aaron Bohy 05589db823 [FIX] web: don't ignore required attrs on image fields
Before this rev., falsy image fields could be saved even if they
were required.
2018-04-18 17:40:09 +02:00
Christophe Simonis 5dca782100 Revert "[FIX] web: remove &shy; when saving phone number"
This reverts commit b8b0f947bf.
2018-04-16 20:26:21 +02:00
Christophe Simonis 74033eb007 [MERGE] forward port branch saas-11.2 up to 90f8f17fb4 2018-04-16 19:50:50 +02:00
Christophe Simonis 5f2d080cf8 [MERGE] forward port branch 11.0 up to ad825b673b 2018-04-16 18:34:56 +02:00
Vincent Schippefilt 65d8a082df [FIX] web: fix keyboard related crash in client actions 2018-04-16 09:35:33 +02:00
Nicolas Lempereur b8b0f947bf [FIX] web: remove &shy; when saving phone number
When Odoo display a phone number number, on phone or if VOIP is
installed a invisible `&shy;` character was added from 9.0 up to
saas-11.2 so an applications such as skype would not be concerned with
the number.

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

opw-1834858
closes #24223
2018-04-13 15:35:33 +02:00
Vincent Schippefilt 02a063fd73 [IMP] web: keyboard navigation in form view
The goal of this commit is to allow fast entry of the same model using
the keyboard for navigating through the form once, by blocking the user
from advancing in the form if there is a required field or once they
went through the form once to get them to a primary action (button)

This commit includes the following changes
    1) Enable moving forward from field to field using the TAB key
    2) Entering the one to many and many to many using the TAB key
        a. When entering it, set the focus on the "add new line" link or
            button
		b. When adding a new line, set the focus on the field visible
            editable field of the new line
        c. Discard adding a new line with ESC key
        d. If the user leaves the first field empty and uses TAB, we
            will cancel the adding of a new line and move to the next
            field of the form
    3) When a field is required and not filled in, do not allow the user
        to move out of the field using the TAB key (the user is still
        allowed to use the mouse though), mark the field as invalid
        instead
    4) After going though the form once, using the TAB key on the last
        field will move the focus to the first primary button of the page
    5) When the focus is on a primary button (EDIT/SAVE), the user cannot
        move the focus forward using the TAB key. Hitting TAB again will
        display a tooltip telling to hit ENTER to activate the button.
        The mouse is still available to move the focus.
    6) When the user saves, the focus is placed on the first primary
        button of the form renderer (like VALIDATE for a new invoice)
    7) On dialogs, primary buttons should stop the users from moving out
        of them, and showing a popup if the user tries
    8) When closing a dialog, the focus will be moved back to the widget
        that opened it.

This commit does not include the following features
    1) Navigation with the keyboard on a selection one to man
    2) Navigate between tabs in a form using the keyboard
    3) Cancelling the adding of a new line in a many to many using the
        ESC key do not set the focus correctly
    4) Enhancing the focusses fields (like blue underline)
2018-04-10 09:39:08 +02:00
Christophe Simonis 860dfb5586 [MERGE] forward port branch 11.0 up to d277adf4d5 2018-04-06 15:36:10 +02:00
Géry Debongnie 19946294fa [DOC] doc: update/add documentation on js framework
The state of the JS documentation was quite sad, not updated in a long
time.  With this commit, we rework a lot of the JS doc.  Most notably,
we add a section 'Javascript Cheatsheet' (help on some common
customization tasks) and rewrite the 'Javascript Reference' totally.

Note that the JS reference page also contains a reference on all field
widgets.

This work is just the beginning, it is probably not complete, but at
least we will have a foundation.
2018-04-05 09:22:09 +02:00
Géry Debongnie ea6e7379a3 [DOC] doc: update/add documentation on js framework
The state of the JS documentation was quite sad, not updated in a long
time.  With this commit, we rework a lot of the JS doc.  Most notably,
we add a section 'Javascript Cheatsheet' (help on some common
customization tasks) and rewrite the 'Javascript Reference' totally.

Note that the JS reference page also contains a reference on all field
widgets.

This work is just the beginning, it is probably not complete, but at
least we will have a foundation.
2018-03-30 14:11:49 +02:00
Martin Geubelle 6676c3b189 [IMP] web: override size attributes in image widget
Size attributes (e.g. `max-width`) are sometimes set in css (i.e. with classes,
see `oe_avatar`).

They must however be overriden if they are specified on the widget.

Example:
  <field name="image" widget="image" class="oe_avatar" options="{'size': [180, 180]}"/>

The `max-width: 90px` set on oe_avatar must be overriden in this case.

Note that the attribute `img_width` and `img_height` have been depreciated as
`width` and `height` are fulfilling the exact same purpose.
2018-03-28 14:02:00 +02:00
Christophe Simonis b51f2d38c2 [MERGE] forward port branch saas-11.2 up to 500e3f4970 2018-03-21 11:04:48 +01:00
Christophe Simonis e0345a4a3f [MERGE] forward port branch 11.0 up to 2835d29979 2018-03-20 11:45:11 +01:00
Géry Debongnie 64d47c0bc5 [IMP] update ace editor to v1.3.1
Note that we do not do a custom build anymore, since we lazyload the
files anyway.  A custom build will save a few kb, but will not do any
meaningful change to the user experience.  However, it dies impact
negatively our ease of maintenance, so standard build it is.
2018-03-14 09:02:16 +01:00
Aaron Bohy a0b06afcf3 [FIX] web: 'toggle_button' widget in edit mode
The 'toggle_button' widget is one of special field widgets that
can trigger changes in readonly mode (in this case, toggle the
boolean value when clicked). It was working fine in form views in
'readonly' mode, as in this case, the new value is saved directly,
and the form view is re-rendered (a new widget is created with the
new value).

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

Fixes #23400
2018-03-12 12:56:00 +01:00
Ankit Sathvara 6be9fa3967 [IMP] web,hr: Phone widget is always clickable
With this commit, when a phone number is clicked (in readonly),
 - if voip is not installed, it opens an app according to the user
   choice (e.g. skype), and on mobile, it opens the phone app to
   call the number
 - if voip is installed, in desktop, it opens voip, and on mobile,
   it still opens the phone app to call the number, because webRTC
   is not supported.

This commit also makes the employee form view use the phone widget
for the 'Work Phone' and 'Work Mobile' fields.

Task #30369
2018-03-02 15:45:42 +01:00
Martin Geubelle a7b521fe44 [MOV] web, mrp: move pdf_viewer widget
This widget is generic enough to be used in other modules than mrp so
we move it in the web module.

Closes #22569
2018-02-12 11:16:21 +01:00
Dhaval Panchal 197a5f3887 [IMP] account: Display full instead of cut bullets on dashboard graphs
Purpose
=======

http://nimb.ws/q12J40
Bullets are cut in the middle, improve so we can see the full bullet.
2018-02-07 14:32:17 +01:00
Christophe Simonis e00a447e2c [MERGE] forward port branch saas-11.1 up to 7e469eb77a 2018-02-01 18:20:28 +01:00
Christophe Simonis 7e469eb77a [MERGE] forward port branch 11.0 up to f5e7b86686 2018-02-01 18:15:21 +01:00
Aaron Bohy cf178a2f06 [IMP] web,*: config: add XXS size to config.device
In Less, the size_class XXS is defined and used in media queries.
This rev. adds it in JS for sake of consistency.

Code in addons comparing the size_class needed to be adapted due
to the new XXS size_class.

Moreover, we now use the helper 'config.device.isMobile' everywhere
we should, instead of manually comparing the size_class.

Finally, we changed the way the config.device has to be specified
in the test environment. From now on, only the size_class should be
set, and the isMobile flag is computed automatically.
2018-01-26 19:26:03 +01:00
Géry Debongnie 21c1b1acd3 [FIX] web: add target=_blank to url field widgets
Url in the web client are supposed to open in a new tab.  This was the
way it worked in v10.0 and was lost with the refactoring of the new
views.

We just reintroduce that behaviour with this commit.

Closes github issue #22389
2018-01-25 16:31:06 +01:00
Christophe Simonis fa1f2132e7 [MERGE] forward port branch 11.0 up to 950d9b2369 2018-01-22 17:47:32 +01:00
Alexandre Kühn 2a5488619d [FIX] web: disable {bin_size: true} on binary fields
Revision on 41fe7f9d11

This commit intended to reduce the network load when reading records with
binary fields. This was made possible by enforcing the contextual key
`bin_size` to be set for records with binary fields.

However, it is causing some issues (see #22222, #22231) which are:
    - write with bin_size:true generates a traceback
    - read/search_read with bin_size:true breaks some images
      on some views (e.g. base.view_partner_form)

Since the problems outweight the gain of these changes, we revert them.
2018-01-15 10:03:14 +01:00
Christophe Simonis 56974322f8 [MERGE] forward port branch 11.0 up to 3b80a059ff 2018-01-12 19:03:00 +01:00
Alexandre Kühn 41fe7f9d11 [FIX] web: contexts on field widgets + enforce bin_size for binary
Field widgets now have a key 'context' that let them
extend the context of the dataPoint (e.g. list).

In particular, widgets on binary fields enforce the contextual
item {bin_size: True}, so that the server gives the size of the
binary field as its value, instead of its content.

This change on binary fields reduces network load when accessing
a view with binary fields.
2018-01-12 16:12:49 +01:00
Alexandre Kühn 7813a8e714 [FIX] web: binaryfile field in list views
Revert partially 255e8ca3d9

Removed widget 'download_link', as it was a sub-version of widget 'binary':
it did the exact same thing (representation of binary fields by means of a download link)
in a much better-looking way (download icon + filename as text of the download link,
instead of just a download link with text "Download").

Also, the values of binary fields might be already a human-readable binsize (e.g. 2.52 MBs),
instead of its plain textual string representation in base64:
The contextual parameter 'bin_size', when set to true, does not download the data of binary fields.
As a consequence, the server provides the sizes of the binary, instead of their value.
2018-01-12 16:12:49 +01:00
Christophe Simonis 228ecdbe28 [MERGE] forward port branch 11.0 up to ff0abd214c 2018-01-10 11:41:35 +01:00
Alexandre Kühn 255e8ca3d9 [FIX] web: binary field format in list view
Binary fields were simply shown simply by their textual representation in list views,
e.g. the base64 string.

There was no formatter for binary fields, therefore it has been implemented so that
it displays its estimated size.

Binary fields in list views had a download link in v10.0.
We provide this feature back by means of a widget called 'download_link'.
It is also possible to define an option to set the field name having the filename as its value.

Example:

    <tree>
        <field name="fname"/>
        <field name="datas" widget="download_link" options="{'filename': 'fname'}"/>
    </tree>

with the following record: {fname: 'document.txt', datas: 'Cg=='},
we get a file named "document.txt" by clicking on the download link.

Closes #21996
2018-01-08 10:17:44 +01:00
Nicolas Martinelli 38e73da092 [IMP] web: support variable digits
In v10, a `Float` field with `widget="monetary"` option uses the decimal
precision of the field. In v11, however, it uses the decimal precision
of the currency. However, in many cases `widget="monetary"` is used in
the sole purpose of displaying the currency symbol. The precision of the
field sould be kept.

This commit introduces the support of the decimal precision of the field
for this specific use case thanks to the `field_digits` option:

```
<field name="pouet" widget="monetary" options="{'field_digits': True}" />
```
If such an option is used, the field precision will prevail over the
currency precision.

Related to #21686
opw-800279
2018-01-04 11:32:04 +01:00
Christophe Simonis 362f0489d0 [MERGE] forward port branch 11.0 up to fe22a0f9ca 2018-01-03 12:28:52 +01:00
Nicolas Martinelli 88afd055cf [FIX] web: currency digits
- Set the currency rounding to 0.001 (3 digits)
- Create an account move
- Add an account move line, set an account

When switching from edit/read-only mode, the rounding switches from 2 to
3 digits.

This is because, in edit mode, the format method is the method of the
float widget. Therefore, in this case, the formatting doesn't take into
account the currency rounding.

To avoid this, we simply use a `noSymbol` flag to avoid adding the
currency symbol, while keeping the monetary rounding.

opw-800279
2017-12-29 09:20:18 +01:00
Christophe Simonis 8ef7af6afe [MERGE] forward port branch 11.0 up to f96a797fe6 2017-12-06 12:02:58 +01:00
Christophe Simonis f96a797fe6 [MERGE] forward port branch saas-16 up to b8540eefe3 2017-12-06 11:59:38 +01:00
Lucas Perais (lpe) 519555054a [FIX] web: BinaryFile not download when new record
Let's have:

- on res.company a binary file field named x_file
- on res.users a related binary field to company_id.x_file, and make it readonly
- On the res.users form view, display the new field
Before this commit in create mode, upon clicking on download the file, the server crashed, because the record id was empty.
Then, the JS crashed in turn because of the unhandled 404 from the server.

Since the id of a new record will always be unset, we choose to disable the download option in this very specific case

OPW 777042
2017-12-05 08:19:08 +01:00
Christophe Simonis a8d01cbf4e [MERGE] forward port branch saas-15 up to a447da75fd 2017-12-04 20:12:19 +01:00
Géry Debongnie 5faec34a3c [REF] web: update widget to new guidelines
- make delegate/undelegate events private
- remove $el before start
- make replaceElement private
- remove one _ from __render_and_insert... method
- update documentation
- remove make and improve make_descriptive (also, it is private)
- ...
2017-12-04 10:03:00 +01:00
Christophe Simonis 29590a61cd [MERGE] forward port branch 11.0 up to 8fb25e185b 2017-11-28 16:57:58 +01:00
Alexandre Kühn fb6c9c2443 [IMP] web: FieldChar trim its value by default
With this commit, we change the behaviour of the web client with respect
to spaces in char fields.  Most of the time, starting and ending spaces
have no value, and worse, make the data not so reliable.

After this commit, field char will trim by default (so, if the user input a
char as ' abc ', the string 'abc' will be sent to the server instead).
Note that this only applies when the value of the field is changed.  If
someone open a form view, then switches to edit mode and save, nothing
will change.

This is the desired behavior most of the time.  However, in some rare
cases, this is actually harmful.  For example, if we trim the
'decimal_point' field, it will not be possible to enter a whitespace as
decimal separator.  In those cases, we introduce a new attribute 'trim',
which allow the developer to desactivate that feature.
2017-11-24 13:09:10 +01:00
Alexandre Kühn 732f176fe1 [FIX] web: readonly monetary field onchange currency
Before this fix:
    A readonly monetary field was not updating
    its currency symbol when selecting another currency.

Scenario:
    1. Activate multi-currency with $ (default) and €
    2. In hr_expense, go to My Expenses to Submit
    3. Create a new expense
    4. Select 'EUR' as currency
        => Unit Price is correctly updated with €, but not Total.

With this fix:
    Total displays the correct currency in edit mode.

Explanation:
    Monetary fields in readonly are relying on _formatValue() to
    display their value.
    _formatValue() uses this.formatOptions.currency, which stores
    the currency at loading of the field. We must update its value
    whenever there is a change of currency.

opw-783378
2017-11-22 14:16:00 +01:00
Aaron Bohy 995610c065 [FIX] web: JournalDashboardGraph widget crash
The JournalDashboardGraph requires nv, which is lazyloaded. Before
this rev., a crash occurred when this widget was instantiated and
destroyed before the loading of the lib was complete (because a
function of the lib was called in destroy()).

For instance, press F5 (to ensure that nv isn't already loaded),
activate some throttling in the network tab, go to Accounting and
as soon as the dashboard shows up, click on another menu.

opw 781628
2017-11-13 11:18:56 +01:00
Christophe Simonis e918271f76 [MERGE] forward port branch saas-16 up to 8fdac4b6b2 2017-10-27 14:09:20 +02:00
Lucas Perais (lpe) f45edfbe6d [FIX] web: image widget is dependent on its record's last_update
As a way to optimize loading, images are not necessarily fetched in db.
They have, in their url a "unique" parameter, which is the last_update date on **the record** and controls on the python-side whether it should get the image from a cache or from the db.

Before this commit, this __last_update field wasn't present in the view, so it wasn't fetched, and writes on a model's image worked but did not refresh.
The image displayed was the old one.

After this commit, when the image field widget is present, we force the loading of the __last_update field of the record.
Upon update, the image displayed is the new one.

OPW 777552

closes #20457
2017-10-25 16:39:52 +02:00
Christophe Simonis 693f8dc68a [MERGE] forward port branch saas-16 up to 7bfde6e05d 2017-10-25 14:57:24 +02:00