Skip to content

Commit

Permalink
[MIG] bi_view_editor: Migration to 15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ilo committed Mar 8, 2023
1 parent 1eb14ec commit fba0ff5
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 56 deletions.
14 changes: 12 additions & 2 deletions bi_view_editor/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,20 @@
"data": [
"security/ir.model.access.csv",
"security/rules.xml",
"templates/assets_template.xml",
"views/bve_view.xml",
],
"qweb": ["static/src/xml/bi_view_editor.xml"],
"assets": {
"web.assets_backend": [
"bi_view_editor/static/src/css/bve.css",
"bi_view_editor/static/src/js/bi_view_editor.js",
"bi_view_editor/static/src/js/bi_view_editor.JoinNodeDialog.js",
"bi_view_editor/static/src/js/bi_view_editor.ModelList.js",
"bi_view_editor/static/src/js/bi_view_editor.FieldList.js",
],
"web.assets_qweb": [
"bi_view_editor/static/src/xml/bi_view_editor.xml",
],
},
"uninstall_hook": "uninstall_hook",
"installable": True,
}
2 changes: 1 addition & 1 deletion bi_view_editor/models/bve_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def action_translations(self):
if self.state != "created":
return
self = self.sudo()
model = self.env["ir.model"].search([("model", "=", self.model_name)])
model = self.env["ir.model"].sudo().search([("model", "=", self.model_name)])
IrTranslation = self.env["ir.translation"]
IrTranslation.translate_fields("ir.model", model.id)
for field in model.field_id:
Expand Down
4 changes: 3 additions & 1 deletion bi_view_editor/models/ir_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def _check_unknown(model_name):
count_check += _check_contains(model_model)
count_check += _check_unknown(model_name)
if not count_check:
return self.env["ir.model.access"].check(model["model"], "read", False)
return (
self.env["ir.model.access"].sudo().check(model["model"], "read", False)
)
return False

def get_model_list(self, model_table_map):
Expand Down
1 change: 1 addition & 0 deletions bi_view_editor/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
* Andrea Stirpe <[email protected]>
* Antonio Esposito <[email protected]>
* Jordi Ballester Alomar <[email protected]>
* Italo LOPES <[email protected]>
22 changes: 11 additions & 11 deletions bi_view_editor/static/src/xml/bi_view_editor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
>
Use the field
<b>
<t t-esc="choice.model_name" />
<t t-out="choice.model_name" />
</b>
<i class="fa fa-caret-right" />
<b>
<t t-esc="choice.description" />
<t t-out="choice.description" />
</b>
<span class="badge">new</span>
</li>
Expand All @@ -58,11 +58,11 @@
>
Use the field
<b>
<t t-esc="choice.model_name" />
<t t-out="choice.model_name" />
</b>
<i class="fa fa-caret-right" />
<b>
<t t-esc="choice.description" />
<t t-out="choice.description" />
</b>
</li>
</t>
Expand All @@ -86,14 +86,14 @@
<t t-name="bi_view_editor.ModelListItem">
<div class="class-container">
<div class="class" t-attf-title="#{model}" t-attf-data-id="#{id}">
<t t-esc="name" />
<t t-out="name" />
</div>
</div>
</t>
<!-- ModelListFieldItem-->
<t t-name="bi_view_editor.ModelListFieldItem">
<div class="field" t-attf-title="#{name}" t-attf-data-id="#{name}">
<t t-esc="description" />
<t t-out="description" />
</div>
</t>
<!-- FieldList -->
Expand Down Expand Up @@ -190,7 +190,7 @@
/>
</td>
<td>
<t t-esc="field.model_name" />
<t t-out="field.model_name" />
</td>
<td>
<span
Expand Down Expand Up @@ -233,20 +233,20 @@
/>
<t t-if="field.join_node > field.table_alias">
<b>
<t t-esc="field.model_name" />
<t t-out="field.model_name" />
</b>
<i class="fa fa-caret-right" />
<small>
<t t-esc="field.description" />
<t t-out="field.description" />
</small>
</t>
<t t-else="">
<small>
<t t-esc="field.description" />
<t t-out="field.description" />
</small>
<i class="fa fa-caret-left" />
<b>
<t t-esc="field.model_name" />
<t t-out="field.model_name" />
</b>
</t>
<span
Expand Down
28 changes: 0 additions & 28 deletions bi_view_editor/templates/assets_template.xml

This file was deleted.

34 changes: 22 additions & 12 deletions bi_view_editor/tests/test_bi_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ class TestBiViewEditor(TransactionCase):
def setUp(self):
def _get_models(model_name_list):
return (
self.env["ir.model"].search([("model", "=", name)])
self.env["ir.model"].sudo().search([("model", "=", name)])
for name in model_name_list
)

def _get_fields(model_field_list):
return (
self.env["ir.model.fields"].search(
self.env["ir.model.fields"]
.sudo()
.search(
[("model", "=", model_field[0]), ("name", "=", model_field[1])],
limit=1,
)
Expand Down Expand Up @@ -117,8 +119,10 @@ def test_01_get_fields(self):
self.assertGreater(len(fields), 0)

def test_02_get_join_nodes(self):
field_res_users = self.env["ir.model.fields"].search(
[("name", "=", "login"), ("model", "=", "res.users")], limit=1
field_res_users = (
self.env["ir.model.fields"]
.sudo()
.search([("name", "=", "login"), ("model", "=", "res.users")], limit=1)
)
field_data = [
{
Expand Down Expand Up @@ -223,8 +227,10 @@ def test_09_create_open_bve_object(self):

# create bve object
bi_view.action_create()
model = self.env["ir.model"].search(
[("model", "=", "x_bve.testview4"), ("name", "=", "Test View4")]
model = (
self.env["ir.model"]
.sudo()
.search([("model", "=", "x_bve.testview4"), ("name", "=", "Test View4")])
)
self.assertEqual(len(model), 1)

Expand Down Expand Up @@ -367,12 +373,16 @@ def test_18_action_translations(self):

@odoo.tests.tagged("post_install", "-at_install")
def test_19_field_selection(self):
field = self.env["ir.model.fields"].search(
[
("model", "=", self.company_model_name),
("name", "=", "base_onboarding_company_state"),
],
limit=1,
field = (
self.env["ir.model.fields"]
.sudo()
.search(
[
("model", "=", self.company_model_name),
("name", "=", "base_onboarding_company_state"),
],
limit=1,
)
)
selection_data = [
{
Expand Down
2 changes: 1 addition & 1 deletion bi_view_editor/wizard/wizard_ir_model_menu_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def menu_create(self):
"action": "ir.actions.act_window,%d" % (bve_view.action_id,),
}
)
self.env["ir.model.data"].create(
self.env["ir.model.data"].sudo().create(
{
"name": bve_view.name + ",id=" + str(menu.id),
"noupdate": True,
Expand Down

0 comments on commit fba0ff5

Please sign in to comment.