Commit Graph
621 Commits
Author SHA1 Message Date
Cédric Krier 33b240736c Re-introduce iteration over keys
It was removed in changeset 808e05f4898c but indeed we need a copy list of the
keys because the dictionary is modified during the iteration.
2016-03-19 15:25:49 +01:00
Cédric Krier 23c45fc511 Group records when calling set method for field with the same value
We need to loop to compare the values instead of using a dictionary because the
values are not necessary hashable. But it is still an improvement compared to
calling the set method for each record.

issue5398
review19111002
2016-03-19 12:07:27 +01:00
Cédric Krier 1380d60c45 Cache default values in ModelSQL.create
default values should be constant during the create transaction so we could
cache the result and avoid query it for each created record.

issue5397
review16121002
2016-03-19 12:04:35 +01:00
Cédric Krier 510931a8ab Use OrderedDict in Workflow.transition for cache alignment
This allows to loop over the key in the same order as the list of records.
Also avoid to use .keys() when iterating on dict because it generate a useless
list on Python2.
Use list on dict instead of .keys() to avoid one extra call on Python3 because
.key() return an iterator.

issue5396
review20061002
2016-03-19 11:59:52 +01:00
Cédric Krier 9dfb717088 Always use __name__ instead of _get_name to raise access_error
Other similar exception use __name__
2016-03-16 12:48:15 +01:00
Cédric Krier bfe9e5bea8 ModelStorage._clean_defaults must skip related fields
Related fields like '.rec_name' could be set as default value, they are not
defined in _fields and they must be cleaned.

issue5376
review17131002
2016-03-16 12:46:20 +01:00
Cédric Krier 9b94696b05 Speed up instantiation of Models
Pass as much possible, pre-computed parameters to __init__ to move their
computation outside the loop.

issue5294
review20721002
2016-03-15 19:01:47 +01:00
Cédric Krier 4d58b3a720 Don't remove from context the format of Binary fields
The getter of the Binary field could be called many times in the same
transaction, so popping out the format from the context create a side effect
that changes the requested format.

issue3774
review19981002
2016-03-05 17:26:27 +01:00
Cédric Krier 22dc3d23bc Remove __setattr__ from Model
This method is there to only skip the id attribute to be set using the field
__set__ but it has a cost as it is called each time an attribute is set.
So we store now the id value in the attribute '_id' which doesn't overload the
field and we adapt field __get__ for this new location.
The __getitem__ is also removed as it is deprecated since 2.6.

issue5296
review17031002
2016-03-04 00:19:18 +01:00
Cédric Krier 512808e151 Add LRUDictTransaction
issue5293
review22771002
2016-03-03 23:27:38 +01:00
Nicolas Évrard 2fef479575 Follow PEP-0249 for Transaction and backends
issue4949
review19781002
2016-03-03 21:51:57 +01:00
Nicolas Évrard 9aa648513e re-add the use of the case removed in changeset 0c62b08fa917
Removing the case resulted in the evaluation of expression that were not valid
like the cast of a string into an integer.

issue5335
review16011002
2016-02-19 12:43:12 +01:00
Cédric Krier af00126074 Allow to modify XML record with noupdate
issue5176
review19851002
2016-02-11 22:18:29 +01:00
Cédric Krier 29129855ec Add support for Python 3
issue3211
review7311002
2016-02-07 16:46:16 +01:00
Cédric Krier 81f1e8b6db Fix typo when reading getter fields with datetime_field
issue5269
review20671002
2016-02-02 19:03:11 +01:00
Nicolas Évrard d4e3b605ef Add 'where' operator to xxx2many
issue4507
review12951002
2016-01-21 10:48:32 +01:00
Sergi Almacellas Abellana 2a723f2e52 Only rebuild mptt tree if needed
The tree will be only rebuild if a record with the default value of left or right fields exists.

issue5118
review16921002
2016-01-11 15:33:08 +01:00
Cédric Krier 1bd76628c6 Set view_ids attribute only if it is not empty
issue5207
review15861002
2015-12-31 14:17:03 +01:00
Cédric Krier 71c0e0a3af Allow nested inherited views
Search and use the recursive type of the views

issue5206
review17691002
2015-12-31 14:15:51 +01:00
Cédric Krier 1f04a58562 Remove comments from view.arch
A side effect of this change is that now the method parse only once the arch of
each view instead of dumping and parsing the intermediary result of
inheritance.

issue5189
review18831002
2015-12-31 14:13:03 +01:00
Sergi Almacellas Abellana 80b3679dd3 Backed out changeset ac3c495d797f 2015-12-28 15:29:21 +01:00
Sergi Almacellas Abellana fc58438188 Only rebuild mptt tree one time per model in a database update
issue5118
review20501002
2015-12-28 14:13:03 +01:00
Cédric Krier 2e37bf7852 Don't return changed many2one if the id is None
If the id is None, it is a temporary record which should not be considered as a
value change.

issue5190
review20601002
2015-12-27 20:03:59 +01:00
Cédric Krier 1a7c6c3a06 Add missing id on label
Fields without read access are replaced by empty label but they still require
at least a name attribute or an id.

issue5187
review19701002
2015-12-27 20:01:03 +01:00
Cédric Krier 5999bb231d Check all fields when writing a sequence of records, values
issue5167
review22631002
2015-12-16 13:47:33 +01:00
Cédric Krier bcd557da3b Many2Many are not sortable
fields_get should set sortable to False for Many2Many.

issue5123
review15821002
2015-11-15 12:45:41 -03:00
Cédric Krier 9a58954703 Add view_ids on tree view
issue5052
review24511002
2015-11-10 12:55:06 +01:00
Cédric Krier a61474274a Add parent_of operator
issue5037
review15711002
2015-11-05 23:22:26 +01:00
Cédric Krier b5479332d9 Use instance context in translated descriptor of Selection field
It is more expected from the translated descriptor to return translation in the
language from the instance instead of the current context.

issue5028
review15701002
2015-11-03 12:20:49 +01:00
Cédric Krier 5c062ebeea Always rebuild MPTT tree in case of nested creation
because _update_tree can not find children with left/right.

issue5095
review24571002
2015-11-02 11:41:04 +01:00
Cédric Krier 10af0ea078 Reset MPTT fields when copying records
The left/right fields must be reset to their default values to allow to compute
the correct new values. As it is common to forget this requirement when
implementing, it is safer to enforce this behaviour directly in the
ModelStorage.copy method.

issue5049
review16741002
2015-10-18 16:50:41 +02:00
Cédric Krier 0e467f1b5d Fix order when searching view in ModelView
When id is given, there is no need to perform a search otherwise only root
views or inherited views from other model should be considered.
Instead of explicitly define orders, it is better for modularity to use the
default one defined on the view model.

issue2041
review21461002
2015-10-15 10:44:30 +02:00
Cédric Krier f01f0d5871 Fix child_of domain on empty MPTT
When the MPTT search returns no row, the SQL query generated has an invalid
syntax because it uses an empty Or() clause. We replace this empty Or() by a
Literal(False) to select nothing.

issue5011
review18651002
2015-10-03 11:50:56 +02:00
Cédric Krier fe52324943 Improve SQL expression for child_of on Many2One with MPTT
issue4984
review22441002
2015-09-24 15:48:45 +02:00
Cédric Krier e43bda21bc Wrong parameter passed to __raise_integrity_error 2015-09-21 10:30:25 +02:00
Cédric Krier cd47b8cf85 Use specific test 'elem is None' to remove lxml warning
FutureWarning: The behavior of this method will change in future
versions. Use specific 'len(elem)' or 'elem is not None' test instead.
2015-09-15 14:52:03 +02:00
Cédric Krier 9bc7174254 Backed out changeset 0fd061e7c87f 2015-09-15 14:51:13 +02:00
Cédric Krier 228a8ca7d9 Use specific test 'elem is not None' to remove lxml warning
FutureWarning: The behavior of this method will change in future
versions. Use specific 'len(elem)' or 'elem is not None' test instead.
2015-09-14 12:00:43 +02:00
Cédric Krier c18ec6ba74 Add support for float and integer on Property fields
issue4942
review18531002
2015-09-14 10:37:38 +02:00
Cédric Krier 8299e1c133 Validate XML generated by ModelView.fields_view_get
- Add missing attributes to {form,tree}.rn{c,g}
- Add validatation to test_view
- Prevent fields_view_get to set attribute to the wrong view type

issue4944
review19421002
2015-09-04 12:04:07 +02:00
Cédric Krier 0574e90f5b Remove foreign-key on create_uid and write_uid
Instead prevent delete of any user to keep logging information.

issue4925
review24301002
2015-09-04 11:52:53 +02:00
Cédric Krier 09345debbd Add missing Check and Unique in __all__ 2015-07-30 16:21:31 +02:00
Sergi Almacellas Abellana 9ac3fec4dd Explicity raise error when creating/writing/deleting models with table_query
issue4822
review16351002
2015-07-29 10:56:30 +02:00
Cédric Krier c6c6c7e268 Fix join target_search for history
search_domain must not override the main table with the history instance if
tables is provided by the caller. In such case, it must assume the caller will
pass the right table.
The join search on Many2One must use the history table if the Target is
historized and a _datetime is set in the context.

issue4798
review12251002
2015-07-28 14:54:03 +02:00
Cédric Krier 6cd05ed6fe Add has_multirow_insert
There are still many databases that doesn't support this SQL-92 syntax.

issue4881
review19331002
2015-07-28 08:04:29 +02:00
Cédric Krier 7652df0be4 Allow to override ModelSQL._table
issue4774
review15431002
2015-07-16 01:13:45 +02:00
Cédric Krier ba40cb71d1 Get all eligible records when writting many values
The call to trigger_write_get_eligibles must be done with all the records and
not only the first set.

issue4863
review23311002
2015-07-14 00:06:13 +02:00
Cédric Krier dad49fa98b Always test field presence in initial value when computed changed values
The value could be None which is also the default value returned by dict.get.
So it will fail to detect change in such case.

issue4839
review23281002
2015-07-14 00:04:08 +02:00
Cédric Krier 390aebef15 Simplify the SQL query for domain on property
- Remove useless CASE test
- Simplify double negation

issue4835
review21271002
2015-07-09 15:38:44 +02:00
Cédric Krier 808580e2ea Improve domain queries of xxx2Many
Avoid using double select of ids and origin.

issue4821
review15521002
2015-07-09 15:37:03 +02:00