mirror of https://github.com/OCA/web.git
Description ----------- This commit fixes incorrect bechavior (error thrown) in case when additional `domain` provided to action (`ir.actions.act_window`) that displays view with search panel enabled. Before this commit ------------------ For example we have following models: - My Category - My Model And in category view, we have stat-button that display number of records of records in this category. On click, it have to open view for My Model, with domain like `[('category_id', '=', 42)]`. In this case, following error will be raised: ```tracaback Error: Odoo Server Error Traceback (most recent call last): ... File "/opt/odoo/custom_addons/web_view_searchpanel/models/base.py", line 60, in search_panel_select_range hierarchical_naming=False).search_read(model_domain, fields), File "/opt/odoo/odoo/odoo/models.py", line 4615, in search_read records = self.search(domain or [], offset=offset, limit=limit, order=order) File "/opt/odoo/odoo/odoo/models.py", line 1581, in search res = self._search(args, offset=offset, limit=limit, order=order, count=count) File "/opt/odoo/odoo/odoo/models.py", line 4147, in _search query = self._where_calc(args) File "/opt/odoo/odoo/odoo/models.py", line 3939, in _where_calc e = expression.expression(domain, self) File "/opt/odoo/odoo/odoo/osv/expression.py", line 673, in __init__ self.parse() File "/opt/odoo/odoo/odoo/osv/expression.py", line 854, in parse raise ValueError("Invalid field %r in leaf %r" % (left, str(leaf))) ValueError: Invalid field 'category_id' in leaf "<osv.ExtendedLeaf: ('category_id', '=', 26) on bureaucrat_knowledge_category (ctx: )>" ``` Diagnostics ----------- It seems that model domain was passed to comodel, thus system cannot find field related to model in comodel. See code (web_view_searchpanel/models/base.py", line 60, in search_panel_select_range) As tested, the `search_domain` causes this bug. But if we look at implementation of same method (`search_panel_select_range`) in Odoo 13.0 (see [code](https://github.com/odoo/odoo/blob/13.0/addons/web/models/models.py#L214)) then we can see, that there is only empty domain applied for search. Solution -------- It seems, that variable `model_domain` could be simply removed, and we could do the search in comodel without any extra domain in this case. So, this commit, only makes imlementation of this method look same as in Odoo 13.0 After this commit ----------------- Everything is working fine. |
||
---|---|---|
.. | ||
demo | ||
i18n | ||
models | ||
readme | ||
static | ||
template | ||
README.rst | ||
__init__.py | ||
__manifest__.py |
README.rst
============ Search Panel ============ .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |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-LGPL--3-blue.png :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github :target: https://github.com/OCA/web/tree/12.0/web_view_searchpanel :alt: OCA/web .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png :target: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_view_searchpanel :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png :target: https://runbot.odoo-community.org/runbot/162/12.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| With Odoo version 13 a new feature is added which allows kanban views to be extended by a search panel. This can be defined via XML and is then automatically added to the view. With this module the function is ported back to version 12. **Table of contents** .. contents:: :local: Usage ===== This tool allows to quickly filter data on the basis of given fields. The fields are specified as direct children of the ``searchpanel`` with tag name ``field``, and the following attributes: * ``name`` (mandatory) the name of the field to filter on * ``select`` determines the behavior and display. * ``groups``: restricts to specific users * ``string``: determines the label to display * ``icon``: specifies which icon is used * ``color``: determines the icon color Possible values for the ``select`` attribute are * ``one`` (default) at most one value can be selected. Supported field types are many2one and selection. * ``multi`` several values can be selected (checkboxes). Supported field types are many2one, many2many and selection. Additional optional attributes are available in the ``multi`` case: * ``domain``: determines conditions that the comodel records have to satisfy. A domain might be used to express a dependency on another field (with select="one") of the search panel. Consider .. code-block:: xml <searchpanel> <field name="department_id"/> <field name="manager_id" select="multi" domain="[('department_id', '=', department_id)]"/> </searchpanel> In the above example, the range of values for manager_id (manager names) available at screen will depend on the value currently selected for the field ``department_id``. * ``groupby``: field name of the comodel (only available for many2one and many2many fields). Values will be grouped by that field. * ``disable_counters``: default is false. If set to true the counters won't be computed. This feature has been implemented in case performances would be too bad. Another way to solve performance issues is to properly override the ``search_panel_select_multi_range`` method. Bug Tracker =========== Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/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 `feedback <https://github.com/OCA/web/issues/new?body=module:%20web_view_searchpanel%0Aversion:%2012.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 ~~~~~~~ * MuK IT Contributors ~~~~~~~~~~~~ * Mathias Markl <mathias.markl@mukit.at> * Enric Tobella <etobella@creublanca.es> 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/web <https://github.com/OCA/web/tree/12.0/web_view_searchpanel>`_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.