jsonifier: migration to v16

pull/2418/head
Sébastien BEAU 2022-10-08 13:47:51 +02:00
parent a9449b2be9
commit db4d191c35
4 changed files with 15 additions and 26 deletions

View File

@ -1,7 +1,7 @@
id,export_id/id,name
name,ir_exp_partner,name
active,ir_exp_partner,active
credit_limit,ir_exp_partner,credit_limit
partner_latitude,ir_exp_partner,partner_latitude
color,ir_exp_partner,color
category_id_name,ir_exp_partner,category_id/name
country_id_name,ir_exp_partner,country_id/name

1 id export_id/id name
2 name ir_exp_partner name
3 active ir_exp_partner active
4 credit_limit partner_latitude ir_exp_partner credit_limit partner_latitude
5 color ir_exp_partner color
6 category_id_name ir_exp_partner category_id/name
7 country_id_name ir_exp_partner country_id/name

View File

@ -1,11 +1,11 @@
# Copyright 2017 ACSONE SA/NV
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
import mock
from unittest import mock
from odoo import fields, tools
from odoo.exceptions import UserError
from odoo.tests.common import SavepointCase
from odoo.tests.common import TransactionCase
from ..models.utils import convert_simple_to_full_parser
@ -14,7 +14,7 @@ def jsonify_custom(self, field_name):
return "yeah!"
class TestParser(SavepointCase):
class TestParser(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
@ -43,20 +43,9 @@ class TestParser(SavepointCase):
Langs = cls.env["res.lang"].with_context(active_test=False)
cls.lang = Langs.search([("code", "=", "fr_FR")])
cls.lang.active = True
cls.env["ir.translation"]._load_module_terms(["base"], [cls.lang.code])
category = cls.env["res.partner.category"].create({"name": "name"})
cls.translated_target = "name_{}".format(cls.lang.code)
cls.env["ir.translation"].create(
{
"type": "model",
"name": "res.partner.category,name",
"module": "base",
"lang": cls.lang.code,
"res_id": category.id,
"value": cls.translated_target,
"state": "translated",
}
)
category.with_context(lang=cls.lang.code).write({"name": cls.translated_target})
cls.global_resolver = cls.env["ir.exports.resolver"].create(
{"python_code": "value['X'] = 'X'; result = value", "type": "global"}
)
@ -97,7 +86,7 @@ class TestParser(SavepointCase):
expected_parser = [
"name",
"active",
"credit_limit",
"partner_latitude",
"color",
("category_id", ["name"]),
("country_id", ["name", "code"]),
@ -134,7 +123,7 @@ class TestParser(SavepointCase):
parser = [
"lang",
"comment",
"credit_limit",
"partner_latitude",
"name",
"color",
(
@ -161,7 +150,7 @@ class TestParser(SavepointCase):
expected_json = {
"lang": "en_US",
"comment": None,
"credit_limit": 0.0,
"partner_latitude": 0.0,
"name": "Akretion",
"color": 0,
"country": {"code": "FR", "name": "France"},

View File

@ -2,10 +2,10 @@
# @author Iván Todorovich <ivan.todorovich@camptocamp.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo.tests.common import SavepointCase
from odoo.tests.common import TransactionCase
class TestJsonifyHelpers(SavepointCase):
class TestJsonifyHelpers(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
@ -36,10 +36,10 @@ class TestJsonifyHelpers(SavepointCase):
)
def test_helper_format_duration(self):
# credit_limit is not intended for this, but it's a float field in core
# partner_latitude is not intended for this, but it's a float field in core
# any float field does the trick here
self.partner.credit_limit = 15.5
self.partner.partner_latitude = 15.5
self.assertEqual(
self.partner._jsonify_format_duration("credit_limit"),
self.partner._jsonify_format_duration("partner_latitude"),
"15:30",
)

View File

@ -2,10 +2,10 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
from odoo.exceptions import ValidationError
from odoo.tests.common import SavepointCase
from odoo.tests.common import TransactionCase
class TestIrExportsLine(SavepointCase):
class TestIrExportsLine(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()