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

export: implement one2many fields

parent e79a9a018b94
No related branches found
No related tags found
No related merge requests found
......@@ -53,6 +53,8 @@
if field and field["type"] == "many2one":
if len(value) != 0:
value.ensure_one()
elif field and field["type"] == "one2many":
islist = True
if islist:
value = [export(item, mapping) for item in value]
......
......@@ -71,3 +71,21 @@
{"parent": {"source": "parent_id", "mapping": {"name": {}}}},
),
)
def test_export_one2many_field(self):
m = {"children": {"source": "child_ids", "mapping": {"name": {}}}}
parent = self.env["res.partner"].create({"name": "my parent"})
self.assertEqual({"children": []}, export(parent, m))
self.env["res.partner"].create(
{"name": "Child1", "parent_id": parent.id}
)
self.assertEqual({"children": [{"name": "Child1"}]}, export(parent, m))
self.env["res.partner"].create(
{"name": "Child2", "parent_id": parent.id}
)
self.assertEqual(
{"children": [{"name": "Child1"}, {"name": "Child2"}]},
export(parent, m),
)
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