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:
parent
fc428f7a6c
commit
103e2354b6
|
@ -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
|
Loading…
Reference in New Issue