-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by pedrobaeza
- Loading branch information
Showing
21 changed files
with
1,139 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
21
web_widget_dropdown_dynamic/i18n/web_widget_dropdown_dynamic.pot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.