[MIG] bi_view_editor: Migration to 15.0

pull/730/head
ilo 2023-03-08 11:22:45 -03:00
parent 1eb14ec1f0
commit 6ea92d74e3
8 changed files with 53 additions and 57 deletions

View File

@ -18,10 +18,20 @@
"data": [ "data": [
"security/ir.model.access.csv", "security/ir.model.access.csv",
"security/rules.xml", "security/rules.xml",
"templates/assets_template.xml",
"views/bve_view.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", "uninstall_hook": "uninstall_hook",
"installable": True, "installable": True,
} }

View File

@ -393,7 +393,7 @@ class BveView(models.Model):
if self.state != "created": if self.state != "created":
return return
self = self.sudo() 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 = self.env["ir.translation"]
IrTranslation.translate_fields("ir.model", model.id) IrTranslation.translate_fields("ir.model", model.id)
for field in model.field_id: for field in model.field_id:

View File

@ -69,7 +69,9 @@ class IrModel(models.Model):
count_check += _check_contains(model_model) count_check += _check_contains(model_model)
count_check += _check_unknown(model_name) count_check += _check_unknown(model_name)
if not count_check: 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 return False
def get_model_list(self, model_table_map): def get_model_list(self, model_table_map):

View File

@ -6,3 +6,4 @@
* Andrea Stirpe <a.stirpe@onestein.nl> * Andrea Stirpe <a.stirpe@onestein.nl>
* Antonio Esposito <a.esposito@onestein.nl> * Antonio Esposito <a.esposito@onestein.nl>
* Jordi Ballester Alomar <jordi.ballester@eficent.com> * Jordi Ballester Alomar <jordi.ballester@eficent.com>
* Italo LOPES <italo.lopes@camptocamp.com>

View File

@ -42,11 +42,11 @@
> >
Use the field Use the field
<b> <b>
<t t-esc="choice.model_name" /> <t t-out="choice.model_name" />
</b> </b>
<i class="fa fa-caret-right" /> <i class="fa fa-caret-right" />
<b> <b>
<t t-esc="choice.description" /> <t t-out="choice.description" />
</b> </b>
<span class="badge">new</span> <span class="badge">new</span>
</li> </li>
@ -58,11 +58,11 @@
> >
Use the field Use the field
<b> <b>
<t t-esc="choice.model_name" /> <t t-out="choice.model_name" />
</b> </b>
<i class="fa fa-caret-right" /> <i class="fa fa-caret-right" />
<b> <b>
<t t-esc="choice.description" /> <t t-out="choice.description" />
</b> </b>
</li> </li>
</t> </t>
@ -86,14 +86,14 @@
<t t-name="bi_view_editor.ModelListItem"> <t t-name="bi_view_editor.ModelListItem">
<div class="class-container"> <div class="class-container">
<div class="class" t-attf-title="#{model}" t-attf-data-id="#{id}"> <div class="class" t-attf-title="#{model}" t-attf-data-id="#{id}">
<t t-esc="name" /> <t t-out="name" />
</div> </div>
</div> </div>
</t> </t>
<!-- ModelListFieldItem--> <!-- ModelListFieldItem-->
<t t-name="bi_view_editor.ModelListFieldItem"> <t t-name="bi_view_editor.ModelListFieldItem">
<div class="field" t-attf-title="#{name}" t-attf-data-id="#{name}"> <div class="field" t-attf-title="#{name}" t-attf-data-id="#{name}">
<t t-esc="description" /> <t t-out="description" />
</div> </div>
</t> </t>
<!-- FieldList --> <!-- FieldList -->
@ -190,7 +190,7 @@
/> />
</td> </td>
<td> <td>
<t t-esc="field.model_name" /> <t t-out="field.model_name" />
</td> </td>
<td> <td>
<span <span
@ -233,20 +233,20 @@
/> />
<t t-if="field.join_node > field.table_alias"> <t t-if="field.join_node > field.table_alias">
<b> <b>
<t t-esc="field.model_name" /> <t t-out="field.model_name" />
</b> </b>
<i class="fa fa-caret-right" /> <i class="fa fa-caret-right" />
<small> <small>
<t t-esc="field.description" /> <t t-out="field.description" />
</small> </small>
</t> </t>
<t t-else=""> <t t-else="">
<small> <small>
<t t-esc="field.description" /> <t t-out="field.description" />
</small> </small>
<i class="fa fa-caret-left" /> <i class="fa fa-caret-left" />
<b> <b>
<t t-esc="field.model_name" /> <t t-out="field.model_name" />
</b> </b>
</t> </t>
<span <span

View File

@ -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>

View File

@ -15,13 +15,15 @@ class TestBiViewEditor(TransactionCase):
def setUp(self): def setUp(self):
def _get_models(model_name_list): def _get_models(model_name_list):
return ( return (
self.env["ir.model"].search([("model", "=", name)]) self.env["ir.model"].sudo().search([("model", "=", name)])
for name in model_name_list for name in model_name_list
) )
def _get_fields(model_field_list): def _get_fields(model_field_list):
return ( return (
self.env["ir.model.fields"].search( self.env["ir.model.fields"]
.sudo()
.search(
[("model", "=", model_field[0]), ("name", "=", model_field[1])], [("model", "=", model_field[0]), ("name", "=", model_field[1])],
limit=1, limit=1,
) )
@ -117,8 +119,10 @@ class TestBiViewEditor(TransactionCase):
self.assertGreater(len(fields), 0) self.assertGreater(len(fields), 0)
def test_02_get_join_nodes(self): def test_02_get_join_nodes(self):
field_res_users = self.env["ir.model.fields"].search( field_res_users = (
[("name", "=", "login"), ("model", "=", "res.users")], limit=1 self.env["ir.model.fields"]
.sudo()
.search([("name", "=", "login"), ("model", "=", "res.users")], limit=1)
) )
field_data = [ field_data = [
{ {
@ -223,8 +227,10 @@ class TestBiViewEditor(TransactionCase):
# create bve object # create bve object
bi_view.action_create() bi_view.action_create()
model = self.env["ir.model"].search( model = (
[("model", "=", "x_bve.testview4"), ("name", "=", "Test View4")] self.env["ir.model"]
.sudo()
.search([("model", "=", "x_bve.testview4"), ("name", "=", "Test View4")])
) )
self.assertEqual(len(model), 1) self.assertEqual(len(model), 1)
@ -367,12 +373,16 @@ class TestBiViewEditor(TransactionCase):
@odoo.tests.tagged("post_install", "-at_install") @odoo.tests.tagged("post_install", "-at_install")
def test_19_field_selection(self): def test_19_field_selection(self):
field = self.env["ir.model.fields"].search( field = (
[ self.env["ir.model.fields"]
("model", "=", self.company_model_name), .sudo()
("name", "=", "base_onboarding_company_state"), .search(
], [
limit=1, ("model", "=", self.company_model_name),
("name", "=", "base_onboarding_company_state"),
],
limit=1,
)
) )
selection_data = [ selection_data = [
{ {

View File

@ -19,9 +19,10 @@ class WizardModelMenuCreate(models.TransientModel):
"action": "ir.actions.act_window,%d" % (bve_view.action_id,), "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, "noupdate": True,
"module": "bi_view_editor", "module": "bi_view_editor",
"model": "ir.ui.menu", "model": "ir.ui.menu",