diff --git a/web_widget_one2many_product_picker/README.rst b/web_widget_one2many_product_picker/README.rst index f44960cec..43be865e3 100644 --- a/web_widget_one2many_product_picker/README.rst +++ b/web_widget_one2many_product_picker/README.rst @@ -37,6 +37,141 @@ Installation It's advisable to install 'web_widget_numeric_step' to have a better usability on touch screens. +Configuration +============= + +Create or edit a new view and use the new widget called 'one2many_product_picker'. +You need to define the view fields. The view must be of ``form`` type. + + +Widget options: +~~~~~~~~~~~~~~~ + +* product_per_page > Integer -> Used to control the load more behaviour (16 by default) +* groups > Array of dictionaries -> Declare the groups + + * name -> The group name + * string -> The text displayed + * domain -> Forced domain to use + * order -> The order + + * name -> The field name to order + * asc -> Flag to use 'asc' order + +* currency_field > Model field used to format monetary values ('currency_id' by default) +* field_map > Dictionary: + + * product -> The field that represent the product (`product_id` by default) + * name -> The field that represent a name ('name' by default) + * product_uom -> The field that represent a product_uom ('product_uom' by default) + * product_uom_qty -> The field that represent a product_uom_qty ('product_uom_qty' by default) + * price_unit -> The field that represent a price_unit ('price_unit' by default) + * discount -> The field that represent a discount ('discount' by default) + +* search > Array of dictionaries or Array of 'triplets' ([[field_map.name, 'ilike', '$search']] by default) + + * name -> The name to display + * domain -> The domain to use + + * $search -> Replaces it with the current value of the searchbox + * $number_search -> Replaces all the leaf with the current value of the searchbox as a number + +* edit_discount > Enable/Disable discount edits (False by default) +* edit_price > Enable/Disable price edits (True by default) +* show_discount > Enable/Disable display discount (False by default) +* show_subtotal > Enable/Disable show subtotal (True by default) + +All widget options are optional. +Notice that you can call '_' method to use translations. This only can be used with this widget. + +Example: + +.. code:: + + options="{'search': [{'name': _('Starts With'), 'domain': [('name', '=like', '$search%')]}], 'groups': [{'name': 'cheap', 'string': _('Cheap'), 'domain': [('list_price', '<', 10.0)], 'field_map': { 'product': 'my_product_id' }}]}" + + +Default context: +~~~~~~~~~~~~~~~~ + +The widget sends a defaults context with the 'search_read' request: + + * active_search_group_name > Contains the name of the active search group + + * 'all' > Is the hard-coded name for the 'All' group + * 'main_lines' > Is the hard-coded name for the 'Lines' group + + * active_search_involved_fields > Contains an array of dictionaries with the fields used with the searchbox content + + * 'type' > Can be 'text' or 'number' + * 'field' > The field name + * 'oper' > The operator used + + +Examples: +~~~~~~~~~ + +This is an example that uses the 'sale.order.line' fields: + +.. code:: xml + + +
+ + + + + + + + + + + + + +** In this example we don't use 'field_map' option because the default match with the sale.order.line field names. + +Other example for 'purchase.order.line' fields: + +.. code:: xml + + +
+ + + + + + + + + + + Usage ===== @@ -87,7 +222,7 @@ Other example for 'purchase.order.line' fields: nolabel="1" widget="one2many_product_picker" mode="form" - options="{'search': [{'name': _('Name'), 'domain': [['name', 'ilike', '$search']]}, {'name': _('Price'), 'domain': [['list_price', '=', $number_search]]}], 'field_map': {'name': 'name', 'product': 'product_id', 'product_uom': 'product_uom', 'price': 'price_unit', 'parent_id': 'order_id', 'product_uom_qty': 'product_qty'}, 'groups': [{'name': _('Desk'), 'domain': [['name', 'ilike', 'desk']], 'order': {'name': 'id', 'asc': true}}, {'name': _('Chairs'), 'domain': [['name', 'ilike', 'chair']]}]}" + options="{'search': [{'name': _('Name'), 'domain': [['name', 'ilike', '$search']]}, {'name': _('Price'), 'domain': [['list_price', '=', $number_search]]}], 'field_map': {'product_uom_qty': 'product_qty'}, 'groups': [{'name': _('Desk'), 'domain': [['name', 'ilike', 'desk']], 'order': {'name': 'id', 'asc': true}}, {'name': _('Chairs'), 'domain': [['name', 'ilike', 'chair']]}]}" >
@@ -114,6 +249,12 @@ The widget sends a defaults context with the 'search_read' request: * 'all' > Is the hard-coded name for the 'All' group * 'main_lines' > Is the hard-coded name for the 'Lines' group + * active_search_involved_fields > Contains an array of dictionaries with the fields used with the searchbox content + + * 'type' > Can be 'text' or 'number' + * 'field' > The field name + * 'oper' > The operator used + Preview: ~~~~~~~~ @@ -124,7 +265,7 @@ Known issues / Roadmap ====================== * Translations in the xml 'options' attribute of the field that use the widget can't be exported automatically to be translated -* The product card animations can be improved. Currently the card is recreated, so we lost some states to apply correct effects. +* The product card animations can be improved. Currently the card is recreated, so we lost some elements to apply correct effects. Bug Tracker =========== diff --git a/web_widget_one2many_product_picker/readme/CONFIG.rst b/web_widget_one2many_product_picker/readme/CONFIG.rst deleted file mode 100644 index cb36faf47..000000000 --- a/web_widget_one2many_product_picker/readme/CONFIG.rst +++ /dev/null @@ -1,47 +0,0 @@ -Create or edit a new view and use the new widget called 'one2many_product_picker'. - -Widget options: -~~~~~~~~~~~~~~~ - -* product_per_page > Integer -> Used to control the load more behaviour (16 by default) -* groups > Array of dictionaries -> Declare the groups - - * name -> The group name - * string -> The text displayed - * domain -> Forced domain to use - * order -> The order - - * name -> The field name to order - * asc -> Flag to use 'asc' order - -* currency_field > Model field used to format monetary values ('currency_id' by default) -* field_map > Dictionary: - - * product -> The field that represent the product (`product_id` by default) - * name -> The field that represent a name ('name' by default) - * product_uom -> The field that represent a product_uom ('product_uom' by default) - * product_uom_qty -> The field that represent a product_uom_qty ('product_uom_qty' by default) - * price_unit -> The field that represent a price_unit ('price_unit' by default) - * discount -> The field that represent a discount ('discount' by default) - -* search > Array of dictionaries or Array of 'triplets' ([[field_map.name, 'ilike', '$search']] by default) - - * name -> The name to display - * domain -> The domain to use - - * $search -> Replaces it with the current value of the searchbox - * $number_search -> Replaces all the leaf with the current value of the searchbox as a number - -* edit_discount > Enable/Disable discount edits (False by default) -* edit_price > Enable/Disable price edits (True by default) -* show_discount > Enable/Disable display discount (False by default) -* show_subtotal > Enable/Disable show subtotal (True by default) - -All widget options are optional. -Notice that you can call '_' method to use translations. This only can be used with this widget. - -Example: - -.. code:: - - options="{'search': [{'name': _('Starts With'), 'domain': [('name', '=like', '$search%')]}], 'groups': [{'name': 'cheap', 'string': _('Cheap'), 'domain': [('list_price', '<', 10.0)], 'field_map': { 'product': 'my_product_id' }}]}" diff --git a/web_widget_one2many_product_picker/readme/CONFIGURATION.rst b/web_widget_one2many_product_picker/readme/CONFIGURATION.rst deleted file mode 100644 index e6592be0a..000000000 --- a/web_widget_one2many_product_picker/readme/CONFIGURATION.rst +++ /dev/null @@ -1 +0,0 @@ -It's recommendable install 'web_widget_numeric_step' to have a better usability on touch screens. diff --git a/web_widget_one2many_product_picker/readme/CONFIGURE.rst b/web_widget_one2many_product_picker/readme/CONFIGURE.rst new file mode 100644 index 000000000..2d1112c87 --- /dev/null +++ b/web_widget_one2many_product_picker/readme/CONFIGURE.rst @@ -0,0 +1,131 @@ +Create or edit a new view and use the new widget called 'one2many_product_picker'. +You need to define the view fields. The view must be of ``form`` type. + + +Widget options: +~~~~~~~~~~~~~~~ + +* product_per_page > Integer -> Used to control the load more behaviour (16 by default) +* groups > Array of dictionaries -> Declare the groups + + * name -> The group name + * string -> The text displayed + * domain -> Forced domain to use + * order -> The order + + * name -> The field name to order + * asc -> Flag to use 'asc' order + +* currency_field > Model field used to format monetary values ('currency_id' by default) +* field_map > Dictionary: + + * product -> The field that represent the product (`product_id` by default) + * name -> The field that represent a name ('name' by default) + * product_uom -> The field that represent a product_uom ('product_uom' by default) + * product_uom_qty -> The field that represent a product_uom_qty ('product_uom_qty' by default) + * price_unit -> The field that represent a price_unit ('price_unit' by default) + * discount -> The field that represent a discount ('discount' by default) + +* search > Array of dictionaries or Array of 'triplets' ([[field_map.name, 'ilike', '$search']] by default) + + * name -> The name to display + * domain -> The domain to use + + * $search -> Replaces it with the current value of the searchbox + * $number_search -> Replaces all the leaf with the current value of the searchbox as a number + +* edit_discount > Enable/Disable discount edits (False by default) +* edit_price > Enable/Disable price edits (True by default) +* show_discount > Enable/Disable display discount (False by default) +* show_subtotal > Enable/Disable show subtotal (True by default) + +All widget options are optional. +Notice that you can call '_' method to use translations. This only can be used with this widget. + +Example: + +.. code:: + + options="{'search': [{'name': _('Starts With'), 'domain': [('name', '=like', '$search%')]}], 'groups': [{'name': 'cheap', 'string': _('Cheap'), 'domain': [('list_price', '<', 10.0)], 'field_map': { 'product': 'my_product_id' }}]}" + + +Default context: +~~~~~~~~~~~~~~~~ + +The widget sends a defaults context with the 'search_read' request: + + * active_search_group_name > Contains the name of the active search group + + * 'all' > Is the hard-coded name for the 'All' group + * 'main_lines' > Is the hard-coded name for the 'Lines' group + + * active_search_involved_fields > Contains an array of dictionaries with the fields used with the searchbox content + + * 'type' > Can be 'text' or 'number' + * 'field' > The field name + * 'oper' > The operator used + + +Examples: +~~~~~~~~~ + +This is an example that uses the 'sale.order.line' fields: + +.. code:: xml + + + + + + + + + + + + + + + + +** In this example we don't use 'field_map' option because the default match with the sale.order.line field names. + +Other example for 'purchase.order.line' fields: + +.. code:: xml + + +
+ + + + + + + + + + diff --git a/web_widget_one2many_product_picker/readme/ROADMAP.rst b/web_widget_one2many_product_picker/readme/ROADMAP.rst index 43b92528c..0e3fe6e62 100644 --- a/web_widget_one2many_product_picker/readme/ROADMAP.rst +++ b/web_widget_one2many_product_picker/readme/ROADMAP.rst @@ -1,2 +1,2 @@ * Translations in the xml 'options' attribute of the field that use the widget can't be exported automatically to be translated -* The product card animations can be improved. Currently the card is recreated, so we lost some states to apply correct effects. +* The product card animations can be improved. Currently the card is recreated, so we lost some elements to apply correct effects. diff --git a/web_widget_one2many_product_picker/readme/USAGE.rst b/web_widget_one2many_product_picker/readme/USAGE.rst index 4f227a595..df29c4af0 100644 --- a/web_widget_one2many_product_picker/readme/USAGE.rst +++ b/web_widget_one2many_product_picker/readme/USAGE.rst @@ -45,7 +45,7 @@ Other example for 'purchase.order.line' fields: nolabel="1" widget="one2many_product_picker" mode="form" - options="{'search': [{'name': _('Name'), 'domain': [['name', 'ilike', '$search']]}, {'name': _('Price'), 'domain': [['list_price', '=', $number_search]]}], 'field_map': {'name': 'name', 'product': 'product_id', 'product_uom': 'product_uom', 'price': 'price_unit', 'parent_id': 'order_id', 'product_uom_qty': 'product_qty'}, 'groups': [{'name': _('Desk'), 'domain': [['name', 'ilike', 'desk']], 'order': {'name': 'id', 'asc': true}}, {'name': _('Chairs'), 'domain': [['name', 'ilike', 'chair']]}]}" + options="{'search': [{'name': _('Name'), 'domain': [['name', 'ilike', '$search']]}, {'name': _('Price'), 'domain': [['list_price', '=', $number_search]]}], 'field_map': {'product_uom_qty': 'product_qty'}, 'groups': [{'name': _('Desk'), 'domain': [['name', 'ilike', 'desk']], 'order': {'name': 'id', 'asc': true}}, {'name': _('Chairs'), 'domain': [['name', 'ilike', 'chair']]}]}" >
@@ -72,6 +72,12 @@ The widget sends a defaults context with the 'search_read' request: * 'all' > Is the hard-coded name for the 'All' group * 'main_lines' > Is the hard-coded name for the 'Lines' group + * active_search_involved_fields > Contains an array of dictionaries with the fields used with the searchbox content + + * 'type' > Can be 'text' or 'number' + * 'field' > The field name + * 'oper' > The operator used + Preview: ~~~~~~~~ diff --git a/web_widget_one2many_product_picker/static/description/index.html b/web_widget_one2many_product_picker/static/description/index.html index 19e778bbe..69e68cf65 100644 --- a/web_widget_one2many_product_picker/static/description/index.html +++ b/web_widget_one2many_product_picker/static/description/index.html @@ -372,28 +372,194 @@ ul.auto-toc {

Table of contents

-

Installation

+

Installation

It’s advisable to install ‘web_widget_numeric_step’ to have a better usability on touch screens.

+
+

Configuration

+

Create or edit a new view and use the new widget called ‘one2many_product_picker’. +You need to define the view fields. The view must be of form type.

+
+

Widget options:

+
    +
  • product_per_page > Integer -> Used to control the load more behaviour (16 by default)

    +
  • +
  • groups > Array of dictionaries -> Declare the groups

    +
    +
      +
    • name -> The group name

      +
    • +
    • string -> The text displayed

      +
    • +
    • domain -> Forced domain to use

      +
    • +
    • order -> The order

      +
      +
        +
      • name -> The field name to order
      • +
      • asc -> Flag to use ‘asc’ order
      • +
      +
      +
    • +
    +
    +
  • +
  • currency_field > Model field used to format monetary values (‘currency_id’ by default)

    +
  • +
  • field_map > Dictionary:

    +
    +
      +
    • product -> The field that represent the product (product_id by default)
    • +
    • name -> The field that represent a name (‘name’ by default)
    • +
    • product_uom -> The field that represent a product_uom (‘product_uom’ by default)
    • +
    • product_uom_qty -> The field that represent a product_uom_qty (‘product_uom_qty’ by default)
    • +
    • price_unit -> The field that represent a price_unit (‘price_unit’ by default)
    • +
    • discount -> The field that represent a discount (‘discount’ by default)
    • +
    +
    +
  • +
  • search > Array of dictionaries or Array of ‘triplets’ ([[field_map.name, ‘ilike’, ‘$search’]] by default)

    +
    +
      +
    • name -> The name to display

      +
    • +
    • domain -> The domain to use

      +
      +
        +
      • $search -> Replaces it with the current value of the searchbox
      • +
      • $number_search -> Replaces all the leaf with the current value of the searchbox as a number
      • +
      +
      +
    • +
    +
    +
  • +
  • edit_discount > Enable/Disable discount edits (False by default)

    +
  • +
  • edit_price > Enable/Disable price edits (True by default)

    +
  • +
  • show_discount > Enable/Disable display discount (False by default)

    +
  • +
  • show_subtotal > Enable/Disable show subtotal (True by default)

    +
  • +
+

All widget options are optional. +Notice that you can call ‘_’ method to use translations. This only can be used with this widget.

+

Example:

+
+options="{'search': [{'name': _('Starts With'), 'domain': [('name', '=like', '$search%')]}], 'groups': [{'name': 'cheap', 'string': _('Cheap'), 'domain': [('list_price', '<', 10.0)], 'field_map': { 'product': 'my_product_id' }}]}"
+
+
+
+

Default context:

+

The widget sends a defaults context with the ‘search_read’ request:

+
+
    +
  • active_search_group_name > Contains the name of the active search group

    +
    +
      +
    • ‘all’ > Is the hard-coded name for the ‘All’ group
    • +
    • ‘main_lines’ > Is the hard-coded name for the ‘Lines’ group
    • +
    +
    +
  • +
  • active_search_involved_fields > Contains an array of dictionaries with the fields used with the searchbox content

    +
    +
      +
    • ‘type’ > Can be ‘text’ or ‘number’
    • +
    • ‘field’ > The field name
    • +
    • ‘oper’ > The operator used
    • +
    +
    +
  • +
+
+
+
+

Examples:

+

This is an example that uses the ‘sale.order.line’ fields:

+
+<field
+    name="order_line"
+    attrs="{'readonly': [('state', 'in', ('done','cancel'))]}"
+    nolabel="1"
+    mode="form"
+    widget="one2many_product_picker"
+    options="{'search': [{'name': 'Test', 'domain': [['name', 'ilike', '$search']]}] ,'edit_discount': True, 'show_discount': True, 'groups': [{'name': 'desk', 'string': _('Desks'), 'domain': [('name', 'ilike', '%desk%')], 'order': [{'name': 'id', 'asc': true}]}, {'name': 'chair', 'string': _('Chairs'), 'domain': [('name', 'ilike', '%chair%')]}]}"
+>
+    <form>
+        <field name="state" invisible="1" />
+        <field name="display_type" invisible="1" />
+        <field name="currency_id" invisible="1" />
+        <field name="discount" widget="numeric_step" options="{'max': 100}" invisible="1"/>
+        <field name="price_unit" widget="numeric_step" invisible="1"/>
+        <field name="name" invisible="1" />
+        <field name="product_id" invisible="1" />
+        <field name="order_id" invisible="1"/>
+        <field name="product_uom_qty" class="mb-1" widget="numeric_step" context="{
+            'partner_id': parent.partner_id,
+            'quantity': product_uom_qty,
+            'pricelist': parent.pricelist_id,
+            'uom': product_uom,
+            'company_id': parent.company_id
+        }" />
+        <field name="product_uom" force_save="1" attrs="{
+            'readonly': [('state', 'in', ('sale','done', 'cancel'))],
+            'required': [('display_type', '=', False)],
+        }" context="{'company_id': parent.company_id}" class="mb-2" options="{'no_open': True, 'no_create': True, 'no_edit': True}" />
+    </form>
+</field>
+
+

** In this example we don’t use ‘field_map’ option because the default match with the sale.order.line field names.

+

Other example for ‘purchase.order.line’ fields:

+
+<field
+    name="order_line"
+    attrs="{'readonly': [('state', 'in', ('done','cancel'))]}"
+    nolabel="1"
+    widget="one2many_product_picker"
+    mode="form"
+    options="{'search': [{'name': _('Name'), 'domain': [['name', 'ilike', '$search']]}, {'name': _('Price'), 'domain': [['list_price', '=', $number_search]]}], 'field_map': {'product_uom_qty': 'product_qty'}, 'groups': [{'name': _('Desk'), 'domain': [['name', 'ilike', 'desk']], 'order': {'name': 'id', 'asc': true}}, {'name': _('Chairs'), 'domain': [['name', 'ilike', 'chair']]}]}"
+>
+    <form>
+        <field name="name" invisible="1" />
+        <field name="product_id" invisible="1" />
+        <field name="price_unit" invisible="1"  />
+        <field name="currency_id" invisible="1" />
+        <field name="order_id" invisible="1" />
+        <field name="date_planned" class="mb-1" />
+        <field name="product_qty" class="mb-1" widget="numeric_step" required="1" />
+        <field name="product_uom" class="mb-2" options="{'no_open': True, 'no_create': True, 'no_edit': True}" />
+    </form>
+</field>
+
+
+
-

Usage

+

Usage

You need to define the view fields. The view must be of form type. This is an example that uses the ‘sale.order.line’ fields:

@@ -436,7 +602,7 @@ This is an example that uses the ‘sale.order.line’ fields:

nolabel="1" widget="one2many_product_picker" mode="form" - options="{'search': [{'name': _('Name'), 'domain': [['name', 'ilike', '$search']]}, {'name': _('Price'), 'domain': [['list_price', '=', $number_search]]}], 'field_map': {'name': 'name', 'product': 'product_id', 'product_uom': 'product_uom', 'price': 'price_unit', 'parent_id': 'order_id', 'product_uom_qty': 'product_qty'}, 'groups': [{'name': _('Desk'), 'domain': [['name', 'ilike', 'desk']], 'order': {'name': 'id', 'asc': true}}, {'name': _('Chairs'), 'domain': [['name', 'ilike', 'chair']]}]}" + options="{'search': [{'name': _('Name'), 'domain': [['name', 'ilike', '$search']]}, {'name': _('Price'), 'domain': [['list_price', '=', $number_search]]}], 'field_map': {'product_uom_qty': 'product_qty'}, 'groups': [{'name': _('Desk'), 'domain': [['name', 'ilike', 'desk']], 'order': {'name': 'id', 'asc': true}}, {'name': _('Chairs'), 'domain': [['name', 'ilike', 'chair']]}]}" > <form> <field name="name" invisible="1" /> @@ -451,8 +617,8 @@ This is an example that uses the ‘sale.order.line’ fields:

</field>

** In this example we don’t use ‘field_map’ option because the default match with the sale.order.line field names.

-
-

Default context:

+
+

Default context:

The widget sends a defaults context with the ‘search_read’ request:

    @@ -464,25 +630,34 @@ This is an example that uses the ‘sale.order.line’ fields:

+
  • active_search_involved_fields > Contains an array of dictionaries with the fields used with the searchbox content

    +
    +
      +
    • ‘type’ > Can be ‘text’ or ‘number’
    • +
    • ‘field’ > The field name
    • +
    • ‘oper’ > The operator used
    • +
    +
    +
  • -

    Known issues / Roadmap

    +

    Known issues / Roadmap

    • Translations in the xml ‘options’ attribute of the field that use the widget can’t be exported automatically to be translated
    • -
    • The product card animations can be improved. Currently the card is recreated, so we lost some states to apply correct effects.
    • +
    • The product card animations can be improved. Currently the card is recreated, so we lost some elements to apply correct effects.
    -

    Bug Tracker

    +

    Bug Tracker

    Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed @@ -490,15 +665,15 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

    Do not contact contributors directly about support or help with technical issues.

    -

    Credits

    +

    Credits

    -

    Authors

    +

    Authors

    • Tecnativa
    -

    Contributors

    +

    Contributors

    • Tecnativa:

      @@ -512,7 +687,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
    -

    Maintainers

    +

    Maintainers

    This module is maintained by the OCA.

    Odoo Community Association

    OCA, or the Odoo Community Association, is a nonprofit organization whose 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 ccb9dc9cb..7f6eba729 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 @@ -259,7 +259,6 @@ odoo.define("web_widget_one2many_product_picker.ProductPickerQuickCreateFormView this._updateButtons(); } else { this.update({}, {reload: false}).then(function(){ - debugger; self.model.unsetDirty(self.handle); self.trigger_up("restore_flip_card"); self._updateButtons(); 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 e36351a25..c07d59531 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 @@ -13,8 +13,6 @@ odoo.define("web_widget_one2many_product_picker.One2ManyProductPickerRecord", fu var tools = require("web_widget_one2many_product_picker.tools"); var ProductPickerQuickModifPriceForm = require( "web_widget_one2many_product_picker.ProductPickerQuickModifPriceForm"); - var ProductPickerQuickCreateForm = require( - "web_widget_one2many_product_picker.ProductPickerQuickCreateForm"); var qweb = core.qweb; 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 ce4db1600..aac76e59a 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 @@ -302,6 +302,7 @@ odoo.define("web_widget_one2many_product_picker.FieldOne2ManyProductPicker", fun var soptions = options || {}; var context = _.extend({ 'active_search_group_name': this._activeSearchGroup.name, + 'active_search_involved_fields': this._searchContext.involvedFields, },this.state.data[this.name].getContext()); return $.Deferred(function (d) { @@ -420,6 +421,7 @@ odoo.define("web_widget_one2many_product_picker.FieldOne2ManyProductPicker", fun */ _getFullSearchDomain: function (domain) { var sdomain = _.clone(domain); + this._searchContext.involvedFields = []; if (!sdomain) { sdomain = _.clone(this._searchContext.domain) || []; if (this._searchContext.text) { @@ -427,6 +429,7 @@ odoo.define("web_widget_one2many_product_picker.FieldOne2ManyProductPicker", fun if (!(search_domain[0] instanceof Array)) { search_domain = search_domain[this._searchMode].domain; } + var involved_fields = []; // Iterate domain triplets and logic operators for (var index in search_domain) { var domain = _.clone(search_domain[index]); @@ -435,12 +438,23 @@ odoo.define("web_widget_one2many_product_picker.FieldOne2ManyProductPicker", fun // Replace right leaf with the current value of the search input if (domain[2] === "$number_search") { domain[2] = Number(this._searchContext.text); + involved_fields.push({ + type: 'number', + field: domain[0], + oper: domain[1], + }); } else if (typeof(domain[2]) === "string" && domain[2].includes("$search")) { - domain[2] = domain[2].replace(/\$search/, this._searchContext.text) + domain[2] = domain[2].replace(/\$search/, this._searchContext.text); + involved_fields.push({ + type: 'text', + field: domain[0], + oper: domain[1], + }); } } sdomain.push(domain); } + this._searchContext.involvedFields = involved_fields; } } return sdomain || [];