Skip to content
Snippets Groups Projects
Commit b459804f authored by Christophe de Vienne's avatar Christophe de Vienne
Browse files

export: Test and implement export of string fiels

parent f0223fde
No related branches found
No related tags found
No related merge requests found
......@@ -23,4 +23,25 @@
are not yet supported, unless the same mapping applies to all the types.
More complex cases should be handled with ``custom``.
"""
return {}
fields = record.fields_get()
output = {}
for key, options in mapping.items():
source, custom, mapping = options.get('source'), options.get(
'custom'), options.get('mapping')
if source is None and custom is None:
source = key
if source is not None:
field = fields[source]
value = getattr(record, source)
if value is False:
value = None
output[key] = value
return output
[tool.black]
line-length = 79
# flake8: noqa
from . import test_xbus_emitter
from . import test_export
import odoo
from ..export import export
from .util.odoo_tests import TestBase
@odoo.tests.common.at_install(False)
@odoo.tests.common.post_install(True)
class Test(TestBase):
def test_export_string_field(self):
record = self.env["res.partner"].create({"name": "my name"})
self.assertEqual(
{"name": "my name", "company": None},
export(
record, {"name": {}, "company": {"source": "company_name"}}
),
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment