diff --git a/issue6451002_60001.diff b/issue6451002_60001.diff new file mode 100644 index 0000000..899d519 --- /dev/null +++ b/issue6451002_60001.diff @@ -0,0 +1,68 @@ +Index: trytond/setup.py +=================================================================== + +--- a/trytond/setup.py ++++ b/trytond/setup.py +@@ -91,4 +91,5 @@ + zip_safe=False, + test_suite='trytond.tests', + test_loader='trytond.test_loader:Loader', ++ tests_require=['mock'], + ) + +Index: trytond/trytond/model/modelsql.py +=================================================================== + +--- a/trytond/trytond/model/modelsql.py ++++ b/trytond/trytond/model/modelsql.py +@@ -811,9 +811,9 @@ + if hasattr(field, 'set'): + fields_to_set.setdefault(fname, []).extend((ids, value)) + +- field_names = cls._fields.keys() ++ field_names = values.keys() + cls._update_mptt(field_names, [ids] * len(field_names), values) +- all_field_names |= set(values.keys()) ++ all_field_names |= set(field_names) + + for fname, fargs in fields_to_set.iteritems(): + field = cls._fields[fname] + +Index: trytond/trytond/tests/test_mptt.py +=================================================================== + +--- a/trytond/trytond/tests/test_mptt.py ++++ b/trytond/trytond/tests/test_mptt.py +@@ -3,6 +3,7 @@ + #this repository contains the full copyright notices and license terms. + import sys + import unittest ++from mock import patch + from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT, \ + install_module + from trytond.transaction import Transaction +@@ -163,6 +164,23 @@ + + transaction.cursor.rollback() + ++ def test0060_update_only_if_parent_is_modified(self): ++ 'The left and right fields must only be updated if parent is modified' ++ with Transaction().start(DB_NAME, USER, context=CONTEXT): ++ records = self.mptt.search([ ++ ('parent', '=', None), ++ ]) ++ with patch.object(self.mptt, '_update_tree') as mock: ++ self.mptt.write(records, {'name': 'Parent Records'}) ++ self.assertFalse(mock.called) ++ ++ first_parent, second_parent = records[:2] ++ self.mptt.write(list(first_parent.childs), { ++ 'parent': second_parent.id, ++ }) ++ ++ self.assertTrue(mock.called) ++ + + def suite(): + return unittest.TestLoader().loadTestsFromTestCase(MPTTTestCase) + diff --git a/series b/series index 3997df7..d72b63d 100644 --- a/series +++ b/series @@ -28,3 +28,4 @@ issue9511002_1.diff issue8481003_1.diff issue7461002_1.diff issue6441002_20001.diff +issue6451002_60001.diff