Browse Source

Fix tests and add fix nullable fields

pull/1379/head
hpar 7 years ago
committed by Pierrick Brun
parent
commit
d41e39f030
  1. 7
      base_jsonify/models/models.py
  2. 10
      base_jsonify/tests/test_get_parser.py

7
base_jsonify/models/models.py

@ -46,9 +46,10 @@ def jsonify(self, parser):
"""
result = []
empty_value = {
'char': '',
'int': 0,
'float': 0,
'char': None,
'int': None,
# 'float': None, TODO: 0.0 != False
'text': None,
}
for rec in self:

10
base_jsonify/tests/test_get_parser.py

@ -57,17 +57,18 @@ class TestParser(TransactionCase):
partner = self.env['res.partner'].create({
'name': 'Akretion',
'country_id': self.env.ref('base.fr').id,
'lang': 'en_US', # default
'category_id': [(0, 0, {'name': 'Inovator'})],
'child_ids': [
(0, 0, {
'name': 'Sebatien Beau',
'country_id': self.env.ref('base.fr').id
})
]
],
})
expected_json = [{
u'lang': False,
u'comment': False,
u'lang': u'en_US',
u'comment': None,
u'credit_limit': 0.0,
u'name': u'Akretion',
u'color': 0,
@ -87,8 +88,9 @@ class TestParser(TransactionCase):
},
u'children': [],
u'name': u'Sebatien Beau',
u'email': False
u'email': None
}]
}]
json_partner = partner.jsonify(parser)
self.assertDictEqual(json_partner[0], expected_json[0])
Loading…
Cancel
Save