[ADD] web_widget_dropdown_dynamic

[UPD] Update web_widget_dropdown_dynamic.pot

[UPD] Update web_widget_dropdown_dynamic_example.pot

[UPD] README.rst

[ADD] icon.png

[UPD] README.rst
This commit is contained in:
Alexey Pelykh
2019-09-11 14:04:03 +02:00
parent d83aa81376
commit 2b6ba77540
21 changed files with 1330 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import models

View File

@@ -0,0 +1,20 @@
# Copyright 2019 Brainbean Apps (https://brainbeanapps.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
'name': 'Dynamic Dropdown Widget: Example',
'summary': 'Demonstration of web_widget_dropdown_dynamic',
'category': 'Web',
'version': '12.0.1.0.0',
'license': 'AGPL-3',
'author':
'Brainbean Apps OU, '
'Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/web/',
'depends': [
'web_widget_dropdown_dynamic',
],
'data': [
'views/web_widget_dropdown_dynamic_example.xml',
],
'installable': True,
}

View File

@@ -0,0 +1,119 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * web_widget_dropdown_dynamic_example
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.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_example
#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__char_field
#: model_terms:ir.ui.view,arch_db:web_widget_dropdown_dynamic_example.web_widget_dropdown_dynamic_example_form
msgid "Char field"
msgstr ""
#. module: web_widget_dropdown_dynamic_example
#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__char_field_options
msgid "Char field options"
msgstr ""
#. module: web_widget_dropdown_dynamic_example
#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__create_uid
msgid "Created by"
msgstr ""
#. module: web_widget_dropdown_dynamic_example
#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__create_date
msgid "Created on"
msgstr ""
#. module: web_widget_dropdown_dynamic_example
#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__display_name
msgid "Display Name"
msgstr ""
#. module: web_widget_dropdown_dynamic_example
#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__id
msgid "ID"
msgstr ""
#. module: web_widget_dropdown_dynamic_example
#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__int_field
#: model_terms:ir.ui.view,arch_db:web_widget_dropdown_dynamic_example.web_widget_dropdown_dynamic_example_form
msgid "Int field"
msgstr ""
#. module: web_widget_dropdown_dynamic_example
#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__int_field_max
msgid "Int field (max)"
msgstr ""
#. module: web_widget_dropdown_dynamic_example
#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__int_field_min
msgid "Int field (min)"
msgstr ""
#. module: web_widget_dropdown_dynamic_example
#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example____last_update
msgid "Last Modified on"
msgstr ""
#. module: web_widget_dropdown_dynamic_example
#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__write_uid
msgid "Last Updated by"
msgstr ""
#. module: web_widget_dropdown_dynamic_example
#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__write_date
msgid "Last Updated on"
msgstr ""
#. module: web_widget_dropdown_dynamic_example
#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__name
msgid "Name"
msgstr ""
#. module: web_widget_dropdown_dynamic_example
#: selection:web.widget.dropdown.dynamic.example,selection_field:0
msgid "Option A"
msgstr ""
#. module: web_widget_dropdown_dynamic_example
#: selection:web.widget.dropdown.dynamic.example,selection_field:0
msgid "Option B"
msgstr ""
#. module: web_widget_dropdown_dynamic_example
#: selection:web.widget.dropdown.dynamic.example,selection_field:0
msgid "Option C"
msgstr ""
#. module: web_widget_dropdown_dynamic_example
#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__selection_field
#: model_terms:ir.ui.view,arch_db:web_widget_dropdown_dynamic_example.web_widget_dropdown_dynamic_example_form
msgid "Selection field"
msgstr ""
#. module: web_widget_dropdown_dynamic_example
#: model:ir.model.fields,field_description:web_widget_dropdown_dynamic_example.field_web_widget_dropdown_dynamic_example__selection_field_options
msgid "Selection field options"
msgstr ""
#. module: web_widget_dropdown_dynamic_example
#: model:ir.model,name:web_widget_dropdown_dynamic_example.model_web_widget_dropdown_dynamic_example
msgid "Web Widget Dropdown Dynamic Example"
msgstr ""
#. module: web_widget_dropdown_dynamic_example
#: model:ir.actions.act_window,name:web_widget_dropdown_dynamic_example.action_web_widget_dropdown_dynamic_example
#: model:ir.ui.menu,name:web_widget_dropdown_dynamic_example.web_widget_dropdown_dynamic_example_menu
msgid "web_widget_dropdown_dynamic Demo"
msgstr ""

View File

@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import web_widget_dropdown_dynamic_example

View File

@@ -0,0 +1,87 @@
# Copyright 2019 Brainbean Apps (https://brainbeanapps.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
class WebWidgetDropdownDynamicExample(models.TransientModel):
_name = 'web.widget.dropdown.dynamic.example'
_description = 'Web Widget Dropdown Dynamic Example'
name = fields.Char(
default='Web Widget Dropdown Dynamic Example',
required=True,
)
char_field_options = fields.Text(
string='Char field options',
default=(
'Option A\n'
'Option B\n'
'Option C\n'
),
)
char_field = fields.Char(
string='Char field',
)
int_field_min = fields.Integer(
string='Int field (min)',
default=0,
)
int_field_max = fields.Integer(
string='Int field (max)',
default=9,
)
int_field = fields.Integer(
string='Int field',
)
selection_field_options = fields.Text(
string='Selection field options',
default=(
'Option A\n'
'Option B\n'
'Option C\n'
'Option D\n'
),
)
selection_field = fields.Char(
string='Selection field',
selection=[
('Option A', 'Option A'),
('Option B', 'Option B'),
('Option C', 'Option C'),
]
)
@api.model
def values_char_field(self):
options = self.env.context.get('options').strip().split('\n')
return list(map(
lambda option: (option, option),
filter(
lambda option: bool(option),
options
)
))
@api.model
def values_int_field(self):
min_value = int(self.env.context.get('min'))
max_value = int(self.env.context.get('max'))
options = []
for value in range(min_value, max_value + 1):
options.append((value, str(value)))
return options
@api.model
def values_selection_field(self):
options = self.env.context.get('options').strip().split('\n')
return list(map(
lambda option: (option, option),
filter(
lambda option: bool(option),
options
)
))

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2019 Brainbean Apps (https://brainbeanapps.com)
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
-->
<odoo>
<record id="web_widget_dropdown_dynamic_example_form" model="ir.ui.view">
<field name="name">web.widget.dropdown.dynamic.example.form</field>
<field name="model">web.widget.dropdown.dynamic.example</field>
<field name="arch" type="xml">
<form>
<group string="Char field">
<field name="char_field_options"/>
<field
name="char_field"
widget="dynamic_dropdown"
values="values_char_field"
context="{'options': char_field_options}"
/>
</group>
<group string="Int field">
<field name="int_field_min"/>
<field name="int_field_max"/>
<field
name="int_field"
widget="dynamic_dropdown"
values="values_int_field"
context="{'min': int_field_min, 'max': int_field_max}"
/>
</group>
<group string="Selection field">
<field name="selection_field_options"/>
<field
name="selection_field"
widget="dynamic_dropdown"
values="values_selection_field"
context="{'options': selection_field_options}"
/>
</group>
</form>
</field>
</record>
<record id="action_web_widget_dropdown_dynamic_example" model="ir.actions.act_window">
<field name="name">web_widget_dropdown_dynamic Demo</field>
<field name="res_model">web.widget.dropdown.dynamic.example</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
</record>
<menuitem
id="web_widget_dropdown_dynamic_example_menu"
name="web_widget_dropdown_dynamic Demo"
action="action_web_widget_dropdown_dynamic_example"
/>
</odoo>