Skip to content

Commit

Permalink
[FIX] adapt code and test to renaming of <tree> to <list> in Odoo 18
Browse files Browse the repository at this point in the history
See odoo/odoo#159909

closes #134

Related: odoo/upgrade#6484
Signed-off-by: Christophe Simonis (chs) <[email protected]>
  • Loading branch information
KangOl committed Sep 10, 2024
1 parent b7fbb07 commit 062d11a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/base/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,17 +310,18 @@ def test_any_operator(self):

class TestAdaptDomainView(UnitTestCase):
def test_adapt_domain_view(self):
tag = "list" if util.version_gte("saas~17.5") else "tree"
view_form = self.env["ir.ui.view"].create(
{
"name": "test_adapt_domain_view_form",
"model": "res.currency",
"arch": """\
"arch": f"""\
<form>
<field name="rate_ids">
<tree>
<{tag}>
<field name="company_id" domain="[('email', '!=', False)]"/>
<field name="company_id" domain="[('email', 'not like', 'odoo.com')]"/>
</tree>
</{tag}>
</field>
</form>
""",
Expand Down
5 changes: 3 additions & 2 deletions src/util/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -1599,6 +1599,7 @@ def ensure_mail_alias_mapping(cr, model, record_xmlid, alias_xmlid, alias_name):


def remove_act_window_view_mode(cr, model, view_mode):
default = "list,form" if version_gte("saas~17.5") else "tree,form"
cr.execute(
"""
WITH upd AS (
Expand All @@ -1608,7 +1609,7 @@ def remove_act_window_view_mode(cr, model, view_mode):
ARRAY_TO_STRING(ARRAY_REMOVE(STRING_TO_ARRAY(view_mode, ','), %s), ','),
'' -- invalid value
),
'tree,form' -- default value
%s -- default value
)
WHERE act.res_model = %s
AND %s = ANY(STRING_TO_ARRAY(act.view_mode, ','))
Expand All @@ -1620,5 +1621,5 @@ def remove_act_window_view_mode(cr, model, view_mode):
WHERE upd.id = av.act_window_id
AND av.view_mode=%s
""",
[view_mode, model, view_mode, view_mode],
[view_mode, default, model, view_mode, view_mode],
)

0 comments on commit 062d11a

Please sign in to comment.