diff --git a/bi_view_editor/__manifest__.py b/bi_view_editor/__manifest__.py index d30045a1c..dd4ecf602 100644 --- a/bi_view_editor/__manifest__.py +++ b/bi_view_editor/__manifest__.py @@ -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, } diff --git a/bi_view_editor/models/bve_view.py b/bi_view_editor/models/bve_view.py index 5e0877787..6392a9739 100644 --- a/bi_view_editor/models/bve_view.py +++ b/bi_view_editor/models/bve_view.py @@ -393,7 +393,7 @@ class BveView(models.Model): 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: diff --git a/bi_view_editor/models/ir_model.py b/bi_view_editor/models/ir_model.py index 8feeaf4ad..16b501c64 100644 --- a/bi_view_editor/models/ir_model.py +++ b/bi_view_editor/models/ir_model.py @@ -69,7 +69,9 @@ class IrModel(models.Model): 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): diff --git a/bi_view_editor/readme/CONTRIBUTORS.rst b/bi_view_editor/readme/CONTRIBUTORS.rst index 14cc58d68..92632b85a 100644 --- a/bi_view_editor/readme/CONTRIBUTORS.rst +++ b/bi_view_editor/readme/CONTRIBUTORS.rst @@ -6,3 +6,4 @@ * Andrea Stirpe <a.stirpe@onestein.nl> * Antonio Esposito <a.esposito@onestein.nl> * Jordi Ballester Alomar <jordi.ballester@eficent.com> +* Italo LOPES <italo.lopes@camptocamp.com> diff --git a/bi_view_editor/static/src/xml/bi_view_editor.xml b/bi_view_editor/static/src/xml/bi_view_editor.xml index 569d834e6..c69828e55 100644 --- a/bi_view_editor/static/src/xml/bi_view_editor.xml +++ b/bi_view_editor/static/src/xml/bi_view_editor.xml @@ -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> @@ -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> @@ -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 --> @@ -190,7 +190,7 @@ /> </td> <td> - <t t-esc="field.model_name" /> + <t t-out="field.model_name" /> </td> <td> <span @@ -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 diff --git a/bi_view_editor/templates/assets_template.xml b/bi_view_editor/templates/assets_template.xml deleted file mode 100644 index e97b656d9..000000000 --- a/bi_view_editor/templates/assets_template.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<odoo> - <template - id="assets_backend" - name="bi_view_editor assets" - inherit_id="web.assets_backend" - > - <xpath expr="." position="inside"> - <link rel="stylesheet" href="/bi_view_editor/static/src/css/bve.css" /> - <script - type="text/javascript" - src="/bi_view_editor/static/src/js/bi_view_editor.js" - /> - <script - type="text/javascript" - src="/bi_view_editor/static/src/js/bi_view_editor.JoinNodeDialog.js" - /> - <script - type="text/javascript" - src="/bi_view_editor/static/src/js/bi_view_editor.ModelList.js" - /> - <script - type="text/javascript" - src="/bi_view_editor/static/src/js/bi_view_editor.FieldList.js" - /> - </xpath> - </template> -</odoo> diff --git a/bi_view_editor/tests/test_bi_view.py b/bi_view_editor/tests/test_bi_view.py index 22559a74a..c037110b6 100644 --- a/bi_view_editor/tests/test_bi_view.py +++ b/bi_view_editor/tests/test_bi_view.py @@ -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, ) @@ -117,8 +119,10 @@ class TestBiViewEditor(TransactionCase): 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 = [ { @@ -223,8 +227,10 @@ class TestBiViewEditor(TransactionCase): # 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) @@ -367,12 +373,16 @@ class TestBiViewEditor(TransactionCase): @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 = [ { diff --git a/bi_view_editor/wizard/wizard_ir_model_menu_create.py b/bi_view_editor/wizard/wizard_ir_model_menu_create.py index 85196ea58..1812c78b9 100644 --- a/bi_view_editor/wizard/wizard_ir_model_menu_create.py +++ b/bi_view_editor/wizard/wizard_ir_model_menu_create.py @@ -19,9 +19,10 @@ class WizardModelMenuCreate(models.TransientModel): "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), + "name": bve_view.name + and str(bve_view.name).replace(" ", "") + ",id=" + str(menu.id), "noupdate": True, "module": "bi_view_editor", "model": "ir.ui.menu",