[12.0][MIG] base_jsonify: py3
parent
b8516d714a
commit
172243a7fe
|
@ -1,2 +1 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
from . import models
|
from . import models
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright 2017-2018 Akretion (http://www.akretion.com)
|
# Copyright 2017-2018 Akretion (http://www.akretion.com)
|
||||||
# Sébastien BEAU <sebastien.beau@akretion.com>
|
# Sébastien BEAU <sebastien.beau@akretion.com>
|
||||||
# Raphaël Reverdy <raphael.reverdy@akretion.com>
|
# Raphaël Reverdy <raphael.reverdy@akretion.com>
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
from . import models
|
from . import models
|
||||||
from . import ir_export
|
from . import ir_export
|
||||||
from . import ir_exports_line
|
from . import ir_exports_line
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# © 2017 Akretion (http://www.akretion.com)
|
# © 2017 Akretion (http://www.akretion.com)
|
||||||
# Sébastien BEAU <sebastien.beau@akretion.com>
|
# Sébastien BEAU <sebastien.beau@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||||
|
@ -34,7 +33,7 @@ def convert_dict(dict_parser):
|
||||||
tuples.
|
tuples.
|
||||||
"""
|
"""
|
||||||
parser = []
|
parser = []
|
||||||
for field, value in dict_parser.iteritems():
|
for field, value in dict_parser.items():
|
||||||
if value is True:
|
if value is True:
|
||||||
parser.append(field)
|
parser.append(field)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright 2017 ACSONE SA/NV
|
# Copyright 2017 ACSONE SA/NV
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# © 2017 Akretion (http://www.akretion.com)
|
# © 2017 Akretion (http://www.akretion.com)
|
||||||
# Sébastien BEAU <sebastien.beau@akretion.com>
|
# Sébastien BEAU <sebastien.beau@akretion.com>
|
||||||
# Raphaël Reverdy <raphael.reverdy@akretion.com>
|
# Raphaël Reverdy <raphael.reverdy@akretion.com>
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
from . import test_get_parser
|
from . import test_get_parser
|
||||||
from . import test_ir_exports_line
|
from . import test_ir_exports_line
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# © <YEAR(S)> <AUTHOR(S)>
|
# © <YEAR(S)> <AUTHOR(S)>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
@ -9,20 +8,20 @@ class TestParser(TransactionCase):
|
||||||
|
|
||||||
def test_getting_parser(self):
|
def test_getting_parser(self):
|
||||||
expected_parser = [
|
expected_parser = [
|
||||||
u'active',
|
'active',
|
||||||
(u'category_id', [u'name']),
|
('category_id', ['name']),
|
||||||
(u'child_ids', [(
|
('child_ids', [(
|
||||||
u'child_ids', [u'name']),
|
'child_ids', ['name']),
|
||||||
(u'country_id', [u'code', u'name']),
|
('country_id', ['code', 'name']),
|
||||||
u'email', u'id',
|
'email', 'id',
|
||||||
u'name'
|
'name'
|
||||||
]),
|
]),
|
||||||
u'color',
|
'color',
|
||||||
u'comment',
|
'comment',
|
||||||
(u'country_id', [u'code', u'name']),
|
('country_id', ['code', 'name']),
|
||||||
u'credit_limit',
|
'credit_limit',
|
||||||
u'lang',
|
'lang',
|
||||||
u'name']
|
'name']
|
||||||
|
|
||||||
exporter = self.env.ref('base_jsonify.ir_exp_partner')
|
exporter = self.env.ref('base_jsonify.ir_exp_partner')
|
||||||
parser = exporter.get_json_parser()
|
parser = exporter.get_json_parser()
|
||||||
|
@ -32,27 +31,27 @@ class TestParser(TransactionCase):
|
||||||
self.env.ref('base_jsonify.category_id_name').write({
|
self.env.ref('base_jsonify.category_id_name').write({
|
||||||
'alias': 'category_id:category/name'
|
'alias': 'category_id:category/name'
|
||||||
})
|
})
|
||||||
expected_parser[1] = (u'category_id:category', [u'name'])
|
expected_parser[1] = ('category_id:category', ['name'])
|
||||||
parser = exporter.get_json_parser()
|
parser = exporter.get_json_parser()
|
||||||
self.assertEqual(parser, expected_parser)
|
self.assertEqual(parser, expected_parser)
|
||||||
|
|
||||||
def test_json_export(self):
|
def test_json_export(self):
|
||||||
parser = [
|
parser = [
|
||||||
u'lang',
|
'lang',
|
||||||
u'comment',
|
'comment',
|
||||||
u'credit_limit',
|
'credit_limit',
|
||||||
u'name',
|
'name',
|
||||||
u'color',
|
'color',
|
||||||
(u'child_ids:children', [
|
('child_ids:children', [
|
||||||
(u'child_ids:children', [u'name']),
|
('child_ids:children', ['name']),
|
||||||
u'email',
|
'email',
|
||||||
(u'country_id:country', [u'code', u'name']),
|
('country_id:country', ['code', 'name']),
|
||||||
u'name',
|
'name',
|
||||||
u'id',
|
'id',
|
||||||
]),
|
]),
|
||||||
(u'country_id:country', [u'code', u'name']),
|
('country_id:country', ['code', 'name']),
|
||||||
u'active',
|
'active',
|
||||||
(u'category_id', [u'name'])
|
('category_id', ['name'])
|
||||||
]
|
]
|
||||||
partner = self.env['res.partner'].create({
|
partner = self.env['res.partner'].create({
|
||||||
'name': 'Akretion',
|
'name': 'Akretion',
|
||||||
|
@ -67,28 +66,28 @@ class TestParser(TransactionCase):
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
expected_json = {
|
expected_json = {
|
||||||
u'lang': u'en_US',
|
'lang': 'en_US',
|
||||||
u'comment': None,
|
'comment': None,
|
||||||
u'credit_limit': 0.0,
|
'credit_limit': 0.0,
|
||||||
u'name': u'Akretion',
|
'name': 'Akretion',
|
||||||
u'color': 0,
|
'color': 0,
|
||||||
u'country': {
|
'country': {
|
||||||
u'code': u'FR',
|
'code': 'FR',
|
||||||
u'name': u'France'
|
'name': 'France'
|
||||||
},
|
},
|
||||||
u'active': True,
|
'active': True,
|
||||||
u'category_id': [
|
'category_id': [
|
||||||
{u'name': u'Inovator'}
|
{'name': 'Inovator'}
|
||||||
],
|
],
|
||||||
u'children': [{
|
'children': [{
|
||||||
u'id': partner.child_ids.id,
|
'id': partner.child_ids.id,
|
||||||
u'country': {
|
'country': {
|
||||||
u'code': u'FR',
|
'code': 'FR',
|
||||||
u'name': u'France'
|
'name': 'France'
|
||||||
},
|
},
|
||||||
u'children': [],
|
'children': [],
|
||||||
u'name': u'Sebatien Beau',
|
'name': 'Sebatien Beau',
|
||||||
u'email': None
|
'email': None
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
json_partner = partner.jsonify(parser)
|
json_partner = partner.jsonify(parser)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# © 2017 ACSONE SA/NV
|
# © 2017 ACSONE SA/NV
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue