Commit Graph
54 Commits
Author SHA1 Message Date
Christophe Simonis 482fd04167 [MERGE] forward port branch saas-11 up to f1583504ce 2017-01-10 13:46:17 +01:00
Christophe Simonis f1583504ce [MERGE] forward port branch 9.0 up to 3f7b1f6083 2017-01-10 12:07:44 +01:00
Simon Lejeune 17adc2e09e [FIX] barcodes: form view barcode handler: concurrency
Suppose the following usecase: you scan the first product of the
picking. A server onchange is then triggered. You scan the same product
a second time, before the first onchange has returned. You expect that
the first onchange is completely executed before running the second one.
This was not the case. Moreover, some onchanges were not be able to
work with the invalid  state of the formview at some times, and crashed.

The previous implementation was wrong because id didn't run the main
barcode processing mechanism inside a Mutex. It was also wrong because
it didn't correctly wait for the onchange to execute (a previous  barcode
onchanges or some classic ones) before setting the barcode field.
2017-01-09 16:36:00 +01:00
Christophe Simonis 18456b9d42 [MERGE] forward port branch saas-11 up to 321b7dc 2016-12-09 15:44:01 +01:00
Christophe Simonis 70193f23dc [MERGE] forward port branch 9.0 up to 154a125 2016-12-08 13:55:40 +01:00
Denis Ledoux f5f55b2289 [FIX] barcodes: compatibility of new Event() for IE >= 9.0
Using the constructor `new Event()` is not supported in IE >= 9.0
(tested on IE 11). It raises the below error:
`Object doesn't support this action`

This revision implements the Polyfill `CustomEvent()` suggested
by the MDN here:
https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
and uses it if the `new Event()` call fails.

opw-690984
2016-12-07 18:13:43 +01:00
Pierre Masereel 57c7b1d3a1 [FIX] barcodes: _set_quantity_listener
Before, the '_set_quantity_listener' function was opening a 'window.prompt'
which had different comportment depending the navigator. For example,
the focus was not allways on the input field, the enter key 'Cancel'
the prompt or 'validate' it.

So to improve the usability and the consistancy we used a dialog instead
a prompt, to manage the focus and the 'Enter' key pressed when we want to
set a quantity.
2016-10-19 16:14:00 +02:00
Christophe Simonis ceb1ba6dbd [MERGE] forward port branch 9.0 up to b14c8b3 2016-10-17 13:46:24 +02:00
Pierre Masereel 852e2c557e [FIX] barcodes: set_quantity traceback on mobile
When we are trying to set the quantity on a mobile device, we get
a traceback saying that we cannot call the 'find' function on the
elements returned by '_get_records'.

This '_get_records' function returns a 'Collection' when called on a tree
view and an 'Array' when called on a kanban view. When we are working
on a mobile device, most of the one2many are displayed as kanban.
The thing is when we work with the object returned by '_get_records' we
call a 'find' method on it, which is implemented by Odoo's Collection class.

So when we call 'find' on an 'Array' we actually call 'Array.prototype.find' which
is implemented on most desktop browser and on some mobile browser [1]. This is what
caused the traceback on Chrome in Android.

To fix this issue, we enforce '_get_records' to always return an 'Array' and we ensure
that, when working on this 'Array', we use '_.find'.

[1] https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/find
2016-10-14 12:22:22 +02:00
Christophe Simonis 784eaf28dc [MERGE] forward port branch 9.0 up to 6647e1f 2016-09-15 16:45:13 +02:00
Simon Lejeune 6647e1f8a9 [FIX] barcodes: correctly unbind quantity event listener
The quantity event handler is not correctly unbound when its action
is deleted, resulting in multiple window.prompt asking the quantity
of the products if you go mulitple times trough a view when a widget
implementing the barcode thing is used.

There seems to be a bug in the framework ("barcode_scanned" events
are registered the same way than the "keypress" one on core.bus
but they don't have suffer from the same issue).
2016-09-15 16:20:18 +02:00
Simon Lejeune dbe90c2661 [FIX] stock_barcode: correctly check when to execute "O-BTN"
It's possible to trigger click on form view's button with the help
of the "barcode_trigger" attributes. However, we don't want to be
able to execute clicks on items that aren't clickable by the user.
That's why we wrote the following condition: if the elem is visible
OR is a child of a .dropdown-menu, we trigger the click.

The second condition was always true since we used the jquery's
parent function which return an empty list when no result, and
an empty list is truthy.
2016-08-16 18:28:23 +02:00
Joren Van Onder c902437247 [FIX] barcodes: allow users to 'click' focused buttons with Return
Return key events don't get redispatched and even if they did, it
wouldn't work because 'fake' keypress events don't trigger native HTML
event handlers.

This should be safe because Return cannot start a valid barcode.
2016-07-13 13:58:50 +02:00
Nicolas Martinelli 0d19ee989d [FIX] barcodes: manage several barcode widgets
In some cases, several barcode widgets can be found on the same page.
This is for example the case of the stock picking: there is a widget on
the `stock.picking` model (main view) itself, and a widget on the
`stock.pack.operation` model (modal view).

In this case, when the focus is not set directly on the field which
needs to be filled in, both widgets will trigger a `barcode_scanned`
scanned event. This will call the `on_barcode_scanned` Python method
which can lead to errors/warning. For example, the `on_barcode_scanned`
method on the `stock.picking` model raises a warning in case the barcode
scanned does not match any product/package.

The fix is to make sure that the event target is located in the correct
DOM element.

opw-677506
2016-06-15 15:11:41 +02:00
Joren Van Onder 28a9336ac8 [FIX] barcodes: also allow barcodes triggering buttons in dropdowns
On smaller screens some buttons will be hidden. An example of this is
the 'Validate' button in the stock.picking form view. It is not :visible
but it should still be possible to trigger through scanning a
'O-BTN.validate' barcode.

opw-676741
2016-05-10 12:59:37 +02:00
Joren Van Onder fe76e6bc36 [FIX] barcodes: first qualify the quantity event before handling it
Introduced by 5bb64d40d0. Before doing
anything we should first ensure that the quantity keypress event targets
body (and that it is a number, but that's less important). Before this
we didn't do that and thus the _display_no_edit_mode_warning was given
when people where just typing in the associated thread of a picking.

opw-672350
2016-03-18 13:11:25 +01:00
Joren Van Onder 5bb64d40d0 [IMP] barcodes: allow immediate quantity input after scanning
When scanning items with a device like the Symbol MC3200 you are
presented with the Kanban view because of it's limited resolution.

In this view it is not possible to quickly set the quantity of scanned
products. Ideally users just want to scan the barcode, input the
quantity and repeat without having to click on virtual buttons on the
usually less than ideal touchscreen.

This implements a way for users to immediately start typing numbers
representing a quantity after scanning a barcode. The quantity will be
set on the specified m2x_field.quantity_field of the record associated
to the last scanned barcode. Because KanbanRecords are not editable
without opening a new view window.prompt is used. It will create an easy
to use native dialog of whatever device is being used. It also avoids us
having to implement a custom input field which would have to handle
keypress events like numbers, backspace, delete, etc.
2016-03-17 09:39:18 +01:00
Joren Van Onder c6fc91b318 [IMP] stock, barcodes: make barcode operations more mobile friendly
We want to properly support devices like the Symbol MC3200. This is a
handheld computer running a modern operating system like Android or
Windows with an integrated barcode scanner. After installation of a
modern web browser and configuration of the integrated barcode scanner
Odoo works as well as it does anywhere else.

The main issue with these types of devices is that the displays (and
their resolution) are very small (3" @ 320x320 for Symbol
MC3200). Because of this a lot of tree views become awkward to use
because they require vertical scrolling. A Kanban view however scales
nicely on these displays.

This implements Kanban views for both the picking.form view and the
stock.inventory form view because those are the views typically used
when using a barcode scanner.

Doing this alone is not enough, because the barcodes module does not
work with Kanban views. Small changes where made to
barcodes.FormViewBarcodeHandler to make it work with both List views and
Kanban views.
2016-03-17 09:39:18 +01:00
Arthur Maniet 1b9baf1ac2 [FIX] barcode: value representation for scannable field float
The value was stored as a string when it should have been a float.

opw-665376
2016-01-04 13:58:13 +01:00
Arthur Maniet 769e58d186 [FIX] barcodes: don't require suffix for scans
Users don't have to configure their scanner. As stated in the docs/planner,
either wait 50ms between 2 scans or use a suffix.
2015-09-15 13:22:16 +02:00
Arthur Maniet c4f8deecc0 [FIX] barcodes: dumb typo 2015-09-11 13:14:45 +02:00
Arthur Maniet d0423b5e5c [IMP] barcodes: form views action barcodes
Make all common form operations doable through barcode scanning
2015-09-11 12:04:13 +02:00
Arthur Maniet 5b96b4349e [IMP] barcodes: form view barcode handler 'pre_onchange_hook' mechanism
Since the method must return a deferred, resolve it with true to proceed with onchange
and with false to prevent the onchange. Deferred failure is not an option.
2015-09-11 12:04:13 +02:00
Arthur Maniet cdb30b507a [ADD] stock_barcode: field widget with barcodes scan + manual input
Barcodes are detected by catching keypresses. When a keypress is not
part of a barcode, it is 'released' by forging a keypress event.
For security reasons, a non-native keypress doesn't trigger the native
input mechanism. So in order to make both barcode-scanning and manual
keypresses work in a field, it is necessary to have a handler listen
to the 'false' keypresses and simulate the native input behaviour.
2015-09-03 11:23:38 +02:00
Arthur Maniet 27e237346d [IMP] barcodes: BarcodeEvents uses reserved barcodes prefixes
Export a list of barcodes prefixes used for software functionss
2015-09-03 11:11:56 +02:00
Arthur Maniet 17e2526667 [FIX] barcodes: use _.bind instead of function.bind because IE 2015-09-01 13:26:03 +02:00
Arthur Maniet 121556dcea [ADD] barcodes/web: element button can use attribute barcode_trigger
A button can be triggered when a barcode corresponding to its attribute
'barcode_trigger' is scanned
2015-09-01 13:26:02 +02:00
Arthur Maniet 670d759dbf [ADD] barcodes: BarcodeHandlerMixin that starts/stops the event handling
Only the barcode handlers in the front view should listen to barcode events.
2015-09-01 13:26:02 +02:00
Arthur Maniet 2df4060c77 [ADD] barcodes: onchange-like mechanism to react to scans in form view
For a model to use it, it must :
- Inherit barcodes.barcode_events_mixin and override on_barcode_scanned(self, barcode)
- Add <field name=barcode_scanned widget=barcode_handler/> to each form view that
  should listen to barcode events and trigger on_barcode_scanned.

The method on_barcode_scanned works just like an onchange.
2015-09-01 13:25:52 +02:00
Arthur Maniet 77878da066 [FIX] barcodes: key repeat prevention was mistakenly activated
TIL: The $(callback) function passes the jquery object to the callback
2015-08-05 12:45:02 +02:00
Arthur Maniet 581aba9fdb [FIX/REF] barcodes: don't catch keypress if a control key is pressed
This avoids breaking shortcuts on Firefox, which rely on keypress
events instead of keydown / keyup. The tradeoff is that a barcode
cannot be scanned and interpreted if ctrl, alt or cmd is pressed.
Also don't catch function keys.
2015-07-30 07:55:53 +02:00
Arthur Maniet 68ad51b6a9 [FIX] barcodes: style 2015-07-30 07:55:53 +02:00
Arthur Maniet 03534c5bef [IMP] barcodes: use a regexp to match a barcode 2015-07-30 07:55:53 +02:00
Arthur Maniet 0ed6a7dd18 [IMP] barcodes: use a known terminal char to stops buffering keys
BarcodeEvents uses the fact that a barcode usually ends with \n, \r or
\t - and never contains it - to stop buffing keys as soon as such a
character is inputted instead of waiting x milliseconds.
2015-07-30 07:55:53 +02:00
Arthur Maniet 47262c8587 [REF] barcodes: make key repeat prevention optional
This functionality was an attemps to fix the chair-to-keyboard
interface in the PoS. Since it is not a standard behaviour, it
must be explicitly requested.
2015-07-30 07:55:52 +02:00
Arthur Maniet 5b01eca5e4 [FIX] barcodes: BarcodeEvents handler binding and unbinding
In order to remove an eventhandler, removeEventListener must receive
the same function reference that was passed to addEventListener. So
the handlers references are kept as attributes of the class.
2015-07-30 07:55:52 +02:00
Arthur Maniet f45904f581 [REF] web: move barcode_events to module barcodes
If the module barcodes is installed, a BarcodeEvents singleton is
automatically instanciated. It listens to keypresses and, when a
sequence of keys represents a barcode, it broadcasts a 'barcode_scanned'
event on core.bus containing the barcode string.
2015-07-30 07:55:45 +02:00
Christophe Simonis 2cf91d16a5 [MERGE] forward port of branch saas-6 up to 63e92cb 2015-07-22 16:17:54 +02:00
Christophe Matthieu 500c33b184 [IMP] web: split model.js into model.js and data_model.js. Web js modules must call web.DataModel. 2015-07-10 16:32:35 +02:00
Joren Van Onder 80da43ebb8 [FIX] barcode_parser: don't match end of line
Causes issues with the card reader device.
2015-07-02 16:42:35 +02:00
Frédéric van der Essen 50c147514e [FIX] barcodes: correctly recompute the checksum of the product barcode when guessing it from a value encoding barcode 2015-06-29 15:43:15 +02:00
Christophe Simonis fe2b5f35a4 [MERGE] forward port of branch saas-6 up to bf1e999 2015-05-28 14:27:38 +02:00
Frédéric van der Essen 00236aafcc [FIX] point_of_sale: barcode patterns must match barcode as prefix, (and not anywhere in barcode) 2015-05-05 14:04:39 +02:00
Géry Debongnie 4fdf74fe21 [IMP] web+addons: improvement to module system
The module system needs to know the dependencies of a given module
before executing the function.  This is why the dependencies were
defined once in an array, and then were described one more times in the
call to require.

But a trick can simplify this: the boot function can parse the string
representation of the module and extract the calls to require from it.
It is more work for the processor, but it leads to simpler module
definitions.
2015-03-18 09:23:37 +01:00
Géry Debongnie 0dcc559cdd [REF] barcodes: update to the new module system 2015-03-18 09:01:51 +01:00
Frédéric van der Essen 3c5f62413e [FIX] barcodes: typo in function name 2015-01-28 17:01:27 +01:00
Frédéric van der Essen 59b0907d2e [IMP] barcodes, point_of_sale : add support for UPC-A barcodes
- Added support for UPC-A Barcodes
 - Add a way to automatically convert UPC-A to and from EAN13. This
   is usefull if you wish to standardise your product barcode encoding
   in one standard but have a mix of the two in your merchandise.
 - Various bugfixes.
2015-01-13 16:19:39 +01:00
Aaron Bohy dbcc93154f [FIX] barcodes: parse_barcode functions in PY and JS commented 2014-11-26 12:11:55 +01:00
Aaron Bohy b671824048 [FIX] barcodes, stock, point_of_sale: parse_barcode function uses regex, pattern and barcodes may now contain special characters \ { and ., special character * replaced by . 2014-11-26 12:11:51 +01:00
Aaron Bohy aae9dfe4e7 [FIX] barcodes: prepend a zero to ean13 barcodes scanned before looking for a match 2014-11-26 12:06:23 +01:00