jsonifier: migration to v16
parent
fc4bcb3774
commit
4605af5ba8
|
@ -1,7 +1,7 @@
|
||||||
id,export_id/id,name
|
id,export_id/id,name
|
||||||
name,ir_exp_partner,name
|
name,ir_exp_partner,name
|
||||||
active,ir_exp_partner,active
|
active,ir_exp_partner,active
|
||||||
credit_limit,ir_exp_partner,credit_limit
|
partner_latitude,ir_exp_partner,partner_latitude
|
||||||
color,ir_exp_partner,color
|
color,ir_exp_partner,color
|
||||||
category_id_name,ir_exp_partner,category_id/name
|
category_id_name,ir_exp_partner,category_id/name
|
||||||
country_id_name,ir_exp_partner,country_id/name
|
country_id_name,ir_exp_partner,country_id/name
|
||||||
|
|
|
|
@ -1,11 +1,11 @@
|
||||||
# Copyright 2017 ACSONE SA/NV
|
# Copyright 2017 ACSONE SA/NV
|
||||||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
|
# 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 import fields, tools
|
||||||
from odoo.exceptions import UserError
|
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
|
from ..models.utils import convert_simple_to_full_parser
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ def jsonify_custom(self, field_name):
|
||||||
return "yeah!"
|
return "yeah!"
|
||||||
|
|
||||||
|
|
||||||
class TestParser(SavepointCase):
|
class TestParser(TransactionCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super().setUpClass()
|
super().setUpClass()
|
||||||
|
@ -43,20 +43,9 @@ class TestParser(SavepointCase):
|
||||||
Langs = cls.env["res.lang"].with_context(active_test=False)
|
Langs = cls.env["res.lang"].with_context(active_test=False)
|
||||||
cls.lang = Langs.search([("code", "=", "fr_FR")])
|
cls.lang = Langs.search([("code", "=", "fr_FR")])
|
||||||
cls.lang.active = True
|
cls.lang.active = True
|
||||||
cls.env["ir.translation"]._load_module_terms(["base"], [cls.lang.code])
|
|
||||||
category = cls.env["res.partner.category"].create({"name": "name"})
|
category = cls.env["res.partner.category"].create({"name": "name"})
|
||||||
cls.translated_target = "name_{}".format(cls.lang.code)
|
cls.translated_target = "name_{}".format(cls.lang.code)
|
||||||
cls.env["ir.translation"].create(
|
category.with_context(lang=cls.lang.code).write({"name": cls.translated_target})
|
||||||
{
|
|
||||||
"type": "model",
|
|
||||||
"name": "res.partner.category,name",
|
|
||||||
"module": "base",
|
|
||||||
"lang": cls.lang.code,
|
|
||||||
"res_id": category.id,
|
|
||||||
"value": cls.translated_target,
|
|
||||||
"state": "translated",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
cls.global_resolver = cls.env["ir.exports.resolver"].create(
|
cls.global_resolver = cls.env["ir.exports.resolver"].create(
|
||||||
{"python_code": "value['X'] = 'X'; result = value", "type": "global"}
|
{"python_code": "value['X'] = 'X'; result = value", "type": "global"}
|
||||||
)
|
)
|
||||||
|
@ -97,7 +86,7 @@ class TestParser(SavepointCase):
|
||||||
expected_parser = [
|
expected_parser = [
|
||||||
"name",
|
"name",
|
||||||
"active",
|
"active",
|
||||||
"credit_limit",
|
"partner_latitude",
|
||||||
"color",
|
"color",
|
||||||
("category_id", ["name"]),
|
("category_id", ["name"]),
|
||||||
("country_id", ["name", "code"]),
|
("country_id", ["name", "code"]),
|
||||||
|
@ -134,7 +123,7 @@ class TestParser(SavepointCase):
|
||||||
parser = [
|
parser = [
|
||||||
"lang",
|
"lang",
|
||||||
"comment",
|
"comment",
|
||||||
"credit_limit",
|
"partner_latitude",
|
||||||
"name",
|
"name",
|
||||||
"color",
|
"color",
|
||||||
(
|
(
|
||||||
|
@ -161,7 +150,7 @@ class TestParser(SavepointCase):
|
||||||
expected_json = {
|
expected_json = {
|
||||||
"lang": "en_US",
|
"lang": "en_US",
|
||||||
"comment": None,
|
"comment": None,
|
||||||
"credit_limit": 0.0,
|
"partner_latitude": 0.0,
|
||||||
"name": "Akretion",
|
"name": "Akretion",
|
||||||
"color": 0,
|
"color": 0,
|
||||||
"country": {"code": "FR", "name": "France"},
|
"country": {"code": "FR", "name": "France"},
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
# @author Iván Todorovich <ivan.todorovich@camptocamp.com>
|
# @author Iván Todorovich <ivan.todorovich@camptocamp.com>
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
# 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
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super().setUpClass()
|
super().setUpClass()
|
||||||
|
@ -36,10 +36,10 @@ class TestJsonifyHelpers(SavepointCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_helper_format_duration(self):
|
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
|
# any float field does the trick here
|
||||||
self.partner.credit_limit = 15.5
|
self.partner.partner_latitude = 15.5
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.partner._jsonify_format_duration("credit_limit"),
|
self.partner._jsonify_format_duration("partner_latitude"),
|
||||||
"15:30",
|
"15:30",
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
|
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
|
||||||
|
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
from odoo.tests.common import SavepointCase
|
from odoo.tests.common import TransactionCase
|
||||||
|
|
||||||
|
|
||||||
class TestIrExportsLine(SavepointCase):
|
class TestIrExportsLine(TransactionCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super().setUpClass()
|
super().setUpClass()
|
||||||
|
|
Loading…
Reference in New Issue