Commit Graph
141 Commits
Author SHA1 Message Date
svs-odoo 74fcd3ac3b [IMP] web: FieldInteger and FieldFloat can use input of type number
This allow the browser/device to handle the experience of handling number in a more native way.

FieldInteger and FieldFloat now inherits from NumericField because we want
to format it or not dependent of the view (readonly or edit) and the
NumericField will manage it.

We do that because input type number can't take a value with comma on Chrome
(FireFox is more permissive but not perfect because comma is the separator
for decimal in this case).

Task #1880376
2018-09-07 16:18:45 +02:00
qsm-odoo 9fc771dd5d [FIX] web: BS4, restore slider checkboxes
Take advantage of the new BS4 checkbox structure to simplify the
widget too.
2018-08-23 16:45:40 +02:00
Sébastien Theys 416b810eb5 [FIX] web: prevent textarea vertical resize on chrome
Since we correctly compute the height of the field, we don't want to let the user resize it vertically.

This was already working on Firefox because it doesn't require the field to be in the DOM to read the resize attribute, but Chrome does require the field to already be in DOM.

Task: 1869469
PR: #26518
2018-08-22 14:10:06 +02:00
Sébastien Theys 14b9e9c92d [FIX] web: give correct size to o2m textarea at init
Before this commit, a textarea inside a one2many would only have the correct size after focus or on change.

When we select a line, we want all of the textarea of the line to have the correct size even if they are not directly focused.

Task: 1869469
PR: #26430
2018-08-22 11:51:30 +02:00
Sébastien Theys 289adeb63f [FIX] web: properly resize textarea when its value changes
Before this commit, a textarea would not resize when its value changed if the event was different than "input" or "focus".

This commit fixes it by also listening to the "change" event, and by triggering it at appropriate times.

PR: #26430
Task: 1869469
2018-08-22 11:51:30 +02:00
Sébastien Theys 4310b11df5 [FIX] web: compute the correct height for textarea autoresize
The box-sizing property was not correctly taken into account.

- content-box is the standard behavior: border and padding are added after the height
- border-box needs attention: border and padding must be included into the computed height

Task: 1869469
PR: #26430
2018-08-22 11:51:30 +02:00
Vandan ShahandMohammed Shekha f4ee61f950 [IMP] web: mobile: add swipe support in form views
This rev. allows to navigate, in mobile, through records in form
views by swiping.

We also moved mobile-specific tests involving a form view to the
mobile test suite, since those tests became async because of the
lazy loading of the swipe lib (in the mobile suite, that lib is
already loaded).

Related to task #34727

Co-authored-by: Mohammed Shekha <msh@openerp.com>
2018-08-20 21:11:54 +02:00
Alexandre Kühn ccd94a1588 [REV] "[FIX] web:tests: do not rely on testUtils.patch in tests"
This reverts commit f1a0a32e46.

This utility function has been fixed with commit 1edea9326c
2018-08-17 16:21:39 +02:00
Alexandre Kühn f1a0a32e46 [FIX] web:tests: do not rely on testUtils.patch in tests
Revision on https://github.com/odoo/odoo/commit/10f43955d81ff3e7b5ab050656b312ec19f927c5

Commit above uses `testUtils.patch` in the test.
However, this utility function does not seem to work.

That sucks...
2018-08-16 18:38:49 +02:00
Alexandre Kühn 10f43955d8 [FIX] web: render JournalDashboardGraph when in DOM
The lib 'nvd3' renders graph when they are attached to the
DOM. However, widgets are rendered in fragments and
appended to the DOM when ready (to prevent flickering).

Before this commit, we used a `setTimeout(0)` and cross
fingers that the widget was attached to the DOM when the
`render` method was called.

With this commit, the render method is called when it is
attached to the DOM.

Task-ID 1868252

Closes #26410
2018-08-16 16:52:56 +02:00
Christophe Matthieu 61eef73b52 [IMP] base, *: use a many2one for the company report layout
Before this rev. one could set the report layout on the company using a
hardcoded list (background, clean, standard, etc.). Other modules (typically
accounting modules) could add options in this list. The used template was built
on the layout key.

Now, the layout is a many2one field to a newly created model `report.layout`,
which is linked to a view with the layout architecture.

This gives more control to customize reports and create a new layout (without
creating a python module that extend the layout selection).
2018-08-13 17:09:28 +02:00
jem-odoo 1f72644c44 [IMP] web: float_factor and float_toggle widgets
This commit provides new js widgets for list, kanban and form
views on float field.

1/ 'float_factor' displays the normal float field, but takes a
conversion factor as option. The displays value is the normal
one multiplied by the factor.

You can use the widget like
<field name="my_float_field" widget="float_factor"
option="{'factor': 2}"/>

2/ 'float_toggle' displays a button (in edit mode) looping on a
range of given value at each click. A conversion factor is optional
(default will be 1) to display a converted value, but sent to
non converted one to the server.

You can use the widget like
<field name="my_float" widget="float_toggle"
option="{'range': [0, 0.5, 1], 'factor': 2}"/>

'range' and 'factor' are put in the options.
In simple read mode, the widget display the value as a traditionnal
text (like a normal char field).

This commit provides tests and documentation for those 2 widgets.

Task #39079
2018-08-13 14:33:48 +02:00
Mitali Patel 84f528bcff [IMP] Portal - Share link : Easily share the url of a document
Purpose
=======
- Quickly share the url to someone else (a client, a colleague,...)
- Ensure that the recipient can access at least
  the portal view of the shared record.
- Typically used when a client cannot retrieve the mail to access his order.
  The share link can be used in this case.

Specifications
==============
For any object inheriting form portal.mixin:
    - Add a button SHARE (not visible in edit mode)
    - When clicking on this button, a popup opens with :
        - A warning message for tasks and projects only (see below)
        - the link (like in gmail) that can be copied
        - Recipients
        - mail composer (with preselected template) ==> see below
        - button [Send Link] [Copy Link] Discard
        - After sharing document, put internal note like
          "Document shared to xyz,...." with template message
    - Anyone with the link, even anonymous user (not logged in) can have access
      to the document with the access token provided in the url.

Impacted models:
    - account.invoice (Community)
    - project.project (Community)
    - project.task (Community)
    - purchase.order (Community)
    - sale.order (Community)
    - helpdesk.ticket (Enterprise)

Warning messages and access rules:
    Allowed :
        - SO canceled or draft will be accessible with the link
          with access_token
        - If the customer account is B2B (signup not enabled), the recipient
          will anyway see the document as the user specifically wants the
          recipient to see the document.
    Restrictions :
        - For Project and Task, if the privacy is not public, then, there is a
          contradiction between the access_token mechanism
          and the privacy of the document.
        - A warning message will be displayed in the share wizard to inform the
          user if the document cannot be visible by the recipients and to
          ask him to set the privacy to 'Visible by following customer'.
          The send button will, in that case, be hidden.
        - To avoid to block the share for a new project, default privacy value
          is now set to 'Visible by followong customer'

Technical implementation
========================
- Move the access_token mechanism (field + methods + mail controller)
  to the portal.mixin to be able to use it in a generic way for each object
  inheriting the portal.mixin
- Generalise a part of the _*model*_get_page_view_values method
  into a single one in portal
- Generalize the _*model*_check_access into the portal controller of the
  portal module
- Remove the init_column + default value for the access_token
  > old records have an access_token,
  > new one won't but it will be generated on demand via the get_access_token
  Done for performance reasons
- Add share button into action menu separately. + kanban view context menu
  (except for task and project where button not in action menu but 'simple'
  button for task and project because other modules already provide action
  to send documents by email, which is not the case for project and task.)
- Add a sign_token used to authentify the recipient in the portal view chatter,
  if any. The message will be posted as if the user was logged in.
- Set the _get_share_url as private for security reason
- Add a redirect parameter to _get_share_url to get
    If false : The direct portal view url
    If True : The redirect url (mail/view/?)
- Cleaning up unnecessary code

- Bug fix :
    - Before, if user was not logged and record had partner_id,
      if partner id was null, post message was done as admin.
      Now, the post message is done as public user.
    - If the user had an uid but had no access_token, he could be able
      to gain the access token of the record.
      check_access_rights was missing in the get_access_action.

Task ID : 30985
Closes #25629
2018-08-03 15:20:42 +02:00
Christophe Simonis 4797627259 [MERGE] forward port branch saas-11.4 up to 8d9366197e 2018-08-01 18:02:29 +02:00
Christophe Simonis a719cf2563 [MERGE] forward port branch saas-11.3 up to b4555df336 2018-07-30 17:02:28 +02:00
Alexandre Kühn 66dd126053 [FIX] web: empty input for empty password field
Revision on https://github.com/odoo/odoo/commit/4b3588feb2b7e260bf237b0f3944c90cdc47c3b5

In order to not replace characters with '*' in edit mode (because of `input`
with type 'password'), the above commit did not format the value at all.
The formatter of a char with the option 'isPassword' turns all of its
characters into '*'. That is not intended for password inputs, because the
content is hidden by the browser with the 'password' type.

The issue with not using the formatter is that an empty field has the value
`false`, so an empty password field produces an non-empty password input with
its value to 'false'.

This commit fixes the issue by forcing empty string for empty password values.

Note: if you use an integer field with password, falsy values (e.g. `0`) become
empty strings in the input value.
2018-07-27 18:20:02 +02:00
Alexandre Kühn 4b3588feb2 [FIX] web: edited password fields should not contain '*'
Before this commit, when someone was editing a password, the stored
password may not be the expected one by the user.

Steps to reproduce:

	1. Open "Outgoing Mail Servers" form.
	2. Set a password (e.g. "yop").
	3. Save, then edit.
	4. Add "y" at the end of the password field.

	> Expected value: "yopy"
	> Actual value: "***y"

This is due to the use of the char field formatter, which displays passwords
by replacing the characters with '*'. It is not necessary to do this in edit
mode, because it uses an input field of type 'password'. The browser
automatically hides the value of such inputs.

Any changes on a input field in edit mode uses the value of the input, so the
value of an password input should contain the password, without '*'.

This commit fixes the issue by using the formatter in edit mode for the input
of type 'password'.

Task-ID 1869565
2018-07-27 15:02:49 +02:00
qsm-odoo ee65b44d9e [REF] *: BS4, adapt the label component structure
The '.label' elements have been replaced by '.badge' elements without
the 'badge-pill' class.
2018-07-27 12:36:54 +02:00
qsm-odoo f4fbaf1efa [REF] web, *: BS4, use custom BS4 checkbox everywhere
Before this commit, Odoo used checkboxes in three different ways:

- A simple <input type="checkbox"/>, mainly in the frontend. The style
  is browser dependant.

- Same as above but with the BS3, checkbox structure. The style is still
  the same, but the alignement is supposed to be better (which is not
  always the case).

- The Odoo official structure:
	```
	<div class="o_checkbox">
	    <input type="checkbox"/>
	    <span/>
	</div>
	```
  which allows to have a cross-browser checkbox style and correct
  alignements.

The goal after this commit is to only use the BS4 *custom* checkbox
structure to achieve the same goal as our official structure (and
remove that one):

```
<div class="custom-control custom-checkbox">
  <input type="checkbox" class="custom-control-input" id="customCheck1">
  <label class="custom-control-label" for="customCheck1">...</label>
</div>
```

/!\ Labels are now required (use a zero-width space if necessary)
2018-07-27 12:36:54 +02:00
qsm-odoo de214e3742 [REF] *: BS4, 'img-responsive' -> 'img-fluid' 2018-07-27 12:36:54 +02:00
qsm-odoo 1c1c0897e8 [REF] *: BS4, adapt dropdowns and carets
- The dropdown structure was simplified, allowing to get rid of the
  3-levels structure induced by <ul/> elements and dropdowns can now
  contain anything. The class 'dropdown-item' is now mandatory for
  each dropdown clickable element. The class 'dropdown-item-text' can
  be used to add same padding and style but without making the element
  have a clickable look.

- Dividers now use the class 'dropdown-divider'

- The way dropdowns are opened and hidden also changed (before the
  'open' class was added on the `.dropdown-menu` parent, now the
  'show' class is added on both the `.dropdown-menu` parent and the
  `.dropdown-menu` itself).

- JS-wise, no click event handlers can be put on `.dropdown-toggle`
  elements anymore (instead, use handlers for dropdown events).

- Carets are automatically put on `.dropdown-toggle` elements, so this
  commit replaces the `.caret` elements with this. This feature was
  possible to disable but would prevent us from adding a caret with
  scss. Also, this simplifies the DOM. The 'o-no-caret' class was also
  introduced to allow using the 'dropdown-toggle' class on non-caret
  elements.

- Also adapt the scss to use $caret-width instead of $caret-width-base
2018-07-27 12:36:54 +02:00
qsm-odoo f2a1ca1f04 [REF] web, *: BS4, update JS media queries
* website_quote, website_sale
2018-07-27 12:36:54 +02:00
qsm-odoo 6692919d1e [REF] web, *: update bootstrap-datetimepicker to tempusdominus
* website_form, debian

Our old library for datetimepicker for bootstrap 3 is deprecated and
an updated version is developed by the same team under the new name
"tempusdominus", for bootstrap 4.

The lib is imported by taking the *unminified build* JS and the *src*
scss. Odoo is also bundling the lib better by putting the scss file
in both backend and frontend assets instead of only in common (so that
the scss is compiled differently for the frontend and the backend).

Note: the lib also needed to be patched inline to solve a bug at one
line.
2018-07-27 12:36:54 +02:00
Christophe Simonis ba202dbe63 [MERGE] forward port branch saas-11.2 up to 3c521f6d05 2018-07-24 18:10:32 +02:00
Christophe Simonis 4e76173a43 [MERGE] forward port branch 11.0 up to 219d2296d6 2018-07-23 16:03:25 +02:00
eco-odoo 872cf9160d [FIX] web: controller update now waits for _update to resolve
Before this, the deffered returned by _update was not taken into
account.
2018-07-20 11:59:12 +02:00
eco-odoo 0dd6a0b2bf [IMP] web: core: ajax: loadCSS now returns a promise
It is useful to know when the stylesheet has been loaded in order to prevent displaying unstyled content.

CalendarView and the dashboard_graph widget (JournalDashboardGraph) use loadCSS through cssLibs / loadLibs so the tests now have to use createAsyncView instead of createView.
2018-07-20 11:59:12 +02:00
len-odoo bc12428e17 [FIX] web: format value of statinfo widget
The value of the statinfo widget is rendered by the qweb after a t-esc.
Say if the python rounding returned 14.0000000001
(supposed to be a two digits precision number through the magic of floats)
then the statinfo widget would print it as-is.

We now format the value at assignation.

opw 1865426
2018-07-19 13:19:09 +02:00
qsm-odoo 2c966909e2 [FIX] *: fix some side-effects of https://github.com/odoo/odoo/commit/9de1bc0eef6f5bfaa2a8d745431caa361ae91548
- JS Modals were not correctly built anymore, their .modal-body element
  was duplicated and many without-effect JS lines were introduced (as a
  side effect, the form view design was broken when inside modals)

- Tests were changed to make bugs go unnoticed. For example, the media
  dialog functionnality was entirely broken because the .modal-dialog
  element was not receiving the correct class anymore.

- The JS translation function is _t, not _

- Do not use the <title/> tag as a regular DOM element, it is meant to
  be unique, in the <head/> section

- CSS rules were added to the utils.scss file, which is meant to contain
  functions and mixins, otherwise, the rule is duplicated in every asset

- Some icons were still broken, as missed by https://github.com/odoo/odoo/commit/f90cf060a3cfeb37a67bec83264c0aaab8892b56

- Tests were changed to use [role="dialog"]/footer/header in their
  selectors without any reason, this commit restores some of that to
  avoid rebase conflicts with the BS4 work.

- ...

Note: other elements should still be discussed, like the direct use of
the 'o_form_label' class in views definition... but those do not cause
direct problems.
2018-07-09 11:59:30 +02:00
Yannick Tivisse 15f3bbe594 [MOV] web,im_livechat: Move clipboard widget to web 2018-06-27 14:42:04 +02:00
kujiu 9de1bc0eef [IMP] Improve compatibility with screen readers (accessibility) (#24574)
Today, Odoo is really tricky to use without seeing the screen, it must be improved to be usable.

This PR forbid to use labels without a "for" attribute, add some title, rule and aria attributes in HTML. With that, Odoo will be fully usable with a screen reader.


* [IMP] Labels must have a for attribute. Improve accessibility.
* [IMP] Better error message when trying to read a missing cached value
* [FIX] Add some aria-label and title attributes for screen readers.
* [FIX] Template name is not included in the error message in case of SyntaxError in QWeb
* [FIX] Improve the Tour failed at step error message to be more explicit.
* [IMP] Add aria-labels
* [FIX] Add missing aria-label on failing test
* [IMP] aria-hidden means hidden. Fix all bad aria-hidden and hide aria-hidden for all.
* [IMP] Color names on kanban views and many2many tags
* [IMP] Add some checks on views for accessibility.
* [IMP] Add `alt` attribute on `img` tags.
* [IMP] Add aria-label and title on non-described icons
* [IMP] Add button role to widgets with btn class
* [IMP] Translate aria and formatted attributes.
* [IMP] Remove wrong aria-labelledby
* [IMP] Add menu role on dropdowns
* [IMP] Buttons must be focusable
* [IMP] Add aria attributes on progress bars
* [IMP] Improve accessibility of basic widgets
* [IMP] Change main layout to more semantic tags
* [IMP] Add menuitem role when missing
* [IMP] Remove wrong role='presentation'
* [IMP] Improve accessibility of tab panels
* [IMP] Add aria-invalid on invalid fields
* [IMP] Add aria-sort on ordered columns
* [IMP] Add role on alerts
* [IMP] Use dialog role, header, main and footer tags for modals
* [IMP] Add labels on o_status
* [IMP] Improve accessibility of kanban view with feeds and articles
* [IMP] Add alerts in case of new messages
* [IMP] Add widget, navigation or img role to aria-labelled items
2018-06-22 21:22:21 +02:00
Christophe Simonis e56be854ab [MERGE] forward port branch saas-11.3 up to 204935119d 2018-04-19 11:58:44 +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
qsm-odoo 1a007c1a96 [REF] *: stop mentioning "LESS" where this is not required
* web, web_editor, website, im_livechat
2018-04-18 15:59:07 +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
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
Christophe Simonis 860dfb5586 [MERGE] forward port branch 11.0 up to d277adf4d5 2018-04-06 15:36:10 +02:00
Goffin Simon 1039abfbdb [FIX] web: time format without seconds
Steps to reproduce the issue in 11.0 Enterprise:

- Go to the language English
- Remove from the time format the seconds
- Refresh the page
- Go to sales
- Create a sales order;

Bug:

- You get the warning message

closes #23596 closes #22027
opw:1829577
2018-04-03 09:19:34 +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
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
Aaron Bohy 5c67abd0d3 [REF] web: tests: move calls to removeSrcAttribute
In the tests environment, we listen to the 'DOMNodeInserted' event
to remove the src attribute of img and iframe nodes as soon as they
are inserted into the DOM, so that they don't perform RPCs.

However, this listener was bound in the create(Async)View, and
createActionManager helpers only. This rev. moves it to the
addMockEnvironment helper which is more global, and basically used
by all tests.

Moreover, we now listen to the 'DOMNodeInserted' event on the body,
instead of on the widget, as it may happen that some content is
inserted into the DOM outside the widget itself (e.g. dialogs are
appended to the body).
2018-02-12 11:13:42 +01:00
Christophe Simonis e00a447e2c [MERGE] forward port branch saas-11.1 up to 7e469eb77a 2018-02-01 18:20:28 +01:00