[FIX] barcodes: generate correct update command

The barcode mechanism is optimized to (in certain conditions),
directly increment the quantity of a numerical field inside an
x2many, without performing any RPC, and then re-rendering the
x2many to display the new value.

Before this rev., it seemed to work fine, but when the view was
saved, those changes of quantity were lost. This was because the
changes weren't correctly notified to the model (the quantity
field being inside an x2many, the correct update command for the
x2many should be generated).
This commit is contained in:
Aaron Bohy
2017-08-25 15:54:56 +02:00
parent 5f40f21adc
commit 8019eacb47
2 changed files with 111 additions and 5 deletions
@@ -93,8 +93,14 @@ FormController.include({
*/
_barcodeSelectedCandidate: function (candidate, record, barcode, activeBarcode) {
var changes = {};
changes[activeBarcode.quantity] = candidate.data[activeBarcode.quantity] + 1;
return this.model.notifyChanges(candidate.id, changes);
var candidateChanges = {};
candidateChanges[activeBarcode.quantity] = candidate.data[activeBarcode.quantity] + 1;
changes[activeBarcode.fieldName] = {
operation: 'UPDATE',
id: candidate.id,
data: candidateChanges,
};
return this.model.notifyChanges(this.handle, changes);
},
/**
* @private