Browse Source

Fix monkey patchin

pull/1379/head
hpar 7 years ago
committed by Pierrick Brun
parent
commit
bbff9dc620
  1. 14
      base_jsonify/models/models.py

14
base_jsonify/models/models.py

@ -5,11 +5,16 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, models
from odoo.exceptions import Warning as UserError
from odoo.exceptions import UserError
from odoo.tools.translate import _
def __parse_field(parser_field):
class Base(models.AbstractModel):
_inherit = 'base'
@api.model
def __parse_field(self, parser_field):
field_name = parser_field
subparser = None
if isinstance(parser_field, tuple):
@ -55,7 +60,7 @@ def jsonify(self, parser):
for rec in self:
res = {}
for field in parser:
field_name, json_key, subparser = __parse_field(field)
field_name, json_key, subparser = self.__parse_field(field)
field_type = rec._fields[field_name].type
if subparser:
if field_type in ('one2many', 'many2many'):
@ -73,6 +78,3 @@ def jsonify(self, parser):
res[json_key] = empty_value[field_type]
result.append(res)
return result
models.Model.jsonify = jsonify
Loading…
Cancel
Save