Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr Nechyporenko committed Nov 21, 2023
1 parent db8651e commit ba71181
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test_crnd_web_models/demo/tree_colored_field.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,59 @@
<field name="name">Simple text for demonstration light brown colored field dark label</field>
<field name="bg_color">l_brown_bg</field>
<field name="label_color">dark</field>
<field name="field_colorized_by_state_expression">Test text background Light Gray label Dark Blue</field>
<field name="label_state">ok</field>
<field name="bg_state">ok</field>
</record>

<record id="tree_colored_field_green_bg_dark_label"
model="tree.colored.field">
<field name="name">Simple text for demonstration light green colored field dark label</field>
<field name="bg_color">l_green_bg</field>
<field name="label_color">dark</field>
<field name="field_colorized_by_state_expression">Test text background Mint Green label Dark Blue</field>
<field name="label_state">ok</field>
<field name="bg_state">warning</field>
</record>

<record id="tree_colored_field_blue_bg_dark_label"
model="tree.colored.field">
<field name="name">Simple text for demonstration light blue colored field dark label</field>
<field name="bg_color">l_blue_bg</field>
<field name="label_color">dark</field>
<field name="field_colorized_by_state_expression">Test text background Lavender label Dark Blue</field>
<field name="label_state">ok</field>
<field name="bg_state">fail</field>
</record>

<record id="tree_colored_field_brown_bg_white_label"
model="tree.colored.field">
<field name="name">Simple text for demonstration light brown colored field white label</field>
<field name="bg_color">l_brown_bg</field>
<field name="label_color">white</field>
<field name="field_colorized_by_state_expression">Test text background Light Gray label Indigo</field>
<field name="label_state">fail</field>
<field name="bg_state">ok</field>
</record>

<record id="tree_colored_field_green_bg_white_label"
model="tree.colored.field">
<field name="name">Simple text for demonstration light green colored field white label</field>
<field name="bg_color">l_green_bg</field>
<field name="label_color">white</field>
<field name="field_colorized_by_state_expression">Test text background Light Gray label Dark Slate Gray</field>
<field name="label_state">warning</field>
<field name="bg_state">ok</field>
</record>

<record id="tree_colored_field_blue_bg_white_label"
model="tree.colored.field">
<field name="name">Simple text for demonstration light blue colored field white label</field>
<field name="bg_color">l_blue_bg</field>
<field name="label_color">white</field>
<field name="field_colorized_by_state_expression">Test text background Light Gray label Dark Blue</field>
<field name="label_state">ok</field>
<field name="bg_state">ok</field>
</record>

</odoo>
18 changes: 18 additions & 0 deletions test_crnd_web_models/models/tree_colored_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,24 @@ class TreeColoredField(models.Model):
line_label_color = fields.Char(
compute='_compute_state_color')

# expression test fields
field_colorized_by_state_expression = fields.Char(
required=True,
help='Field, colorized by expression')
label_state = fields.Selection(
[('ok', 'Ok'),
('warning', 'Warning'),
('fail', 'Fail')], default='ok',
required=True,
help='This field defines color of label '
'"field_colorized_by_state_expression" field')
bg_state = fields.Selection(
[('ok', 'Ok'),
('warning', 'Warning'),
('fail', 'Fail')], default='fail',
required=True,
help='This field defines background color of cell '
'"field_colorized_by_state_expression" field')
@api.depends('bg_color', 'label_color')
def _compute_state_color(self):
"""
Expand Down

0 comments on commit ba71181

Please sign in to comment.