mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[IMP] web_widget_dropdown_dynamic: black, isort, prettier
This commit is contained in:
@@ -1,20 +1,14 @@
|
||||
# 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,
|
||||
"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,
|
||||
}
|
||||
|
||||
@@ -5,71 +5,47 @@ from odoo import api, fields, models
|
||||
|
||||
|
||||
class WebWidgetDropdownDynamicExample(models.TransientModel):
|
||||
_name = 'web.widget.dropdown.dynamic.example'
|
||||
_description = 'Web Widget Dropdown Dynamic Example'
|
||||
_name = "web.widget.dropdown.dynamic.example"
|
||||
_description = "Web Widget Dropdown Dynamic Example"
|
||||
|
||||
name = fields.Char(
|
||||
default='Web Widget Dropdown Dynamic Example',
|
||||
required=True,
|
||||
)
|
||||
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',
|
||||
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',
|
||||
)
|
||||
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'
|
||||
),
|
||||
string="Selection field options",
|
||||
default=("Option A\n" "Option B\n" "Option C\n" "Option D\n"),
|
||||
)
|
||||
selection_field = fields.Char(
|
||||
string='Selection field',
|
||||
string="Selection field",
|
||||
selection=[
|
||||
('Option A', 'Option A'),
|
||||
('Option B', 'Option B'),
|
||||
('Option C', 'Option C'),
|
||||
]
|
||||
("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
|
||||
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'))
|
||||
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)))
|
||||
@@ -77,11 +53,10 @@ class WebWidgetDropdownDynamicExample(models.TransientModel):
|
||||
|
||||
@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
|
||||
options = self.env.context.get("options").strip().split("\n")
|
||||
return list(
|
||||
map(
|
||||
lambda option: (option, option),
|
||||
filter(lambda option: bool(option), options),
|
||||
)
|
||||
))
|
||||
)
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?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_options" />
|
||||
<field
|
||||
name="char_field"
|
||||
widget="dynamic_dropdown"
|
||||
@@ -20,8 +19,8 @@
|
||||
/>
|
||||
</group>
|
||||
<group string="Int field">
|
||||
<field name="int_field_min"/>
|
||||
<field name="int_field_max"/>
|
||||
<field name="int_field_min" />
|
||||
<field name="int_field_max" />
|
||||
<field
|
||||
name="int_field"
|
||||
widget="dynamic_dropdown"
|
||||
@@ -30,7 +29,7 @@
|
||||
/>
|
||||
</group>
|
||||
<group string="Selection field">
|
||||
<field name="selection_field_options"/>
|
||||
<field name="selection_field_options" />
|
||||
<field
|
||||
name="selection_field"
|
||||
widget="dynamic_dropdown"
|
||||
@@ -41,18 +40,18 @@
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_web_widget_dropdown_dynamic_example" model="ir.actions.act_window">
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user