# HG changeset patch
# User Christophe de Vienne <christophe.devienne@orus.io>
# Date 1547677490 -3600
#      Wed Jan 16 23:24:50 2019 +0100
# Branch 11.0
# Node ID 0cc91a1b4778906c3bb80a438b34a4f696dff98f
# Parent  e79a9a018b94737c2356af6c904c6a108206c3e1
export: implement one2many fields

diff --git a/export.py b/export.py
--- a/export.py
+++ b/export.py
@@ -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]
diff --git a/tests/test_export.py b/tests/test_export.py
--- a/tests/test_export.py
+++ b/tests/test_export.py
@@ -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),
+        )