-
-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] base_import_match: importing related o2m records
The original code did improperly handle importing related one2many records where at best all their attribute values would get overwritten by last of them. This was caused by mapping them only by their first part.
- Loading branch information
1 parent
4200890
commit dd19bd6
Showing
4 changed files
with
68 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
* Jairo Llopis | ||
* Vicent Cubells | ||
* Ernesto Tejeda | ||
* Radovan Skolnik <[email protected]> |
4 changes: 4 additions & 0 deletions
4
base_import_match/tests/import_data/res_partner_email_one2many.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
email,function,child_ids/name,child_ids/color,child_ids/email | ||
[email protected],Bug Fixer,Bart Steward,666,[email protected] | ||
,,Lisa Steward,777,[email protected] | ||
,,Maggie Steward,555,[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,3 +105,41 @@ def test_res_users_login(self): | |
record = self._base_import_record("res.users", "res_users_login") | ||
record.do(["login", "name"], [], OPTIONS) | ||
self.assertEqual(self.env.ref("base.user_demo").name, "Demo User Changed") | ||
|
||
def test_res_partner_email_one2many(self): | ||
"""Change function based on email and import one2many record.""" | ||
record = self._base_import_record("res.partner", "res_partner_email_one2many") | ||
record.do( | ||
[ | ||
"email", | ||
"function", | ||
"child_ids/name", | ||
"child_ids/color", | ||
"child_ids/email", | ||
], | ||
[], | ||
OPTIONS, | ||
) | ||
self.assertEqual( | ||
self.env.ref("base.res_partner_address_4").function, "Bug Fixer" | ||
) | ||
self.assertTrue(self.env.ref("base.res_partner_address_4").child_ids,) | ||
self.assertEqual( | ||
len(self.env.ref("base.res_partner_address_4").child_ids), 3, | ||
) | ||
self.assertEqual( | ||
set(self.env.ref("base.res_partner_address_4").mapped("child_ids.name")), | ||
{"Bart Steward", "Lisa Steward", "Maggie Steward"}, | ||
) | ||
self.assertEqual( | ||
set(self.env.ref("base.res_partner_address_4").mapped("child_ids.email")), | ||
{ | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
}, | ||
) | ||
self.assertEqual( | ||
set(self.env.ref("base.res_partner_address_4").mapped("child_ids.color")), | ||
{666, 777, 555}, | ||
) |