Skip to content

Commit

Permalink
Merge PR #2915 into 17.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Aug 14, 2024
2 parents fa5050f + c3acb6e commit fba577b
Show file tree
Hide file tree
Showing 21 changed files with 1,139 additions and 1 deletion.
2 changes: 1 addition & 1 deletion web_m2x_options/static/src/components/form.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ patch(FormController.prototype, {
* add more method to add subview limit on formview
*/
async _setSubViewLimit() {
const ir_options = session.web_m2x_options;
const ir_options = session.web_m2x_options || {};
const activeFields = this.archInfo.fieldNodes,
isSmall = this.user;

Expand Down
141 changes: 141 additions & 0 deletions web_widget_dropdown_dynamic/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
=======================
Dynamic Dropdown Widget
=======================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:e2b8eb236b4dc206f3a4ab9b5932f86c2e46c33bdac31c385725384f3fe970e3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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%2Fweb-lightgray.png?logo=github
:target: https://github.com/OCA/web/tree/17.0/web_widget_dropdown_dynamic
:alt: OCA/web
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/web-17-0/web-17-0-web_widget_dropdown_dynamic
: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/web&target_branch=17.0
:alt: Try me on Runboat

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

Dynamic dropdown widget that supports resolving options from backend of:

- ``fields.Char``
- ``fields.Integer``
- ``fields.Selection``

**NOTE:** This widget is not intended to *extend* ``fields.Selection``,
but to filter selection values. For fully-dynamic set of options, use
``fields.Char`` instead.

**Table of contents**

.. contents::
:local:

Usage
=====

.. code:: python
@api.model
def method_name(self):
values = [
('value_a', 'Title A'),
]
if self.env.context.get('depending_on') == True:
values += [
('value_b', 'Title B'),
]
return values
.. code:: xml
<field
name="other_field"
/>
<field
name="char_field"
widget="dynamic_dropdown"
options="{'values':'method_name'}"
context="{'depending_on': other_field}"
/>
**DEMO**

On User defined filters added new field to show the feature, it is
called **Dropdown Integer**. If any user selected just One option shoud
appear, but if Mitchell Admin it should be possible to select option One
and Two.

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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_widget_dropdown_dynamic%0Aversion:%2017.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
-------

* CorporateHub

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

- `CorporateHub <https://corporatehub.eu/>`__

- Alexey Pelykh <[email protected]>

- `Therp BV <https://therp.nl/>`__

- Ronald Portier <[email protected]>

- Thanakrit Pintana <[email protected]>

- `Trobz <https://trobz.com>`__:

- Son Ho <[email protected]>

- `Tecnativa <https://www.tecnativa.com>`__:

- Carlos Roca

Other credits
-------------

The migration of this module from 15.0 to 16.0 was financially supported
by Camptocamp

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/17.0/web_widget_dropdown_dynamic>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions web_widget_dropdown_dynamic/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import models
26 changes: 26 additions & 0 deletions web_widget_dropdown_dynamic/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2019-2020 Brainbean Apps (https://brainbeanapps.com)
# Copyright 2020 CorporateHub (https://corporatehub.eu)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Dynamic Dropdown Widget",
"summary": "This module adds support for dynamic dropdown widget",
"category": "Web",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"author": "CorporateHub, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/web",
"depends": ["web"],
"installable": True,
"assets": {
"web.assets_backend": [
"web_widget_dropdown_dynamic/static/src/js/field_dynamic_dropdown.esm.js",
],
"web.qunit_suite_tests": [
"web_widget_dropdown_dynamic/static/tests/web_widget_dropdown_dynamic_tests.esm.js",
],
},
"demo": [
"demo/ir_model_fields.xml",
"demo/ir_filters_view.xml",
],
}
17 changes: 17 additions & 0 deletions web_widget_dropdown_dynamic/demo/ir_filters_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="ir_filters_view_form" model="ir.ui.view">
<field name="model">ir.filters</field>
<field name="inherit_id" ref="base.ir_filters_view_form" />
<field name="arch" type="xml">
<field name="user_id" position="after">
<field
name="x_dynamic_dropdown_int"
widget="dynamic_dropdown"
options="{'values': 'dynamic_dropdown_int_method_demo'}"
context="{'depending_on': user_id}"
/>
</field>
</field>
</record>
</odoo>
11 changes: 11 additions & 0 deletions web_widget_dropdown_dynamic/demo/ir_model_fields.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="field_dynamic_dropdown_int" model="ir.model.fields">
<field name="field_description">Dropdown Integer</field>
<field name="model">ir.filters</field>
<field name="model_id" ref="base.model_ir_filters" />
<field name="name">x_dynamic_dropdown_int</field>
<field name="state">manual</field>
<field name="ttype">integer</field>
</record>
</odoo>
24 changes: 24 additions & 0 deletions web_widget_dropdown_dynamic/i18n/de.po
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:
# * web_widget_dropdown_dynamic
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2021-10-13 20:46+0000\n"
"Last-Translator: Corneliuus <[email protected]>\n"
"Language-Team: none\n"
"Language: de\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.3.2\n"

#. module: web_widget_dropdown_dynamic
#. odoo-javascript
#: code:addons/web_widget_dropdown_dynamic/static/src/js/field_dynamic_dropdown.esm.js:0
#, python-format
msgid "Dynamic Dropdown"
msgstr "Dynamisches Dropdown"
24 changes: 24 additions & 0 deletions web_widget_dropdown_dynamic/i18n/es.po
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:
# * web_widget_dropdown_dynamic
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2021-02-17 14:45+0000\n"
"Last-Translator: claudiagn <[email protected]>\n"
"Language-Team: none\n"
"Language: es\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.3.2\n"

#. module: web_widget_dropdown_dynamic
#. odoo-javascript
#: code:addons/web_widget_dropdown_dynamic/static/src/js/field_dynamic_dropdown.esm.js:0
#, python-format
msgid "Dynamic Dropdown"
msgstr "Menú desplegable dinámico"
24 changes: 24 additions & 0 deletions web_widget_dropdown_dynamic/i18n/it.po
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:
# * web_widget_dropdown_dynamic
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-11-27 11:37+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: web_widget_dropdown_dynamic
#. odoo-javascript
#: code:addons/web_widget_dropdown_dynamic/static/src/js/field_dynamic_dropdown.esm.js:0
#, python-format
msgid "Dynamic Dropdown"
msgstr "Dropdown dinamico"
21 changes: 21 additions & 0 deletions web_widget_dropdown_dynamic/i18n/web_widget_dropdown_dynamic.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_widget_dropdown_dynamic
#
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: web_widget_dropdown_dynamic
#. odoo-javascript
#: code:addons/web_widget_dropdown_dynamic/static/src/js/field_dynamic_dropdown.esm.js:0
#, python-format
msgid "Dynamic Dropdown"
msgstr ""
4 changes: 4 additions & 0 deletions web_widget_dropdown_dynamic/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from odoo.tools import config

if not config.get("without_demo"):
from . import ir_filters
19 changes: 19 additions & 0 deletions web_widget_dropdown_dynamic/models/ir_filters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 Tecnativa - Carlos Roca
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import api, models


class IrFilters(models.Model):
_inherit = "ir.filters"

@api.model
def dynamic_dropdown_int_method_demo(self):
values = [
("1", "One"),
]
if self.env.context.get("depending_on") == self.env.ref("base.user_admin").id:
values += [
("2", "Two"),
]
return values
3 changes: 3 additions & 0 deletions web_widget_dropdown_dynamic/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
16 changes: 16 additions & 0 deletions web_widget_dropdown_dynamic/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
- [CorporateHub](https://corporatehub.eu/)

- Alexey Pelykh \<<[email protected]>\>

- [Therp BV](https://therp.nl/)

- Ronald Portier \<<[email protected]>\>

- Thanakrit Pintana \<<[email protected]>\>

- [Trobz](https://trobz.com):

> - Son Ho \<<[email protected]>\>
- [Tecnativa](https://www.tecnativa.com):
- Carlos Roca
2 changes: 2 additions & 0 deletions web_widget_dropdown_dynamic/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The migration of this module from 15.0 to 16.0 was financially supported
by Camptocamp
9 changes: 9 additions & 0 deletions web_widget_dropdown_dynamic/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Dynamic dropdown widget that supports resolving options from backend of:

> - `fields.Char`
> - `fields.Integer`
> - `fields.Selection`
**NOTE:** This widget is not intended to *extend* `fields.Selection`,
but to filter selection values. For fully-dynamic set of options, use
`fields.Char` instead.
30 changes: 30 additions & 0 deletions web_widget_dropdown_dynamic/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
``` python
@api.model
def method_name(self):
values = [
('value_a', 'Title A'),
]
if self.env.context.get('depending_on') == True:
values += [
('value_b', 'Title B'),
]
return values
```

``` xml
<field
name="other_field"
/>
<field
name="char_field"
widget="dynamic_dropdown"
options="{'values':'method_name'}"
context="{'depending_on': other_field}"
/>
```

**DEMO**

On User defined filters added new field to show the feature, it is called
**Dropdown Integer**. If any user selected just One option shoud appear, but if
Mitchell Admin it should be possible to select option One and Two.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit fba577b

Please sign in to comment.