mirror of
https://github.com/odoo/runbot.git
synced 2025-03-15 23:45:44 +07:00
[FIX] runbot: adapt attrs
remove all attrs in xml views To help with that, a scripts was written, minimal but sufficent #!/usr/bin/python3 import glob import re from ast import literal_eval def leaf_to_python(leaf): if len(leaf) != 3: raise ValueError('This script doesnt support leaf', leaf) field, operator, value = leaf if operator == '=': return f'not {field}' if value is False else field if value is True else f'{field} == {value!r}' if operator == '!=': return f'not {field}' if value is True else field if value is False else f'{field} != {value!r}' if operator == 'in': return f'{field} in {value!r}' if operator == 'not in': return f'{field} not in {value!r}' raise ValueError('This script doesnt support operator', operator) for file in glob.glob('**/*.xml', recursive=True): with open(file) as f: content = f.read() attrs_list = re.findall(r'attrs="{.*}"', content) if attrs_list: for attrs in attrs_list: match = re.match(r'''attrs="{'(invisible|readonly)': ?(\[.*\])}"''', attrs) attr = match.groups()[0] domain = literal_eval(match.groups()[1]) condition = ' and '.join([leaf_to_python(leaf) for leaf in domain]) replace = f'{attr}="{condition}"' content = content.replace(attrs, replace) with open(file, 'w') as fw: fw.write(content)
This commit is contained in:
parent
e83db83533
commit
a250794432
@ -6,8 +6,8 @@
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<sheet>
|
||||
<widget name="web_ribbon" title="Test-tags" bg_color="bg-danger" attrs="{'invisible': [('test_tags', '=', False)]}"/>
|
||||
<widget name="web_ribbon" title="Linked to another error" bg_color="bg-warning" attrs="{'invisible': [('parent_id', '=', False)]}"/>
|
||||
<widget name="web_ribbon" title="Test-tags" bg_color="bg-danger" invisible="not test_tags"/>
|
||||
<widget name="web_ribbon" title="Linked to another error" bg_color="bg-warning" invisible="not parent_id"/>
|
||||
<header>
|
||||
</header>
|
||||
<group name="build_error_group" string="Base info" col="2">
|
||||
@ -18,13 +18,13 @@
|
||||
</group>
|
||||
<group name="fixer_info" string="Fixing" col="2">
|
||||
<group>
|
||||
<field name="responsible" attrs="{'readonly': [('parent_id','!=', False), ('responsible','=', False)]}"/>
|
||||
<field name="team_id" attrs="{'readonly': [('parent_id','!=', False), ('team_id','=', False)]}"/>
|
||||
<field name="responsible" readonly="parent_id and not responsible"/>
|
||||
<field name="team_id" readonly="parent_id and not team_id"/>
|
||||
<field name="fixing_pr_id"/>
|
||||
<field name="fixing_pr_url" widget="url"/>
|
||||
<field name="active"/>
|
||||
<field name="test_tags" decoration-danger="True" readonly="1" groups="!runbot.group_runbot_admin"/>
|
||||
<field name="test_tags" decoration-danger="True" groups="runbot.group_runbot_admin" attrs="{'readonly': [('parent_id','!=', False), ('test_tags','=', False)]}"/>
|
||||
<field name="test_tags" decoration-danger="True" groups="runbot.group_runbot_admin" readonly="parent_id and not test_tags"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="version_ids" widget="many2many_tags"/>
|
||||
@ -59,7 +59,7 @@
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Linked Errors" attrs="{'invisible': [('child_ids', '=', [])]}">
|
||||
<page string="Linked Errors" invisible="child_ids == []">
|
||||
<field name="child_ids" widget="many2many" options="{'not_delete': True, 'no_create': True}" readonly="1">
|
||||
<tree>
|
||||
<field name="create_date"/>
|
||||
@ -70,7 +70,7 @@
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Error history" attrs="{'invisible': [('error_history_ids', '=', [])]}">
|
||||
<page string="Error history" invisible="error_history_ids == []">
|
||||
<field name="error_history_ids" widget="one2many" options="{'not_delete': True, 'no_create': True}" readonly="1">
|
||||
<tree>
|
||||
<field name="create_date"/>
|
||||
@ -167,7 +167,7 @@
|
||||
<field name="test_tags"/>
|
||||
<field name="fixing_pr_id"/>
|
||||
<field name="fixing_pr_alive" invisible="1"/>
|
||||
<field name="fixing_pr_url" widget="url" text="view PR" readonly="1" attrs="{'invisible': [('fixing_pr_url', '=', False)]}"/>
|
||||
<field name="fixing_pr_url" widget="url" text="view PR" readonly="1" invisible="not fixing_pr_url"/>
|
||||
<field name="fingerprint" optional="hide"/>
|
||||
</tree>
|
||||
</field>
|
||||
@ -225,7 +225,7 @@
|
||||
<group name="build_regex_group">
|
||||
<field name="regex"/>
|
||||
<field name="re_type"/>
|
||||
<field name="replacement" attrs="{'invisible': [('re_type', '!=', 'cleaning')]}"/>
|
||||
<field name="replacement" invisible="re_type != 'cleaning'"/>
|
||||
</group>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
|
@ -6,7 +6,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Build config">
|
||||
<sheet>
|
||||
<div attrs="{'invisible': [('protected', '=', False)]}">
|
||||
<div invisible="not protected">
|
||||
<i class="fa fa-warning text-warning"/>This record is protected and can only be edited by config administrator.
|
||||
</div>
|
||||
<group>
|
||||
@ -35,7 +35,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Build config step">
|
||||
<sheet>
|
||||
<div class="label label-warning" attrs="{'invisible': [('protected', '=', False)]}">
|
||||
<div class="label label-warning" invisible="not protected">
|
||||
This record is protected and can only be edited by config administrator.
|
||||
</div>
|
||||
<group string="General settings">
|
||||
@ -48,7 +48,7 @@
|
||||
<field name="default_sequence" groups="base.group_no_one"/>
|
||||
<field name="group" groups="base.group_no_one"/>
|
||||
</group>
|
||||
<group string="Stats regexes" attrs="{'invisible': [('make_stats', '=', False)]}">
|
||||
<group string="Stats regexes" invisible="not make_stats">
|
||||
<field name="build_stat_regex_ids">
|
||||
<tree string="Regexes" editable="bottom">
|
||||
<field name="name"/>
|
||||
@ -57,34 +57,34 @@
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
<group string="Python settings" attrs="{'invisible': [('job_type', 'not in', ('python'))]}">
|
||||
<group string="Python settings" invisible="job_type not in 'python'">
|
||||
<field name="python_code" widget="ace" options="{'mode': 'python'}"/>
|
||||
<field name="python_result_code" widget="ace" options="{'mode': 'python'}"/>
|
||||
<field name="running_job"/>
|
||||
</group>
|
||||
<group string="Test settings" attrs="{'invisible': [('job_type', 'not in', ('python', 'install_odoo'))]}">
|
||||
<group string="Test settings" invisible="job_type not in ('python', 'install_odoo')">
|
||||
<field name="create_db" groups="base.group_no_one"/>
|
||||
<field name="install_modules"/>
|
||||
<field name="db_name" groups="base.group_no_one"/>
|
||||
<field name="cpu_limit" groups="base.group_no_one"/>
|
||||
<field name="coverage"/>
|
||||
<field name="paths_to_omit" attrs="{'invisible': [('coverage', '!=', True)]}"/>
|
||||
<field name="paths_to_omit" invisible="not coverage"/>
|
||||
<field name="test_enable"/>
|
||||
<field name="test_tags"/>
|
||||
<field name="enable_auto_tags"/>
|
||||
<field name="sub_command"/>
|
||||
</group>
|
||||
<group string="Extra Parameters" attrs="{'invisible': [('job_type', 'not in', ('python', 'install_odoo', 'test_upgrade', 'run_odoo'))]}">
|
||||
<group string="Extra Parameters" invisible="job_type not in ('python', 'install_odoo', 'test_upgrade', 'run_odoo')">
|
||||
<field name="extra_params"/>
|
||||
<field name="additionnal_env"/>
|
||||
<field name="enable_log_db"/>
|
||||
</group>
|
||||
<group string="Create settings" attrs="{'invisible': [('job_type', 'not in', ('python', 'create_build'))]}">
|
||||
<group string="Create settings" invisible="job_type not in ('python', 'create_build')">
|
||||
<field name="create_config_ids" widget="many2many_tags" options="{'no_create': True}" />
|
||||
<field name="number_builds"/>
|
||||
<field name="make_orphan"/>
|
||||
</group>
|
||||
<group attrs="{'invisible': [('job_type', 'not in', ('python', 'configure_upgrade'))]}">
|
||||
<group invisible="job_type not in ('python', 'configure_upgrade')">
|
||||
<group class="col" string="Target version settings">
|
||||
<field string="Current" name="upgrade_to_current"/>
|
||||
<field string="Master" name="upgrade_to_master"/>
|
||||
@ -110,12 +110,12 @@
|
||||
</field>
|
||||
</group>
|
||||
</group>
|
||||
<group string="Restore settings" attrs="{'invisible': [('job_type', '!=', 'restore')]}">
|
||||
<group string="Restore settings" invisible="job_type != 'restore'">
|
||||
<field name="restore_download_db_suffix"/>
|
||||
<field name="restore_rename_db_suffix"/>
|
||||
</group>
|
||||
|
||||
<group string="Codeowner settings" attrs="{'invisible': [('job_type', 'not in', ('codeowner', 'python'))]}">
|
||||
<group string="Codeowner settings" invisible="job_type not in ('codeowner', 'python')">
|
||||
<field name="fallback_reviewer"/>
|
||||
</group>
|
||||
<group>
|
||||
|
@ -20,9 +20,9 @@
|
||||
</group>
|
||||
<group string="Restore options">
|
||||
<field name="restore_mode"/>
|
||||
<field name="restore_dump_url" attrs="{'invisible': [('restore_mode', '!=', 'url')]}"/>
|
||||
<field name="restore_trigger_id" attrs="{'invisible': [('restore_mode', '!=', 'auto')]}"/>
|
||||
<field name="restore_database_suffix" attrs="{'invisible': [('restore_mode', '!=', 'auto')]}"/>
|
||||
<field name="restore_dump_url" invisible="restore_mode != 'url'"/>
|
||||
<field name="restore_trigger_id" invisible="restore_mode != 'auto'"/>
|
||||
<field name="restore_database_suffix" invisible="restore_mode != 'auto'"/>
|
||||
</group>
|
||||
<group colspan="4">
|
||||
<field name="child_extra_params"/>
|
||||
|
@ -25,7 +25,7 @@
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Errors" attrs="{'invisible': [('build_error_ids', '=', [])]}">
|
||||
<page string="Errors" invisible="build_error_ids == []">
|
||||
<field name="build_error_ids" nolabel="1" widget="many2many" options="{'not_delete': True, 'no_create': True}"/>
|
||||
</page>
|
||||
<page string="Modules">
|
||||
@ -40,11 +40,11 @@
|
||||
<field name="codeowner_ids">
|
||||
</field>
|
||||
</page>
|
||||
<page string="Followed triggers" attrs="{'invisible': [('trigger_ids', '=', [])]}">
|
||||
<page string="Followed triggers" invisible="trigger_ids == []">
|
||||
<field name="trigger_ids">
|
||||
</field>
|
||||
</page>
|
||||
<page string="Exceptions" attrs="{'invisible': [('upgrade_exception_ids', '=', [])]}">
|
||||
<page string="Exceptions" invisible="upgrade_exception_ids == []">
|
||||
<field name="upgrade_exception_ids" readonly="1"/>
|
||||
</page>
|
||||
</notebook>
|
||||
|
@ -6,7 +6,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Dockerfile">
|
||||
<sheet>
|
||||
<widget name="web_ribbon" title="Empty" bg_color="bg-warning" attrs="{'invisible': [('dockerfile', '!=', '')]}"/>
|
||||
<widget name="web_ribbon" title="Empty" bg_color="bg-warning" invisible="dockerfile != ''"/>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
<field name="image_tag"/>
|
||||
|
@ -8,7 +8,7 @@
|
||||
<header>
|
||||
</header>
|
||||
<sheet>
|
||||
<widget name="web_ribbon" title="Archived" bg_color="bg-danger" attrs="{'invisible': [('active', '=', True)]}"/>
|
||||
<widget name="web_ribbon" title="Archived" bg_color="bg-danger" invisible="active"/>
|
||||
<field name="active" invisible="1"/>
|
||||
<group name="Base config">
|
||||
<group>
|
||||
|
Loading…
Reference in New Issue
Block a user