Skip to content

Commit

Permalink
[MIG] remove_odoo_enterprise: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-filament committed Jul 29, 2024
1 parent d857c38 commit e86b875
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 33 deletions.
2 changes: 1 addition & 1 deletion remove_odoo_enterprise/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Remove Odoo Enterprise",
"summary": "Remove enterprise modules and setting items",
"version": "16.0.2.0.1",
"version": "17.0.1.0.0",
"category": "Maintenance",
"author": "Eska, Onestein, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/server-brand",
Expand Down
1 change: 0 additions & 1 deletion remove_odoo_enterprise/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@

from . import base
from . import res_config_settings
from . import ir_module_module
8 changes: 5 additions & 3 deletions remove_odoo_enterprise/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ class Base(models.AbstractModel):
_inherit = "base"

@api.model
def search(self, domain, offset=0, limit=None, order=None, count=False):
res = super().search(domain, offset, limit, order, count)
if not count and self._name == "payment.provider":
def search_fetch(self, domain, field_names, offset=0, limit=None, order=None):
res = super().search_fetch(domain, field_names, offset, limit, order)
if self._name == "ir.module.module":
res = res.filtered(lambda a: not a.to_buy)
elif self._name == "payment.provider":
res = res.filtered(lambda a: not a.module_to_buy)
return res
13 changes: 0 additions & 13 deletions remove_odoo_enterprise/models/ir_module_module.py

This file was deleted.

24 changes: 17 additions & 7 deletions remove_odoo_enterprise/models/res_config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,26 @@ def get_views(self, views, options=None):

doc = etree.XML(ret_val["views"]["form"]["arch"])

query = "//div[div[field[@widget='upgrade_boolean']]]"
query = "//setting[field[@widget='upgrade_boolean']]"
for item in doc.xpath(query):
item.attrib["class"] = "d-none"

Check warning on line 26 in remove_odoo_enterprise/models/res_config_settings.py

View check run for this annotation

Codecov / codecov/patch

remove_odoo_enterprise/models/res_config_settings.py#L26

Added line #L26 was not covered by tests

for container in doc.xpath("//div[contains(@class, 'o_settings_container')]"):
if len(container.xpath("div[not(contains(@class, 'd-none'))]")) == 0:
prev_el = container.getprevious()
if len(prev_el) and prev_el.tag == "h2":
prev_el.attrib["class"] = "d-none"
container.attrib["class"] = "d-none"
for block in doc.xpath("//block"):
if (
len(
block.xpath(
"""setting[
not(contains(@class, 'd-none'))
and not(@invisible='1')]
"""
)
)
== 0
):
# Removing title and tip so that no empty h2 or h3 are displayed
block.attrib.pop("title", None)
block.attrib.pop("tip", None)
block.attrib["class"] = "d-none"

ret_val["views"]["form"]["arch"] = etree.tostring(doc)
return ret_val
12 changes: 5 additions & 7 deletions remove_odoo_enterprise/tests/test_remove_odoo_enterprise.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Copyright 2023 Le Filament (https://le-filament.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

import json

from lxml import etree

Expand All @@ -16,7 +15,7 @@ def test_res_config_settings(self):
view = conf.get_views([[False, "form"]])["views"]["form"]
doc = etree.XML(view["arch"])

query = "//div[div[field[@widget='upgrade_boolean']]]"
query = "//setting[field[@widget='upgrade_boolean']]"
for item in doc.xpath(query):
self.assertEqual(item.attrib["class"], "d-none")

Check warning on line 20 in remove_odoo_enterprise/tests/test_remove_odoo_enterprise.py

View check run for this annotation

Codecov / codecov/patch

remove_odoo_enterprise/tests/test_remove_odoo_enterprise.py#L20

Added line #L20 was not covered by tests

Expand All @@ -35,10 +34,9 @@ def test_appstore_invisible(self):
view = conf.get_views([[False, "form"]])["views"]["form"]
doc = etree.XML(view["arch"])

query = "//div[@id='appstore']"
query = "//setting[@id='appstore']"
for item in doc.xpath(query):
invisible_attrib = json.loads(item.attrib["modifiers"])
self.assertTrue(invisible_attrib["invisible"])
self.assertTrue(item.attrib["invisible"])

def test_appstore_visible(self):
"""Disabling the view makes the appstore widget visible again"""
Expand All @@ -50,6 +48,6 @@ def test_appstore_visible(self):
view = conf.get_views([[False, "form"]])["views"]["form"]
doc = etree.XML(view["arch"])

query = "//div[@id='appstore']"
query = "//setting[@id='appstore']"
for item in doc.xpath(query):
self.assertNotIn("modifiers", item.attrib)
self.assertNotIn("invisible", item.attrib)
2 changes: 1 addition & 1 deletion remove_odoo_enterprise/views/res_config_settings_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="base_setup.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@id='appstore']" position="attributes">
<xpath expr="//setting[@id='appstore']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</field>
Expand Down

0 comments on commit e86b875

Please sign in to comment.