mirror of
https://github.com/NaN-tic/trytond-patches.git
synced 2023-12-14 06:03:03 +01:00
Remove unnecessary assignment on cache selction of Reference fields
This commit is contained in:
parent
0c1fcef841
commit
afd736879c
35
issue309331002_305261002_256961002.diff
Normal file
35
issue309331002_305261002_256961002.diff
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
diff --git a/trytond/model/modelstorage.py b/trytond/model/modelstorage.py
|
||||||
|
index 32d6a531..e74ff841 100644
|
||||||
|
--- a/trytond/model/modelstorage.py
|
||||||
|
+++ b/trytond/model/modelstorage.py
|
||||||
|
@@ -1084,6 +1084,15 @@ class ModelStorage(Model):
|
||||||
|
if hasattr(field, 'selection') and field.selection:
|
||||||
|
if isinstance(field.selection, (tuple, list)):
|
||||||
|
test = set(dict(field.selection).keys())
|
||||||
|
+ instance_sel_func = False
|
||||||
|
+ else:
|
||||||
|
+ sel_func = getattr(cls, field.selection)
|
||||||
|
+ instance_sel_func = is_instance_method(cls,
|
||||||
|
+ field.selection)
|
||||||
|
+ if not instance_sel_func:
|
||||||
|
+ test = sel_func()
|
||||||
|
+ test = set(dict(test))
|
||||||
|
+
|
||||||
|
for record in records:
|
||||||
|
value = getattr(record, field_name)
|
||||||
|
if field._type == 'reference':
|
||||||
|
@@ -1091,12 +1100,8 @@ class ModelStorage(Model):
|
||||||
|
value = value.__class__.__name__
|
||||||
|
elif value:
|
||||||
|
value, _ = value.split(',')
|
||||||
|
- if not isinstance(field.selection, (tuple, list)):
|
||||||
|
- sel_func = getattr(cls, field.selection)
|
||||||
|
- if not is_instance_method(cls, field.selection):
|
||||||
|
- test = sel_func()
|
||||||
|
- else:
|
||||||
|
- test = sel_func(record)
|
||||||
|
+ if instance_sel_func:
|
||||||
|
+ test = sel_func(record)
|
||||||
|
test = set(dict(test))
|
||||||
|
# None and '' are equivalent
|
||||||
|
if '' in test or None in test:
|
1
series
1
series
|
@ -87,3 +87,4 @@ issue8252.diff # [account_tax_rule_country] Add subdivisiions to match account t
|
||||||
account_statement_message_invoice.diff # [account_statement] Add invoice number in amount_greater_invoice_amount_to_pay error message
|
account_statement_message_invoice.diff # [account_statement] Add invoice number in amount_greater_invoice_amount_to_pay error message
|
||||||
|
|
||||||
lazy_loading.diff
|
lazy_loading.diff
|
||||||
|
issue309331002_305261002_256961002.diff # Issue 309331002: tryton-env: Cache selection of Reference fields. Remove unnecessary assignment
|
||||||
|
|
Loading…
Reference in a new issue