-
-
Notifications
You must be signed in to change notification settings - Fork 274
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 188a44e
Showing
6 changed files
with
75 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ Base Import Match | |
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:40f62ca1ed4ddafbe04e1dba6fafb257e2262df0dc6dc19eda7aa8c466d9c1b0 | ||
!! source digest: sha256:a814a82527acac6bf3fec5490bf37a35060a58c552bed21fec066ed77b7bed01 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
|
@@ -140,6 +140,7 @@ Contributors | |
* Jairo Llopis | ||
* Vicent Cubells | ||
* Ernesto Tejeda | ||
* Radovan Skolnik <[email protected]> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
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]> |
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
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,44 @@ 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}, | ||
) |