From 098df6a08fef9a52eefc510bb33f03a9c4dafb2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20D=2E=20D=C3=ADaz?= Date: Thu, 15 Apr 2021 20:25:38 +0200 Subject: [PATCH] [FIX] web_widget_one2many_product_picker: Update qty counter --- .../views/One2ManyProductPicker/quick_create_form_view.js | 3 +++ .../static/src/js/views/One2ManyProductPicker/record.js | 6 ++++++ .../static/src/xml/one2many_product_picker.xml | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/web_widget_one2many_product_picker/static/src/js/views/One2ManyProductPicker/quick_create_form_view.js b/web_widget_one2many_product_picker/static/src/js/views/One2ManyProductPicker/quick_create_form_view.js index 6fc6c12f9..774526a14 100644 --- a/web_widget_one2many_product_picker/static/src/js/views/One2ManyProductPicker/quick_create_form_view.js +++ b/web_widget_one2many_product_picker/static/src/js/views/One2ManyProductPicker/quick_create_form_view.js @@ -257,6 +257,9 @@ odoo.define( this.trigger_up("create_quick_record", { id: record.id, callback: () => { + this.model.updateRecordContext(this.handle, { + saving: false, + }); this.model.unsetDirty(this.handle); // Self._updateButtons(); this._enableQuickCreate(); diff --git a/web_widget_one2many_product_picker/static/src/js/views/One2ManyProductPicker/record.js b/web_widget_one2many_product_picker/static/src/js/views/One2ManyProductPicker/record.js index 81f642174..8eea2653b 100644 --- a/web_widget_one2many_product_picker/static/src/js/views/One2ManyProductPicker/record.js +++ b/web_widget_one2many_product_picker/static/src/js/views/One2ManyProductPicker/record.js @@ -552,6 +552,7 @@ odoo.define("web_widget_one2many_product_picker.One2ManyProductPickerRecord", fu this.trigger_up("create_quick_record", { id: record.id, callback: () => { + model.updateRecordContext(this.state.id, {saving: false}); this.$card .find(".o_catch_attention") .removeClass("o_catch_attention"); @@ -625,6 +626,11 @@ odoo.define("web_widget_one2many_product_picker.One2ManyProductPickerRecord", fu // sends a creation with qty 1 but can still add more qty mean while // wait for the Odoo response. const model_record_data = model.localData[this.state.id].data; + if ( + _.isNull(model_record_data[this.options.fieldMap.product_uom_qty]) + ) { + model_record_data[this.options.fieldMap.product_uom_qty] = 1; + } model_record_data[this.options.fieldMap.product_uom_qty] += amount; return model .notifyChanges(record.id, { diff --git a/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker.xml b/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker.xml index f7b0947d1..470057172 100644 --- a/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker.xml +++ b/web_widget_one2many_product_picker/static/src/xml/one2many_product_picker.xml @@ -99,7 +99,7 @@ t-attf-class="oe_flip_card_front p-0 {{((modified || is_saving) && 'border-warning') || (state && !is_virtual && 'border-success') || ''}}" > - +