[FIX] bi_view_editor: Apostrophe + migration script

Apostrophe in model name raised ValueError. Added needed migration script.
This commit is contained in:
SimoRubi
2018-08-14 08:52:43 +02:00
committed by Andrea
parent f6e4bfa01b
commit c26370b31d
4 changed files with 84 additions and 14 deletions

View File

@@ -1,6 +1,8 @@
# Copyright 2017-2018 Onestein (<http://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import json
from odoo.tests.common import TransactionCase, at_install, post_install
from odoo.exceptions import UserError
@@ -99,7 +101,7 @@ class TestBiViewEditor(TransactionCase):
'measure': 0
}
]
format_data = self.env['bve.view']._get_format_data(str(data))
format_data = json.dumps(data)
self.bi_view1_vals = {
'state': 'draft',
@@ -227,3 +229,23 @@ class TestBiViewEditor(TransactionCase):
# try to remove view
with self.assertRaises(UserError):
bi_view.unlink()
@at_install(False)
@post_install(True)
def test_10_create_open_bve_object_apostrophe(self):
vals = self.bi_view1_vals
employees_group = self.env.ref('base.group_user')
vals.update({
'name': "Test View5",
'group_ids': [(6, 0, [employees_group.id])],
})
l = list()
for r in json.loads(vals['data']):
r['model_name'] = "model'name"
l.append(r)
new_format_data = json.dumps(l)
vals.update({'data': new_format_data})
bi_view = self.env['bve.view'].create(vals)
self.assertEqual(len(bi_view), 1)
# create bve object
bi_view.action_create()