From ebe8af2e9b162c6184d4621c4fe343a0e81fe78e Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 17 Sep 2014 17:59:25 +0200 Subject: [PATCH] [ADD] base_field_serialized --- base_field_serialized/__init__.py | 22 ++++++++ base_field_serialized/__openerp__.py | 36 ++++++++++++ .../base_field_serialized.py | 33 +++++++++++ base_field_serialized/fields.py | 53 ++++++++++++++++++ .../static/description/icon.png | Bin 0 -> 15973 bytes base_field_serialized/tests/__init__.py | 22 ++++++++ .../tests/test_serialized.py | 47 ++++++++++++++++ 7 files changed, 213 insertions(+) create mode 100644 base_field_serialized/__init__.py create mode 100644 base_field_serialized/__openerp__.py create mode 100644 base_field_serialized/base_field_serialized.py create mode 100644 base_field_serialized/fields.py create mode 100644 base_field_serialized/static/description/icon.png create mode 100644 base_field_serialized/tests/__init__.py create mode 100644 base_field_serialized/tests/test_serialized.py diff --git a/base_field_serialized/__init__.py b/base_field_serialized/__init__.py new file mode 100644 index 000000000..3a4c4411e --- /dev/null +++ b/base_field_serialized/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2014 Therp BV (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +import fields +import base_field_serialized diff --git a/base_field_serialized/__openerp__.py b/base_field_serialized/__openerp__.py new file mode 100644 index 000000000..13e6f48f4 --- /dev/null +++ b/base_field_serialized/__openerp__.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2014 Therp BV (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +{ + "name": "Serialized fields", + "version": "1.0", + "author": "Therp BV", + "license": "AGPL-3", + "complexity": "normal", + "description": """This addon restores serialized fields for Odoo 8.0 + """, + "category": "Hidden/Dependency", + "depends": [ + 'base', + ], + "auto_install": False, + "installable": True, + "application": False, +} diff --git a/base_field_serialized/base_field_serialized.py b/base_field_serialized/base_field_serialized.py new file mode 100644 index 000000000..10190e965 --- /dev/null +++ b/base_field_serialized/base_field_serialized.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2014 Therp BV (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from openerp import fields + + +class Serialized(fields.Field): + type = 'serialized' + + def convert_to_cache(self, value, env, validate=True): + if value: + return value + else: + return {} + +fields.Serialized = Serialized diff --git a/base_field_serialized/fields.py b/base_field_serialized/fields.py new file mode 100644 index 000000000..bac5aa21c --- /dev/null +++ b/base_field_serialized/fields.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import simplejson +import openerp +from openerp.models import FIELDS_TO_PGTYPES +from openerp.osv.fields import _column + +# --------------------------------------------------------- +# Serialized fields +# --------------------------------------------------------- + + +class serialized(_column): + """ A field able to store an arbitrary python data structure. + + Note: only plain components allowed. + """ + + def _symbol_set_struct(val): + return simplejson.dumps(val) + + def _symbol_get_struct(self, val): + return simplejson.loads(val or '{}') + + _prefetch = False + _type = 'serialized' + + _symbol_c = '%s' + _symbol_f = _symbol_set_struct + _symbol_set = (_symbol_c, _symbol_f) + _symbol_get = _symbol_get_struct + +openerp.osv.fields.serialized = serialized +FIELDS_TO_PGTYPES[openerp.osv.fields.serialized] = 'text' diff --git a/base_field_serialized/static/description/icon.png b/base_field_serialized/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..62e4d4be49087978bef50e4032b4de236cd478f6 GIT binary patch literal 15973 zcmV-rKAORaP)1MP(32uz(#@#DWk}5JUkfA}yhYA|!->5khDI(hbQAF(HL?QcWY( zmtvZ!ru@?;?VpfI!cYbr&Y!<^#i<1=T}=4Z|%ZKwA) zsjUMbI!*LHo`rORDeEqfm{Ma+64~@$=9B6c;XBqQLEx)b1X?@caAq^fu_%);5aD%GMhaprz%q zC@HC+IN&dk{=XDVs#IUEC%5s_Pd|&Fe*RfhfLy0e1)ciz({(!CB)G-FTS9{RR7=Zw z2L7M_{1+PipQ5epXGHK9MLhFJg{x{#m+oz^}pIlN>DXOdMMN`uyHud;@ z2SHo_t8!Ho7M77^`Oe=r{3|l?J9q9J%IB5$V+HWb%Bsa>0N>DXUbLROELvMH;+Hfq$UX_=WN(BM`gKnH>UW9w>P1bi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NkvXXu0mjfzP%>( literal 0 HcmV?d00001 diff --git a/base_field_serialized/tests/__init__.py b/base_field_serialized/tests/__init__.py new file mode 100644 index 000000000..dde5974db --- /dev/null +++ b/base_field_serialized/tests/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2014 Therp BV (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +import test_serialized +from test_serialized import TestBaseFieldSerialized diff --git a/base_field_serialized/tests/test_serialized.py b/base_field_serialized/tests/test_serialized.py new file mode 100644 index 000000000..f2956ea96 --- /dev/null +++ b/base_field_serialized/tests/test_serialized.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# This module copyright (C) 2014 Therp BV (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from openerp import models, fields +from openerp.tests.common import TransactionCase + + +class BaseFieldSerializedTestModel(models.Model): + _name = 'base.field.serialized.test.model' + + serialized = fields.Serialized('Serialized') + + +class TestBaseFieldSerialized(TransactionCase): + def test_ReadWrite(self): + BaseFieldSerializedTestModel._build_model(self.registry, self.cr) + self.env['base.field.serialized.test.model']._auto_init() + record = self.env['base.field.serialized.test.model'].create( + {'serialized': ['hello world']}) + self.assertEqual(record.serialized, ['hello world']) + self.env.invalidate_all() + self.assertEqual(record.serialized, ['hello world']) + record.write({'serialized': {'hello': 'world'}}) + self.env.invalidate_all() + self.assertEqual(record.serialized, {'hello': 'world'}) + record.write({'serialized': None}) + self.assertEqual( + self.registry['base.field.serialized.test.model'].browse( + self.cr, self.uid, record.id).serialized, + {})