Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions product_search_multi_value/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
==========================
Product Search Multi Value
==========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:d97a663dd910f9bd31ab8620e54af1ec4c4eb0e54a67bcba08d32eb52d0e4e5a
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fodoo--pim-lightgray.png?logo=github
:target: https://github.com/OCA/odoo-pim/tree/18.0/product_search_multi_value
:alt: OCA/odoo-pim
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/odoo-pim-18-0/odoo-pim-18-0-product_search_multi_value
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/odoo-pim&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows users to search products based on a list of default
codes or barcodes. It can be extended to other values if needed.

**Table of contents**

.. contents::
:local:

Configuration
=============

By default, the multi value search looks on default_code and barcode
properties. If you need to extend to other property, you just need to
adapt the related system parameter:
'product_search_multi_value.search_field'.

Usage
=====

Go on the product search view and search on a list of default_code
separated by a space. The search must be based on "Multiple search"
field.

Known issues / Roadmap
======================

- The searched fields should not be related non stored ones where the
target model has an 'active' field as it can leads to not found
records.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/odoo-pim/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/odoo-pim/issues/new?body=module:%20product_search_multi_value%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* ACSONE SA/NV

Contributors
------------

- Cédric PIGEON <[email protected]>
- Xavier Bouquiaux <[email protected]>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/odoo-pim <https://github.com/OCA/odoo-pim/tree/18.0/product_search_multi_value>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions product_search_multi_value/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
13 changes: 13 additions & 0 deletions product_search_multi_value/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Product Search Multi Value",
"version": "18.0.1.0.1",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/odoo-pim",
"depends": ["product"],
"data": ["data/search_field_data.xml", "views/product_template_view.xml"],
"demo": [],
}
6 changes: 6 additions & 0 deletions product_search_multi_value/data/search_field_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<odoo noupdate="1">
<record model="ir.config_parameter" id="search_fields">
<field name="key">product_search_multi_value.search_fields</field>
<field name="value">['default_code', 'description']</field>
</record>
</odoo>
46 changes: 46 additions & 0 deletions product_search_multi_value/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_search_multi_value
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-02-12 10:47+0000\n"
"Last-Translator: mymage <[email protected]>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: product_search_multi_value
#: model:ir.model.fields,field_description:product_search_multi_value.field_product_product__search_multi
#: model:ir.model.fields,field_description:product_search_multi_value.field_product_search_multi_mixin__search_multi
#: model:ir.model.fields,field_description:product_search_multi_value.field_product_template__search_multi
msgid "Multiple search"
msgstr "Ricerca multipla"

#. module: product_search_multi_value
#. odoo-python
#: code:addons/product_search_multi_value/models/product.py:0
#, python-format
msgid "Operator %s is not usable with multisearch"
msgstr "L'operatore %s non è utilizzabile con la ricerca multipla"

#. module: product_search_multi_value
#: model:ir.model,name:product_search_multi_value.model_product_template
msgid "Product"
msgstr "Prodotto"

#. module: product_search_multi_value
#: model:ir.model,name:product_search_multi_value.model_product_product
msgid "Product Variant"
msgstr "Variante prodotto"

#. module: product_search_multi_value
#: model:ir.model,name:product_search_multi_value.model_product_search_multi_mixin
msgid "Product search multi value mixin"
msgstr "Mixin ricerca multi valore prodotto"
43 changes: 43 additions & 0 deletions product_search_multi_value/i18n/product_search_multi_value.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_search_multi_value
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: product_search_multi_value
#: model:ir.model.fields,field_description:product_search_multi_value.field_product_product__search_multi
#: model:ir.model.fields,field_description:product_search_multi_value.field_product_search_multi_mixin__search_multi
#: model:ir.model.fields,field_description:product_search_multi_value.field_product_template__search_multi
msgid "Multiple search"
msgstr ""

#. module: product_search_multi_value
#. odoo-python
#: code:addons/product_search_multi_value/models/product.py:0
#, python-format
msgid "Operator %s is not usable with multisearch"
msgstr ""

#. module: product_search_multi_value
#: model:ir.model,name:product_search_multi_value.model_product_template
msgid "Product"
msgstr ""

#. module: product_search_multi_value
#: model:ir.model,name:product_search_multi_value.model_product_product
msgid "Product Variant"
msgstr ""

#. module: product_search_multi_value
#: model:ir.model,name:product_search_multi_value.model_product_search_multi_mixin
msgid "Product search multi value mixin"
msgstr ""
46 changes: 46 additions & 0 deletions product_search_multi_value/i18n/tr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_search_multi_value
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-03-07 08:36+0000\n"
"Last-Translator: Ömer KÜLAK <[email protected]>\n"
"Language-Team: none\n"
"Language: tr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: product_search_multi_value
#: model:ir.model.fields,field_description:product_search_multi_value.field_product_product__search_multi
#: model:ir.model.fields,field_description:product_search_multi_value.field_product_search_multi_mixin__search_multi
#: model:ir.model.fields,field_description:product_search_multi_value.field_product_template__search_multi
msgid "Multiple search"
msgstr "Çoklu arama"

#. module: product_search_multi_value
#. odoo-python
#: code:addons/product_search_multi_value/models/product.py:0
#, python-format
msgid "Operator %s is not usable with multisearch"
msgstr "%s operatörü çoklu aramayla kullanılamıyor"

#. module: product_search_multi_value
#: model:ir.model,name:product_search_multi_value.model_product_template
msgid "Product"
msgstr "Ürün"

#. module: product_search_multi_value
#: model:ir.model,name:product_search_multi_value.model_product_product
msgid "Product Variant"
msgstr "Ürün Varyantı"

#. module: product_search_multi_value
#: model:ir.model,name:product_search_multi_value.model_product_search_multi_mixin
msgid "Product search multi value mixin"
msgstr "Ürün arama çoklu değer katmanı"
1 change: 1 addition & 0 deletions product_search_multi_value/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import product
64 changes: 64 additions & 0 deletions product_search_multi_value/models/product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import logging

from odoo import _, api, fields, models
from odoo.exceptions import UserError
from odoo.osv.expression import OR
from odoo.tools.safe_eval import safe_eval

_logger = logging.getLogger(__name__)


class ProductSearchMultiMixin(models.AbstractModel):
_name = "product.search.multi.mixin"
_description = "Product search multi value mixin"

search_multi = fields.Char(
"Multiple search",
compute="_compute_search_multi",
search="_search_multi",
)

def _compute_search_multi(self):
self.update({"search_multi": False})

@api.model
def _get_search_fields(self):
try:
search_fields = (
self.env["ir.config_parameter"]
.sudo()
.get_param("product_search_multi_value.search_fields")
)
return safe_eval(search_fields)
except SyntaxError as error:
_logger.error("Error while evaluating search fields")
_logger.error(error)
return []

def _search_multi(self, operator, value):
if operator == "=" or operator == "ilike":
operator = "in"
comparator = OR
else:
raise UserError(_("Operator %s is not usable with multisearch", operator))

value_list = value.split(" ") if " " in value else [value]
search_fields = self._get_search_fields()
domain_list = []
for search_field in search_fields:
domain_search_field = [(search_field, operator, tuple(value_list))]
domain_list.append(domain_search_field)
return comparator(domain_list)


class ProductTemplate(models.Model):
_inherit = ["product.template", "product.search.multi.mixin"]
_name = "product.template"


class ProductProduct(models.Model):
_inherit = ["product.product", "product.search.multi.mixin"]
_name = "product.product"
3 changes: 3 additions & 0 deletions product_search_multi_value/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
4 changes: 4 additions & 0 deletions product_search_multi_value/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
By default, the multi value search looks on default_code and barcode
properties. If you need to extend to other property, you just need to
adapt the related system parameter:
'product_search_multi_value.search_field'.
2 changes: 2 additions & 0 deletions product_search_multi_value/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Cédric PIGEON \<[email protected]\>
- Xavier Bouquiaux \<[email protected]\>
2 changes: 2 additions & 0 deletions product_search_multi_value/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module allows users to search products based on a list of default
codes or barcodes. It can be extended to other values if needed.
3 changes: 3 additions & 0 deletions product_search_multi_value/readme/ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- The searched fields should not be related non stored ones where the
target model has an 'active' field as it can leads to not found
records.
3 changes: 3 additions & 0 deletions product_search_multi_value/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Go on the product search view and search on a list of default_code
separated by a space. The search must be based on "Multiple search"
field.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading