Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
86 changes: 86 additions & 0 deletions attribute_set_searchable/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
========================
Attribute Set Searchable
========================

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

.. |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/16.0/attribute_set_searchable
: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-16-0/odoo-pim-16-0-attribute_set_searchable
: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=16.0
:alt: Try me on Runboat

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

This module allows the user to make an attribute searchable directly from the search view of the related model.

**Table of contents**

.. contents::
:local:

Usage
=====

On the attribute, thick the check box 'Searchable' and refresh your browser.
Open the search view linked to the related model and begin to type, the attribute is now available.

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:%20attribute_set_searchable%0Aversion:%2016.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]>
* Dhara Solanki <[email protected]>
* `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`_

* Bhavesh Heliconia

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/16.0/attribute_set_searchable>`_ 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 attribute_set_searchable/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions attribute_set_searchable/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Attribute Set Searchable",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "ACSONE SA/NV,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/odoo-pim",
"depends": ["attribute_set", "base_search_custom_field_filter"],
"data": ["views/attribute_attribute.xml"],
"demo": [],
"installable": True,
}
24 changes: 24 additions & 0 deletions attribute_set_searchable/i18n/attribute_set_searchable.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * attribute_set_searchable
#
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: attribute_set_searchable
#: model:ir.model,name:attribute_set_searchable.model_attribute_attribute
msgid "Attribute"
msgstr ""

#. module: attribute_set_searchable
#: model:ir.model,name:attribute_set_searchable.model_ir_ui_custom_field_filter
msgid "Custom UI field filter"
msgstr ""
28 changes: 28 additions & 0 deletions attribute_set_searchable/i18n/de.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
msgid ""
msgstr ""
"Project-Id-Version: ametras-xsolutions\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: German\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-Crowdin-Project: ametras-xsolutions\n"
"X-Crowdin-Project-ID: 530964\n"
"X-Crowdin-Language: de\n"
"X-Crowdin-File: /[AmetrasIntelligence.oca-migrated] 16.0/attribute_set_searchable/i18n/attribute_set_searchable.pot\n"
"X-Crowdin-File-ID: 21366\n"
"Language: de_DE\n"
"PO-Revision-Date: 2024-09-25 12:08\n"

#. module: attribute_set_searchable
#: model:ir.model,name:attribute_set_searchable.model_attribute_attribute
msgid "Attribute"
msgstr ""

#. module: attribute_set_searchable
#: model:ir.model,name:attribute_set_searchable.model_ir_ui_custom_field_filter
msgid "Custom UI field filter"
msgstr ""

28 changes: 28 additions & 0 deletions attribute_set_searchable/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
msgid ""
msgstr ""
"Project-Id-Version: ametras-xsolutions\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: French\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-Crowdin-Project: ametras-xsolutions\n"
"X-Crowdin-Project-ID: 530964\n"
"X-Crowdin-Language: fr\n"
"X-Crowdin-File: /[AmetrasIntelligence.oca-migrated] 16.0/attribute_set_searchable/i18n/attribute_set_searchable.pot\n"
"X-Crowdin-File-ID: 21366\n"
"Language: fr_FR\n"
"PO-Revision-Date: 2024-09-25 12:08\n"

#. module: attribute_set_searchable
#: model:ir.model,name:attribute_set_searchable.model_attribute_attribute
msgid "Attribute"
msgstr ""

#. module: attribute_set_searchable
#: model:ir.model,name:attribute_set_searchable.model_ir_ui_custom_field_filter
msgid "Custom UI field filter"
msgstr ""

2 changes: 2 additions & 0 deletions attribute_set_searchable/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import attribute_attribute
from . import ir_ui_custom_field_filter
66 changes: 66 additions & 0 deletions attribute_set_searchable/models/attribute_attribute.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class AttributeAttribute(models.Model):

_inherit = "attribute.attribute"

searchable = fields.Boolean(default=False)

def _get_custom_filter(self):
self.ensure_one()
return self.env["ir.ui.custom.field.filter"].search(
[("attribute_id", "=", self.id)]
)

def _prepare_create_custom_filter(self):
self.ensure_one()
model_id = self.attribute_group_id.model_id
return {
"model_id": model_id.id,
"name": self.field_description,
"expression": self.name,
"sequence": self.sequence,
"attribute_id": self.id,
}

def _create_custom_filter(self):
data = self._prepare_create_custom_filter()
return self.env["ir.ui.custom.field.filter"].create(data)

def _update_custom_filter(self, custom_filter):
self.ensure_one()
data = {}
if custom_filter.name != self.field_description:
data.update({"name": self.field_description})
if custom_filter.expression != self.name:
data.update({"expression": self.name})
if custom_filter.sequence != self.sequence:
data.update({"sequence": self.sequence})
if data:
custom_filter.write(data)

def write(self, vals):
res = super(AttributeAttribute, self).write(vals)
for attribute in self:
custom_filter = self._get_custom_filter()
if attribute.searchable:
if not custom_filter:
self._create_custom_filter()
else:
self._update_custom_filter(custom_filter)
elif custom_filter:
custom_filter.unlink()
return res

@api.model_create_multi
@api.returns("self", lambda value: value.id)
def create(self, vals_list):
attributes = super(AttributeAttribute, self).create(vals_list)
search_attributes = attributes.filtered(lambda att: att.searchable)
for attribute in search_attributes:
attribute._create_custom_filter()
return attributes
11 changes: 11 additions & 0 deletions attribute_set_searchable/models/ir_ui_custom_field_filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2020 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class IrUiCustomFieldFilter(models.Model):

_inherit = "ir.ui.custom.field.filter"

attribute_id = fields.Many2one("attribute.attribute", ondelete="cascade")
5 changes: 5 additions & 0 deletions attribute_set_searchable/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* Cédric PIGEON <[email protected]>
* Dhara Solanki <[email protected]>
* `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`_

* Bhavesh Heliconia
1 change: 1 addition & 0 deletions attribute_set_searchable/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This module allows the user to make an attribute searchable directly from the search view of the related model.
2 changes: 2 additions & 0 deletions attribute_set_searchable/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
On the attribute, thick the check box 'Searchable' and refresh your browser.
Open the search view linked to the related model and begin to type, the attribute is now available.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading