[IMP] web_widget_one2many_product_picker: Add auto-save feature

pull/1858/head
Alexandre D. Díaz 2021-01-22 19:23:09 +01:00
parent 0943fa891f
commit b1a2804518
5 changed files with 23 additions and 1 deletions

View File

@ -80,6 +80,11 @@ Widget options:
* edit_price > Enable/Disable price edits (True by default) * edit_price > Enable/Disable price edits (True by default)
* show_discount > Enable/Disable display discount (False by default) * show_discount > Enable/Disable display discount (False by default)
* show_subtotal > Enable/Disable show subtotal (True by default) * show_subtotal > Enable/Disable show subtotal (True by default)
* auto_save > Enable/Disable auto save (False by default)
If using auto save feature, you should keep in mind that the "Save" and "Discard" buttons
will lose part of its functionality as the document will be saved every time you
modify/create a record with the widget.
All widget options are optional. All widget options are optional.
Notice that you can call '_' method to use translations. This only can be used with this widget. Notice that you can call '_' method to use translations. This only can be used with this widget.

View File

@ -4,7 +4,7 @@
{ {
'name': 'Web Widget One2Many Product Picker', 'name': 'Web Widget One2Many Product Picker',
'summary': 'Widget to select products on one2many fields', 'summary': 'Widget to select products on one2many fields',
'version': '12.0.1.3.0', 'version': '12.0.1.4.0',
'category': 'Website', 'category': 'Website',
'author': "Tecnativa, " 'author': "Tecnativa, "
"Odoo Community Association (OCA)", "Odoo Community Association (OCA)",

View File

@ -38,6 +38,11 @@ Widget options:
* edit_price > Enable/Disable price edits (True by default) * edit_price > Enable/Disable price edits (True by default)
* show_discount > Enable/Disable display discount (False by default) * show_discount > Enable/Disable display discount (False by default)
* show_subtotal > Enable/Disable show subtotal (True by default) * show_subtotal > Enable/Disable show subtotal (True by default)
* auto_save > Enable/Disable auto save (False by default)
If using auto save feature, you should keep in mind that the "Save" and "Discard" buttons
will lose part of its functionality as the document will be saved every time you
modify/create a record with the widget.
All widget options are optional. All widget options are optional.
Notice that you can call '_' method to use translations. This only can be used with this widget. Notice that you can call '_' method to use translations. This only can be used with this widget.

View File

@ -464,6 +464,11 @@ You need to define the view fields. The view must be of <tt class="docutils lite
</li> </li>
<li><p class="first">show_subtotal &gt; Enable/Disable show subtotal (True by default)</p> <li><p class="first">show_subtotal &gt; Enable/Disable show subtotal (True by default)</p>
</li> </li>
<li><p class="first">auto_save &gt; Enable/Disable auto save (False by default)</p>
<p>If using auto save feature, you should keep in mind that the “Save” and “Discard” buttons
will lose part of its functionality as the document will be saved every time you
modify/create a record with the widget.</p>
</li>
</ul> </ul>
<p>All widget options are optional. <p>All widget options are optional.
Notice that you can call _ method to use translations. This only can be used with this widget.</p> Notice that you can call _ method to use translations. This only can be used with this widget.</p>

View File

@ -437,6 +437,7 @@ odoo.define("web_widget_one2many_product_picker.FieldOne2ManyProductPicker", fun
price_unit: "price_unit", price_unit: "price_unit",
discount: "discount", discount: "discount",
}, },
auto_save: false,
}; };
}, },
@ -581,6 +582,9 @@ odoo.define("web_widget_one2many_product_picker.FieldOne2ManyProductPicker", fun
_onCreateQuickRecord: function (evt) { _onCreateQuickRecord: function (evt) {
this.parent_controller.model.setPureVirtual(evt.data.id, false); this.parent_controller.model.setPureVirtual(evt.data.id, false);
this._setValue({operation: "ADD", id: evt.data.id}); this._setValue({operation: "ADD", id: evt.data.id});
if (this.options.auto_save) {
this.parent_controller.saveRecord(undefined, {stayInEdit: true});
}
}, },
/** /**
@ -591,6 +595,9 @@ odoo.define("web_widget_one2many_product_picker.FieldOne2ManyProductPicker", fun
*/ */
_onUpdateQuickRecord: function (evt) { _onUpdateQuickRecord: function (evt) {
this._setValue({operation: "UPDATE", id: evt.data.id, data: evt.data.data}); this._setValue({operation: "UPDATE", id: evt.data.id, data: evt.data.data});
if (this.options.auto_save) {
this.parent_controller.saveRecord(undefined, {stayInEdit: true});
}
}, },
/** /**