summaryrefslogtreecommitdiff
path: root/addons/barcodes/static/src
diff options
context:
space:
mode:
authorArnold Moyaux <arm@odoo.com>2018-04-12 14:20:24 +0200
committerArnold Moyaux <arm@odoo.com>2018-04-18 11:50:48 +0200
commite5305ca8b718ffec27474e57d06fb54340c81707 (patch)
treee4aa464f80864388a69fa5ddb2270712f4533f94 /addons/barcodes/static/src
parent20f5f625f49040cc6bd9758a0dc7a2fb46bb6367 (diff)
[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.
Diffstat (limited to 'addons/barcodes/static/src')
-rw-r--r--addons/barcodes/static/src/js/barcode_form_view.js13
1 files changed, 8 insertions, 5 deletions
diff --git a/addons/barcodes/static/src/js/barcode_form_view.js b/addons/barcodes/static/src/js/barcode_form_view.js
index 1730b42290e..b5cad7a1509 100644
--- a/addons/barcodes/static/src/js/barcode_form_view.js
+++ b/addons/barcodes/static/src/js/barcode_form_view.js
@@ -146,10 +146,10 @@ FormController.include({
* @param {Object} activeBarcode: options sent by the field who use barcode features
* @returns {Deferred}
*/
- _barcodeSelectedCandidate: function (candidate, record, barcode, activeBarcode) {
+ _barcodeSelectedCandidate: function (candidate, record, barcode, activeBarcode, quantity) {
var changes = {};
var candidateChanges = {};
- candidateChanges[activeBarcode.quantity] = candidate.data[activeBarcode.quantity] + 1;
+ candidateChanges[activeBarcode.quantity] = quantity ? quantity : candidate.data[activeBarcode.quantity] + 1;
changes[activeBarcode.fieldName] = {
operation: 'UPDATE',
id: candidate.id,
@@ -306,6 +306,8 @@ FormController.include({
}
return self.alive($.when.apply($, defs)).then(function () {
if (!prefixed) {
+ // remember the barcode scanned for the quantity listener
+ self.current_barcode = barcode;
// redraw the view if we scanned a real barcode (required if
// we manually apply the change in JS, e.g. incrementing the
// quantity)
@@ -355,9 +357,10 @@ FormController.include({
title: _t('Set quantity'),
buttons: [{text: _t('Select'), classes: 'btn-primary', close: true, click: function () {
var new_qty = this.$content.find('.o_set_qty_input').val();
- var values = {};
- values[activeBarcode.quantity] = parseFloat(new_qty);
- return self.model.notifyChanges(activeBarcode.candidate.id, values).then(function () {
+ var record = self.model.get(self.handle);
+ return self._barcodeSelectedCandidate(activeBarcode.candidate, record,
+ self.current_barcode, activeBarcode, parseFloat(new_qty))
+ .then(function () {
self.update({}, {reload: false});
});
}}, {text: _t('Discard'), close: true}],