====================================
Add custom filters for fields via UI
====================================

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

.. |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%2Fserver--ux-lightgray.png?logo=github
    :target: https://github.com/OCA/server-ux/tree/16.0/base_search_custom_field_filter
    :alt: OCA/server-ux
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
    :target: https://translation.odoo-community.org/projects/server-ux-16-0/server-ux-16-0-base_search_custom_field_filter
    :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/server-ux&target_branch=16.0
    :alt: Try me on Runboat

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

This module allows to define custom filters in the search views for an specific
field belonging to the document or any other related document.

This nature makes the definition quite technical, but once done, it adds the
element in the UI for regular user use.

**Table of contents**

.. contents::
   :local:

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

#. Go to *Settings > Technical > User Interface > Custom Field Filters*.
#. Create a new record, and define following information:

   * The **Model** for which you are defining the filter. It will appear in all
     the search views of this model.
   * The label you want to see on the search line on the **Name** field. This
     field allows translations for proper UI in different languages.
   * The **Expression**, which is the field chain string with dot notation.
     Examples: `product_id`, `product_id.seller_ids.name`, `partner_id.lang`.
   * Optionally, you can fill **Position After** for indicating after which
     existing field (technical name) the filter will appear. If empty or not
     found, the filter will be added at the end.
#. You can reorder records for determining sorting for multiple filters for the
   same model with the arrow handle in the left part.

Usage
=====

#. Go to the menu entry for which you have defined the custom field filter.
#. On the search bar, type anything.
#. In the filter list, you will see the line for the element you have defined.

As demo data, a custom field filter is included for sample purposes:

.. image:: https://raw.githubusercontent.com/OCA/server-ux/16.0/base_search_custom_field_filter/static/src/img/ir_ui_custom_field_filter.png

Steps for trying this sample:

#. Install `contacts` module.
#. Go to *Contacts*.
#. Type "english" and you'll find the filter "Language" at the end:

.. image:: https://raw.githubusercontent.com/OCA/server-ux/16.0/base_search_custom_field_filter/static/src/img/contact_search.png

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-ux/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/server-ux/issues/new?body=module:%20base_search_custom_field_filter%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
~~~~~~~

* Tecnativa
* Amitaujas

Contributors
~~~~~~~~~~~~

* `Tecnativa <https://www.tecnativa.com>`_:

  * Carlos Dauden
  * Pedro M. Baeza

* `Amitaujas <https://www.amitaujas.com>`_:

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.

.. |maintainer-pedrobaeza| image:: https://github.com/pedrobaeza.png?size=40px
    :target: https://github.com/pedrobaeza
    :alt: pedrobaeza
.. |maintainer-CarlosRoca13| image:: https://github.com/CarlosRoca13.png?size=40px
    :target: https://github.com/CarlosRoca13
    :alt: CarlosRoca13

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-pedrobaeza| |maintainer-CarlosRoca13| 

This module is part of the `OCA/server-ux <https://github.com/OCA/server-ux/tree/16.0/base_search_custom_field_filter>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
