From 107d3a5114391767d009389222150f54c8981699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20D=2E=20D=C3=ADaz?= Date: Thu, 22 Apr 2021 15:06:15 +0200 Subject: [PATCH] [IMP] web_widget_one2many_product_picker: Add option 'all_domain' and auto-select search input content --- web_widget_one2many_product_picker/README.rst | 1 + .../readme/CONFIGURE.rst | 1 + .../static/description/index.html | 2 ++ .../js/widgets/field_one2many_product_picker.js | 14 +++++++++++++- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/web_widget_one2many_product_picker/README.rst b/web_widget_one2many_product_picker/README.rst index c8969bdfe..99b02c73e 100644 --- a/web_widget_one2many_product_picker/README.rst +++ b/web_widget_one2many_product_picker/README.rst @@ -84,6 +84,7 @@ Widget options: * show_discount > Enable/Disable display discount (False by default) * show_subtotal > Enable/Disable show subtotal (True by default) * auto_save > Enable/Disable auto save (False by default) +* all_domain > The domain used in 'All' section ([] 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 diff --git a/web_widget_one2many_product_picker/readme/CONFIGURE.rst b/web_widget_one2many_product_picker/readme/CONFIGURE.rst index f6ecea085..581d56152 100644 --- a/web_widget_one2many_product_picker/readme/CONFIGURE.rst +++ b/web_widget_one2many_product_picker/readme/CONFIGURE.rst @@ -42,6 +42,7 @@ Widget options: * show_discount > Enable/Disable display discount (False by default) * show_subtotal > Enable/Disable show subtotal (True by default) * auto_save > Enable/Disable auto save (False by default) +* all_domain > The domain used in 'All' section ([] 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 diff --git a/web_widget_one2many_product_picker/static/description/index.html b/web_widget_one2many_product_picker/static/description/index.html index c04f874a3..39353f7b4 100644 --- a/web_widget_one2many_product_picker/static/description/index.html +++ b/web_widget_one2many_product_picker/static/description/index.html @@ -471,6 +471,8 @@ You need to define the view fields. The view must be of show_subtotal > Enable/Disable show subtotal (True by default)

  • auto_save > Enable/Disable auto save (False by default)

    +
  • +
  • all_domain > The domain used in ‘All’ section ([] 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.

    diff --git a/web_widget_one2many_product_picker/static/src/js/widgets/field_one2many_product_picker.js b/web_widget_one2many_product_picker/static/src/js/widgets/field_one2many_product_picker.js index 074983d1a..6e0d3ae29 100644 --- a/web_widget_one2many_product_picker/static/src/js/widgets/field_one2many_product_picker.js +++ b/web_widget_one2many_product_picker/static/src/js/widgets/field_one2many_product_picker.js @@ -27,6 +27,7 @@ odoo.define("web_widget_one2many_product_picker.FieldOne2ManyProductPicker", fun "click .oe_btn_lines": "_onClickLines", "click .oe_btn_search_group": "_onClickSearchGroup", "search .oe_search_input": "_onSearch", + "focusin .oe_search_input": "_onFocusInSearch", "show.bs.dropdown .o_cp_buttons": "_onShowSearchDropdown", }), custom_events: _.extend({}, FieldOne2Many.prototype.custom_events, { @@ -196,7 +197,7 @@ odoo.define("web_widget_one2many_product_picker.FieldOne2ManyProductPicker", fun this.searchGroups.splice(0, 0, { name: "all", string: _t("All"), - domain: [], + domain: this.options.all_domain, order: false, active: !hasUserActive, }); @@ -545,6 +546,7 @@ odoo.define("web_widget_one2many_product_picker.FieldOne2ManyProductPicker", fun }, auto_save: false, ignore_warning: false, + all_domain: [], }; }, @@ -681,6 +683,16 @@ odoo.define("web_widget_one2many_product_picker.FieldOne2ManyProductPicker", fun }); }, + /** + * Auto select all content when user enters into fields with this + * widget. + * + * @private + */ + _onFocusInSearch: function() { + this.$searchInput.select(); + }, + /** * @private * @param {DropdownEvent} evt