mirror of
https://github.com/NaN-tic/trytond-patches.git
synced 2023-12-14 06:03:03 +01:00
Add patch for issue4095
This commit is contained in:
parent
42c50bb03c
commit
803f71b658
68
issue6451002_60001.diff
Normal file
68
issue6451002_60001.diff
Normal file
|
@ -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)
|
||||
|
Loading…
Reference in a new issue