Commit Graph
136 Commits
Author SHA1 Message Date
qsm-odoo b94395b501 [IMP] web, *: share and improve notification system
* barcodes, calendar, partner_autocomplete, web_settings_dashboard

Make the notification system better, using bootstrap toast component,
and make it available in the frontend.

The toast component allowed to remove some JS code and made the
component customizable by themes but it had to be reviewed/fixed to make
it functional (maybe bootstrap will review its work in next versions).

This work should still be improved because there are still too many
ways (deprecated and not deprecated) to instantiate toasts in the
backend. The goal here was however to make the toasts more modern and
make them available in the frontend.

This work is needed for some tasks. @kig-odoo and @fja-odoo made a
pre-work to instantiate toasts in the frontend for their respective
tasks. This commit unifies the system.

Part of https://github.com/odoo/odoo/pull/32793
task-1970731

closes odoo/odoo#32793

Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2019-04-24 13:21:41 +00:00
Juhil SomaiyaandMohammed Shekha 5dc971b1ae [IMP] web, *: add a description to generic widgets
A `description` key has been added on AbstractField and all generic
field widgets ; it is used to display a more user friendly name (both in
the webclient and in Studio).

Non-generic field widgets have an empty string as description.

Related task 1918327

closes odoo/odoo#30131

Signed-off-by: Martin Geubelle (mge) <mge@openerp.com>


Co-authored-by: Mohammed Shekha <msh@openerp.com>
2019-04-24 09:57:56 +00:00
Christophe Simonis 5df4746c9a [MERGE] forward port branch saas-12.2 up to 230ad8c381
closes odoo/odoo#32088

Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-03-25 11:13:41 +00:00
Christophe Simonis c50d7d6bc5 [MERGE] forward port branch 12.0 up to 82c4393fd0 2019-03-19 15:14:23 +01:00
Christophe Simonis bd63913326 [MERGE] forward port branch saas-11.3 up to 4e39328a76 2019-03-18 20:03:24 +01:00
Adrien Dieudonne 7e33b54771 [FIX] barcodes: let focus in number, password, tel, phone inputs
Before this commit, users wasn't able to input values in some
input elements like password, email and phone in mobile.

Steps to reproduce:
- Go to user
- Select Preferences
- Select Change password
- Try to input something
=> The focus was lost and the keyboard disappeared

In fact, a hidden input always have the focus when no other fields
need it. This input is used to intercept a value from a barcode
scanner.

So now, we added some input types to avoid to set the focus on the
barcode input.

The barcode input is now always defined (even if not used in desktop)
to be able to mock a Chrome mobile environment in a test.

opw-1936712
opw-1948266

closes odoo/odoo#31841

Signed-off-by: Pierre Paridans <pparidans@users.noreply.github.com>
2019-03-18 13:16:57 +00:00
Adrien Dieudonne b2c8963357 Revert "[FIX] barcodes: let focus in number, password, tel, phone inputs"
This reverts commit 1cdf2bdaf6.
$(':focus') seems not working depending on browser version but
we don't know yet exactly why.

opw-1948266

closes odoo/odoo#31807

Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2019-03-13 09:51:14 +00:00
0ab6a62997 [REF] barcodes: adapt code after jQuery update
Part of task 1896658

Co-authored-by: Aaron Bohy <aab@odoo.com>
Co-authored-by: Christophe Matthieu <chm@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: David Monjoie <dmo@odoo.com>
Co-authored-by: Martin Geubelle <mge@odoo.com>
Co-authored-by: svs-odoo <svs@odoo.com>
Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
2019-03-06 20:07:17 +01:00
Adrien Dieudonne 1cdf2bdaf6 [FIX] barcodes: let focus in number, password, tel, phone inputs
Before this commit, users wasn't able to input values in some
input elements like password, email and phone in mobile.

Steps to reproduce:
- Go to user
- Select Preferences
- Select Change password
- Try to input something
=> The focus was lost and the keyboard disappeared

In fact, a hidden input always have the focus when no other fields
need it. This input is used to intercept a value from a barcode
scanner.

So now, we added some input types to avoid to set the focus on the
barcode input.

It's quite difficult to test this feature because we aren't allow
to simultate a keyboard to write in a input field.
See https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent
Plus, we don't have the focus in mobile except if we have the cursor
inside the window.
So, we can't test focused elements or input values.

opw-1936712
opw-1948266

closes odoo/odoo#31566

Signed-off-by: Pierre Paridans <pparidans@users.noreply.github.com>
2019-03-11 09:57:56 +00:00
Christophe Simonis 3cbc9dd6c0 [MERGE] forward port branch 12.0 up to 6a0675d36d 2019-01-14 10:34:50 +01:00
Xavier Morel 00fb73fa22 [FIX] barcodes: JS documenter fails to infer BarcodeEvents
As a result, parsing the JS fails and so does the doc compilation.

Fixes odoo/odoo#29197
Fixes odoo/odoo#29961

closes odoo/odoo#30057
2019-01-09 09:02:21 +00:00
Christophe Simonis f351dd8cab [MERGE] forward port branch 12.0 up to 047e2b28de 2018-12-12 11:38:25 +01:00
len-odoo aed0a828e4 [FIX] barcodes: allow special keys input on firefox
Install stock_barcode.
It adds a barcode to the product quantity of the inventory adjustment view.
On firefox special characters are ignored (CTRL, BACKSPACE, Fn...)

closes odoo/odoo#29245
2018-12-07 13:48:57 +00:00
Géry Debongnie abf32b8b21 [REF] *: update js test suite to use helpers
This rev. introduces robust helpers to use in the JS tests suite to
interact with DOM and components, and starts using them (almost)
everywhere.

All the helpers are exposed though testUtils.js.

There are 2 kinds of helpers:

1. Assertions
-------------
 * assert.containsNone, containsN, containsOnce check that the DOM
   (or a specific part of the DOM) contains a `selector`. It
   generates a correct error message automatically.
    ex: assert.strictEqual(form.$('.o_form_editable'), 1, "msg");
        -> assert.containsOnce(form, '.o_form_editable');
 * assert.isVisible, isNotVisible check that the DOM has an element
   visible or not. They also check that the element is actually in
   the DOM (before most tests didn't verify this).
 * assert.hasClass, doesNotHaveClass, hasAttrVAlue, check specific
   properties of a DOM element, and also validate that it is
   applied on a single existing DOM element (before most tests
   didn't verify this).
    ex: assert.notOk(form.$('button').hasClass('btn-primary'));
       -> assert.doesNotHaveClass(form.$('button'), 'btn-primary');

2. Utilities
------------
The goal of the utilities is to centralize the definition of many
standard components and interactions, ensuring that when we
refactor the JS framework, we do not need to change all the tests.

Existing mock utilities (addMockEnvironment, intercept, path,
patchDate, unpatch and fieldsViewGet) are moved to
'testUtils.mock.*'.
Existing DOM utilities are moved to 'testUtils.dom.*'.
New dom utilities are created for opendDatePicker, click,
clickFirst and clickLast. Helper `click` verifies that there is
exactly 1 element visible in the DOM you click on, `clickFirst`
and `clickLast` verify that there are more than one element on the
DOM.
 ex: form.$('button').click();
     -> testUtils.dom.click(form.$('button'));

New Form utilities: (testUtils.form.*)
 clickEdit, clickSave, clickCreate, clickDiscard, all clicks on
 the control panel buttons of the form.
 `reload` reloads the form data.

New modal, graph, kanban and pivot utils (testUtils.pivot.*,
testUtils.kanban.*, etc.).

New fields utils: (testUtils.fields.*)
 * editInput, editSelect: allow to change the value of a field,
   using a selector to identify it. They validate that the input
   exists and trigger the change event automatically.
 * editAndTrigger: allow to modify a field and trigger specific
   events after the value change
 * many2one (testUtils.fields.many2one.*)
   clickOpenDropdown, clickHighlightedItem, clickItem,
   searchAndClickItem: use a field name instead of a selector and
   do all the complex mechanism to open, filter and highlight
   many2one fields.

Joint work with aab, dam, ged, mge, svs and vsc.
2018-11-19 11:24:28 +00:00
Simon Lejeune 2d92febaf7 [FIX] barcodes: don't listen to barcode in input number
related to rev 74fcd3ac3b
2018-09-11 13:58:20 +02:00
Christophe Simonis 7499b47ffa [MERGE] forward port branch saas-11.4 up to edd586002e 2018-08-10 13:37:21 +02:00
Christophe Simonis 7717f082c0 [MERGE] forward port branch saas-11.3 up to af35aea6b0 2018-08-09 19:33:32 +02:00
Christophe Matthieu a8e4e625f4 [IMP] web: remove useless service name
We use the registry keys as name for the services.
2018-08-09 02:31:59 +02:00
Christophe Simonis 4c2bdafe69 [MERGE] forward port branch saas-15 up to e7ccf38c48 2018-08-08 18:42:27 +02:00
Nicolas Lempereur 8ff138a0da [FIX] barcodes: ok PageUp/Down/Home/End in firefox
Same reason as 8d948d92.

In firefox if barcode is installed, for example on a form view the keys
to navigate the possible scrolling PageUp/PageDown/Home/End don't work
at all.

This is caused by the interface barcode catching and differences of the
key event handling between firefox and other browser.

So in this change, we add these keys so they are not catched by barcode.

note: aso backport 5bc29744c so the code is the same between 10 and 11.

related to opw-706352
closes #26219
2018-08-08 09:11:06 +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
Fabien Pinckaers bed29a4aea [IMP] product: Unify/Clean product demo data
PURPOSE
=======

1. Unified product demo data
2. Less demo: one per use case
3. Demo data for all models

Specification
=============

1. Refactor all the brol in the demo data
2. Adapt the tests to make them green, as some products are
   renamed, removed, created in python instead of as demo data
   ...
2018-07-05 08:57:41 +02:00
Christophe Simonis 49edee1f4b [MERGE] forward port branch saas-11.4 up to d54a3726ec 2018-06-29 12:46:00 +02:00
Christophe Simonis c8bb02141d [MERGE] forward port branch saas-11.3 up to 3cdcbce93c 2018-06-28 19:01:52 +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
Nicolas Martinelli 1fe119da3b [FIX] barcodes: nomenclature
Loads the barcode nomenclature only if one has been is defined. Indeed,
from commit 80e89c7a11, the POS config unset the
`barcode_nomenclature_id` field if the barcode support is not activated.

opw-1859928
2018-06-21 10:40:59 +02:00
Simon Lejeune 5dc9230c6e [FIX] barcodes: barcode input
If the barcode input is hidden, it isn't possible to focus it and thus
it isn't possible to actually use it.

related to rev b4a8338959
2018-06-20 14:46:30 +02:00
Julien Machiels e9901d1422 [FIX] barcodes: barcodes working in button in dropdown
On mobile, some barcodes didn't trigger in the picking screens, notably
O-BTN.validate. This is due to the use of parent() to check if the
button is in a dropdown, as parent() only checks one DOM-level upwards.
The button being inside a <ul><li>, we need to check more levels than
one to pass the condition and trigger the button press.

By changing parent() to parents(), the entire chain will be checked, not
just one level, and the button press is correctly triggered.

opw-1860964
closes #25941
2018-07-24 14:45:57 +02:00
Adrien Dieudonne b4a8338959 [FIX] barcodes: hide barcode input 2018-06-11 17:01:33 +02:00
Simon Lejeune 17984be82c [REF] barcodes: form view: better error messages 2018-06-11 16:18:18 +02:00
MOENS Alexandre d13fb14f1e [REF] barcodes: pager: warn if a pager isn't present
If a barcode triggering an action on the pager was scanned while a pager
wasn't present in the page (see the workorder tablet view), a traceback
happened.

We display a warning instead.

Task: 1831245
2018-06-11 16:18:18 +02:00
MOENS Alexandre defff5f191 [REF] barcodes: form view: multiples button for a single trigger
This commit allows multiple button to share the same `barcode_trigger`
attribute. Note that it only makes sense if a single button is displayed
at a time.

Task: 1831245
2018-06-11 16:18:18 +02:00
Christophe Simonis 2ab7ad8361 [MERGE] forward port branch saas-11.3 up to c00df14654 2018-06-07 11:43:07 +02:00
Adrien Dieudonne a30d9aa560 [FIX] barcodes: avoid virtual keyboard to show up while scanning barcode
(1) Before this commit, the input barcode was removed from the dom
after each scan but now we want to keep it focused to avoid to
automatically open the virtual keyboard in mobile.
This behavior will be useful in enterprise only.
Another commit will follow in this repository.

As the input is not removed anymore, we had to disable autocomplete
to hide previous entries as suggestions.

(2) We also add z-index property to avoid to click on the hidden input
located in the middle of the page.
2018-05-30 14:13:28 +02:00
Christophe Simonis f36e6917bd [MERGE] forward port branch saas-11.3 up to 37eed7c509 2018-05-29 17:34:43 +02:00
Adrien Dieudonne fa2ea4683e [FIX] barcodes: Android Odoo app webview not detected as chrome
Before this commit, it wasn't possible to use a barcode scanner
with the Odoo mobile app.
However it works fine for mobile Chrome browsers.

We now know that 'keypress' event doesn't work as expected in
Chrome for mobile. See @3a74afd21
It's why 'keydown' detection has been implemented.

We also want to use this detection in our Android app.
Unfortunately, 'window.chrome' doesn't seem to exist anymore
in the Android webview.

In this commit, we change the way Chrome is detected.
2018-04-30 16:14:46 +02:00
Adrien Dieudonne 9e14d93c05 [FIX] barcodes: keep vertical position while scanning
Before this commit, you were automatically redirected to the top of
the page when you scanned a product.
It was, therefore, difficult to find the product that had just been
scanned and to check its quantity.

Because of @3a74afd21 we need to put the focus in an invisible input
at the top of the page.

This input is now always vertically centered in the middle of the page.
2018-04-30 16:14:38 +02:00
Géry Debongnie 6d4eb69ef3 [FIX] barcodes: update tests to new notification service
The notification manager was removed and replaced by a notification
service.  Some tests were forward ported after this change, so they need
to be updated to the new system.
2018-04-20 10:36:18 +02:00
Arnold Moyaux a6e2830631 [FIX] barcode: do not trigger barcode on pending views
The check on the event target and the barcode target is done outside
the check on barcode found. That result in a warning for each modal/form
view that is pending.

This commit do the check before doing any operations in order
to directly stop if the event target is not similiar to listening
barcode target
2018-04-18 11:50:48 +02:00
Arnold Moyaux e5305ca8b7 [FIX] barcode: use the same process for quantity listener
The barcode scanner and the quantity listener do not use
the same proccess although they act for the same operation.
(For example the quantity listener trigger onchange server side
while the barcode scanner not if 'notifychange' key on the
active_barcode is set to False)

Since quantity listener is based on candidate we could directly
call the _barcodeSelectedCandidate method in order to have a common
behavior and code.
2018-04-18 11:50:48 +02:00
Adrien Dieudonne 3a74afd21e [FIX] barcodes: barcode scanning on Chrome mobile
Before this commit, the barcode value wasn't triggered on
some Android devices with Google Chrome and using the Odoo app.

In fact, the keypress event may not trigger with some devices.
This is probably due to the fact that this event is marked as
'Legacy'.
See: https://www.w3.org/TR/uievents/#legacy-keyboardevent-event-types

To fix this, we can use 'keydown' event but we have to handle an
other issue: there is no way to know which key is typed.
The auto-suggest feature on Android invalidate all the following
properties: Keycode, charCode, key, which, keyIdentifier, code.
This is a well-known issue:
https://bugs.chromium.org/p/chromium/issues/detail?id=118639

For more infos, please read this blog:
https://www.outsystems.com/blog/javascript-events-unmasked-how-to-create-input-mask-for-mobile.html

As a work around, we create a temporary input field that stores
the barcode value.
The focus is set on this input when a keydown is detected.
Note that when an input has the focus, the android virtual keyboard
will be opened. We can't avoid this behavior.
The only thing we can do is to automatically close it after 800 ms.
See: https://bugs.chromium.org/p/chromium/issues/detail?id=662386

As this fix is specific for Chrome only, it's not possible
to test it easily. Some tests will be added in master.
2018-03-20 16:21:20 +01:00
Adrien Dieudonne 5bc29744c9 [FIX] barcodes: skip undefined keys in barcode value
This fixes an issue occurring with Firefox.
Some events was buffered with an undefined value and it wasn't
possible to build the barcode value from these events.
See 'handle_buffered_keys' function.

So now, we simply skip this kind of event.
We consider this as 'special keys'.
2018-03-20 16:21:12 +01:00
Arnold Moyaux 98547bf0cd [FIX] barcodes: Do not trigger useless onchange server side.
This commit improve perf by not trigger onchange server
side on one2many field if the js could find a candidate.

opw-785425
2018-03-07 14:55:31 +01:00
Arnold Moyaux f95566f08a [FIX] barcode: set quantity with key press
Allow the user to set the quantity with barcode
scanning. This functionality was present in v9 but
didn't work in v11.

The code in order to make it work was already present in
_quantityListener however it makes a check on setQuantityWithKeypress
key on the obejct activeBarcode. Howver the key was never set during the
activeBarcode event.

This commit set the key on the activeBarcode if passed in the event data.
It also allow to trigger a barcode if the user is inside a modal.
2018-03-07 13:20:52 +01:00
Christophe Simonis f5e7b86686 [MERGE] forward port branch saas-16 up to 920aa6174c 2018-02-01 17:02:19 +01:00
Christophe Simonis 920aa6174c [MERGE] forward port branch saas-15 up to e0422bfd6c 2018-02-01 16:40:13 +01:00
Nicolas Martinelli 513fad42a0 [FIX] barcodes: delay between keys
In order to detect if a barcode scanner is being used, we detect the
delay between keypresses. The value is hardcoded to 55 ms. However, in
the case of a bluetooth scanner, this delay is often not enough,
resulting in an incorrect capture of the barcode.

We add the config parameter `barcode.max_time_between_keys_in_ms` which
allows the user to fine tune this delay for his hardware.

opw-806398
2018-01-31 13:47:17 +01:00
Géry Debongnie 0c98951f1c [FIX] barcodes: use patch to prevent interactions between tests
There is a subtle issue happening in tests when we override a widget
property for the duration of the test and try to restore the initial state at
the end by rewriting on the property.  It actually changes the widget, by
having a function bound to the sub widget prototype instead of its ancestor.
This in turns can cause weird interactions with the class system.

We introduced a proper way to temporarily patch a class/widget by adding
a method in testUtils to do exactly that.  This commit simply uses that
method to prevent unwanted interactions in barcode tests
2017-12-18 17:29:14 +01:00
Simon Lejeune 8fb25e185b [FIX] barcodes: manage several barcode widgets
related to rev 0d19ee989d

It was broken following the refactoring done in saas16, resulting in
barcodes being handled on all the displayed forms and it was problematic
in the case of a form dialog openned over a "fullscreen" form view.

This was particularily problematic for the scrap dialog in the
stock_barcode module.
2017-11-28 15:17:59 +01:00
Vandan Shah 4524d93be0 [IMP] barcodes: corrected barcode commands of CMD-PREV and CMD-NEXT as well as changed qunit test case accordingly 2017-09-29 16:42:30 +02:00