|
1 | 1 | import operator
|
2 | 2 | import re
|
3 | 3 | import unittest
|
| 4 | +import uuid |
4 | 5 | from ast import literal_eval
|
5 | 6 |
|
6 | 7 | from lxml import etree
|
@@ -635,14 +636,43 @@ def test_update_record_from_xml_recursive_menuitem(self):
|
635 | 636 | record.write({key: value})
|
636 | 637 | self.assertEqual(record[key], value)
|
637 | 638 |
|
638 |
| - util.update_record_from_xml(self.env.cr, xmlid, ensure_references=True) |
| 639 | + util.update_record_from_xml(self.env.cr, xmlid) |
639 | 640 | if util.version_gte("16.0"):
|
640 | 641 | record.invalidate_recordset(["name"])
|
641 | 642 | else:
|
642 | 643 | record.invalidate_cache(["name"], record.ids)
|
643 | 644 | for key, value in data_before.items():
|
644 | 645 | self.assertEqual(record[key], value)
|
645 | 646 |
|
| 647 | + def test_upgrade_record_from_xml_ensure_references(self): |
| 648 | + def change(xmlid): |
| 649 | + cat = self.env.ref(xmlid) |
| 650 | + result = cat.name |
| 651 | + cat.write({"name": str(uuid.uuid4())}) |
| 652 | + util.flush(cat) |
| 653 | + util.invalidate(cat) |
| 654 | + return result |
| 655 | + |
| 656 | + if util.version_gte("saas~13.5"): |
| 657 | + xmlid_tree = [ |
| 658 | + "base.module_category_accounting_localizations_account_charts", |
| 659 | + "base.module_category_accounting_localizations", |
| 660 | + "base.module_category_accounting", |
| 661 | + ] |
| 662 | + else: |
| 663 | + xmlid_tree = [ |
| 664 | + "base.module_category_localization_account_charts", |
| 665 | + "base.module_category_localization", |
| 666 | + ] |
| 667 | + |
| 668 | + old_names = [change(xmlid) for xmlid in xmlid_tree] |
| 669 | + |
| 670 | + util.update_record_from_xml(self.env.cr, xmlid_tree[0], ensure_references=True) |
| 671 | + |
| 672 | + for xmlid, expected in zip(xmlid_tree, old_names): |
| 673 | + cat = self.env.ref(xmlid) |
| 674 | + self.assertEqual(cat.name, expected) |
| 675 | + |
646 | 676 | def test_update_record_from_xml_template_tag(self):
|
647 | 677 | # reset all fields on a <template>
|
648 | 678 | template_xmlid = "base.contact_name"
|
|
0 commit comments