add http://codereview.tryton.org/1371002/http://codereview.tryton.org/1371002/ adaptet to 3.0 to validate only modified and dependant fields on model write

This commit is contained in:
?ngel ?lvarez Serra 2014-02-27 12:49:36 +01:00
parent fc428f7a6c
commit 103e2354b6
2 changed files with 39 additions and 0 deletions

38
issue1371002_130001.diff Normal file
View File

@ -0,0 +1,38 @@
diff -r 08d7eb612ae4 trytond/model/modelsql.py
--- a/trytond/trytond/model/modelsql.py Sun Feb 09 23:53:10 2014 +0100
+++ b/trytond/trytond/model/modelsql.py Thu Feb 27 12:42:28 2014 +0100
@@ -712,7 +712,7 @@
field.set(ids, cls, fname, value)
cls.__insert_history(ids)
- cls._validate(records)
+ cls._validate(records, field_names=values.keys())
field_names = cls._fields.keys()
cls._update_mptt(field_names, [ids] * len(field_names), values)
diff -r 08d7eb612ae4 trytond/model/modelstorage.py
--- a/trytond/trytond/model/modelstorage.py Sun Feb 09 23:53:10 2014 +0100
+++ b/trytond/trytond/model/modelstorage.py Thu Feb 27 12:42:28 2014 +0100
@@ -880,7 +880,7 @@
pass
@classmethod
- def _validate(cls, records):
+ def _validate(cls, records, field_names=None):
pool = Pool()
# Ensure that records are readable
with Transaction().set_user(0, set_context=True):
@@ -927,8 +927,13 @@
return False
ctx_pref['active_test'] = False
+ field_names = set(field_names or [])
with Transaction().set_context(ctx_pref):
for field_name, field in cls._fields.iteritems():
+ if (field_names
+ and field_name not in field_names
+ and not (set(field.depends) & field_names)):
+ continue
if isinstance(field, fields.Function) and \
not field.setter:
continue

1
series
View File

@ -1,3 +1,4 @@
issue1371002_130001.diff
issue136_416.diff
issue971002_217001.diff
#issue2341002_1_10001.diff