Commit Graph
260 Commits
Author SHA1 Message Date
Cédric Krier 37d80d6f7f Update translate field of all copied records
The same record can be passed multiple times in the list. So we must update all
of the new records with the translated value of the fields.

issue9866
review353091002
2021-01-18 23:20:15 +01:00
Nicolas Évrard 750b597043 Use created_at text for create_date field
issue9902
review308761002
2021-01-07 10:52:08 +01:00
Cédric Krier b16604550c Skip access check on ModelStorage instances
There is no need to enforce access right on instances because only internal
code can use them and the design is to only check on the external calls.

issue7765
review322581002
2020-12-18 00:09:03 +01:00
Nicolas Évrard 1d29cbe2b8 Compute once selection field's value when possible
issue9222
review309331002
2020-12-11 11:57:10 +01:00
Sergi Almacellas Abellana 06346f0c76 Eager load Function field with same multiple getter
issue9561
review314201002
2020-12-06 18:34:19 +01:00
Cédric Krier 1618881692 Allow copying Python instances of Model
issue9869
review337071002
2020-12-05 11:58:41 +01:00
Sergi Almacellas Abellana 02d4e18e35 Remove unused overrided function in modelstorage
issue9863
review331351002
2020-11-23 17:55:20 +01:00
Cédric Krier 2bedebbccc Disable record rule when validating records
issue9796
review329451002
2020-11-11 20:33:18 +01:00
Cédric Krier a1671ab214 Forbid all white spaces except space in Char field
They can not be displayed by all clients (nor OS).
But also they can be trimmed automatically by web input which breaks comparison
against changes.

issue9248
review312681002
2020-11-05 23:58:15 +01:00
Cédric Krier 001245bf60 Support timedelta in CSV import/export
issue9220
review297531002
2020-10-11 19:04:16 +02:00
Cédric Krier bc1f29e6c9 Use the ids order to fill cache with read data
The shared cache is designed for loop usage so we must ensure that we fill the
LRU dictionary in the same order as the loop will request attributes.
So we must order the result of the read because the API does not return data in
the same order as the list of ids.

issue9518
review318041002
2020-08-10 23:24:02 +02:00
Cédric Krier d882e84c74 Delete read data after having instantiated all targets
Some read value may be needed to instantiate other records if it is used in the
context.
Also the test to fill fields dictionary was always false as it tested the field
instance instead of the name.

issue9380
review298171002
2020-07-13 20:55:53 +02:00
Cédric Krier b3f8d125f9 Use custom class to store record data
By using a class with slots instead of standard dict, we can reduce a lot the
memory usage to store the record data in the caches and values.
Also we can rely on the data in the cache to exist only for real field which
can be used to create a fast path in ModelStorage.__getattr__.
As now storing data in the cache has no extra cost, we can store data from the
transactional cache in the local. This allow also to have a shorter path in
ModelStorage.__getattr__.
For more memory efficiency, we remove the record from the cache instead of
clearing them. It was better to clear a dict but a record is less expensive to
re-instantiate than clearing.

issue9369
issue9225
review297861002
2020-06-13 09:48:03 +02:00
Cédric Krier 3242096509 Evaluate PYSON domain with the origin record
When a relation domain is not valid, the domain used to set on the exception
must be evaluated with the origin record and not the invalid target record.
We take the first origin record as any of the passed record will generate the
same domain per design.

issue9383
review317531002
2020-06-12 12:36:47 +02:00
Cédric Krier a48382124f Support explicit delete and remove for saving and on_change xxx2Many
issue4140
review291281002
2020-04-12 23:18:15 +02:00
Cédric Krier 5626018cd6 Add export CSV data route
issue9090
review261011002
2020-04-12 23:10:30 +02:00
Cédric Krier a2c783371d Do not use only cache if context depends on other fields
We must read all the required fields to set a correct context on the field.

issue9187
review297391002
2020-04-10 18:25:03 +02:00
Cédric Krier 34e5c61a1a Run trigger in the queue
This ensures that internal changes that are reverted later in the same
transaction does not trigger an action.
Also we ensure that a record is triggered by the same trigger only
once per transaction.

issue8342
review280971002
2020-03-28 17:13:12 +01:00
Cédric Krier 72a71019c0 Do not copy Binary content with file_id
This avoid the filestore to reprocess the binary data as the file_id is
already copied.

issue9153
review297241002
2020-03-28 16:57:05 +01:00
David Harper ba776f36a5 Replace memoize with functools.lru_cache
issue9081
review286781002
2020-03-25 17:34:35 +01:00
Cédric Krier d0a82c8bdc Support multiselection field in EvalEnvironment
issue9144
review285001004
2020-03-17 23:28:57 +01:00
Cédric Krier d7ed5f91f5 Fix flake8 errors and warnings
We add the flake8 configuration used so we ensure everyone uses the same.
We remove the usage of __all__ for non public API.
When possible, we rationalize the class name according to its __name__ and module.

issue9082
review297061002
2020-03-01 12:33:54 +01:00
Cédric Krier ac4edd0633 Read context fields if they are also in depends
This implements the real intention of changeset a892e7a649a5.

issue9036
review280791002
2020-02-12 00:15:15 +01:00
Cédric Krier e0b48d3f21 Skip eager loading if field is already in the cache
The Many2One and Reference fields are stored in global cache. If they are
already in the cache, the other eager fields should also be in the cache and it
is highly probable that no read will be needed. So it is better to skip the
eager loading.

issue8863
review272541003
2019-12-11 22:19:04 +01:00
Nicolas Évrard 4085e589d6 Cache some performance sensible config values at the module level
issue8749
review284271002
2019-11-25 14:50:33 +01:00
Cédric Krier f4a7c8d395 Do not try to save reverse field of One2Many
Even if the record is already created, the _save_values should not process the
reverse field otherwise it creates an infinite loop.

issue8742
2019-11-16 15:49:50 +01:00
Nicolas Évrard 5f49ca09a7 Remove implicit field names in ModelStorage.search_read
issue8569
review285801003
2019-11-15 11:58:43 +01:00
Cédric Krier def268915a Add MultiSelection field
issue7851
review249911002
2019-09-20 11:32:56 +02:00
Sebastien Marie afd08618f0 Import zero value as non null value
issue8658
review282121004
2019-09-17 23:12:51 +02:00
Cédric Krier 4154b93a01 Prevent assign unknown attributes on Model
by adding __slots__ on PoolMeta

issue8567
review254091002
2019-09-07 23:45:08 +02:00
Cédric Krier 340cb2f630 Loop over all expression of the relation domain to valid
When the field is a relation, the field name can not be used to inverse the
domain because the record evaluated it the Relation. So we inverse the domain
with all the field in the domain until find one invalid. If we find any then we
raise a generic error.

issue8597
review270141002
2019-08-28 22:31:22 +02:00
Cédric Krier 589e27cc87 Add lazy_gettext
issue8560
review283901002
2019-08-25 13:00:28 +02:00
Cédric Krier ca8e1a088d Use non grouped domain when grouped record > IN_MAX
The break when grouped records are greater than IN_MAX, should break all the
loops in order to prevent use of the grouped domain.

issue8474
review257701002
2019-07-13 00:08:30 +02:00
Cédric Krier 2d4f6766b1 Improve domain validation error from server
We add to DomainValidationError the invalid domain and the field definition so
the client can format and append it to the description of the error.

issue8288
review255351002
2019-06-16 19:04:55 +02:00
Cédric Krier 2d0002d8e9 Allow to search on related field in search box
The server adds to the definition of the fields, the definition of relation
fields up to specific deep level.
The clients use this relation fields definition to extend the domain parser
with those fields using a dot notation. But those "dotted fields" are not
shown in the search filter to not bloat the popup as it is dedicated to
learning.
In addition, Dict fields are also filled with relation fields coming from the
keys defined in the schema model. As the size can very large, it is possible
to deactivate this feature from the configuration.

issue8293
review259391005
2019-06-16 15:44:14 +02:00
Cédric Krier 5b355f37d0 Check access on target only if related field has a target
The Dict field can use the relate syntax to access keys but it does not have
any target model to check.

issue8298
review251291002
2019-04-24 23:46:59 +02:00
Cédric Krier e9ee50982b Allow to update records when importing data
issue652
review273131003
2019-04-04 20:00:25 +02:00
Cédric Krier 34316ae615 Check read access on field in search order
issue8189
review279061002
2019-04-02 19:01:33 +02:00
Cédric Krier 792ebac88b Use locale format for data export and import
issue8196
review255151002
2019-03-28 19:22:49 +01:00
Cédric Krier bb0242faf8 Raise NotImplementedError when setting Function field without setter
issue7985
review265101002
2019-03-27 00:28:58 +01:00
Cédric Krier 44011b1435 Take the field type from the right definition
The field type should be taken from the current fields definition and not from
the class.

issue8212
review273131002
2019-03-22 18:25:52 +01:00
Cédric Krier 2752490423 Improve note button
* Add resources method to ModelStorage
* Support badge on icon
* Display unread and total of notes
* Add two extra colors for icon

issue8122
review70561002
2019-03-22 12:16:36 +01:00
Cédric Krier 10e31bc311 Add Model.__names__ to retrieve model and field names
issue8159
review72431002
2019-03-15 12:27:44 +01:00
Cédric Krier b315e9a6d9 Do not update db_id when deleting XML record without noupdate
If the record has been removed from the XML file, the db_id field will be
required. So we must not update it and let convert delete the data in
post_import.

issue8051
review70521002
2019-02-03 20:33:01 +01:00
Cédric Krier c39858aac7 Allow to delete record from XML with noupdate
We set the db_id to None to avoid to link later to a different record.

issue7668
review50671002
2019-01-07 22:08:52 +01:00
Cédric Krier 1738a4ec35 Add ir.message and use custom exceptions
issue3672
review35291002
2018-12-29 14:19:08 +01:00
Cédric Krier c7f5c54a83 Remove implicit fields names in ModelStorage.read
It is a bad practice to not explicit the fields to read. So we should not
support it.

issue7830
review54421002
2018-11-28 10:05:01 +01:00
Cédric Krier 1a3ee131fe Check read access on field in search domain
issue7766
review50591002
2018-11-12 17:18:06 +01:00
Cédric Krier e115ef92d3 Remove check access to trigger_write_get_eligibles
The triggers returned need to be read without any check access.

issue7764
review68321002
2018-10-15 22:49:51 +02:00
Cédric Krier d221e36653 Improve ModelStorage.copy
* Allow callable in copy default
* Support dotted notation in copy default
* Use setdefault in copy
* Copy default when needed
* Do not set default state in copy
* Use callable and dotted notation in copy default

issue5576
issue7648
review72291002
2018-09-01 01:02:04 +02:00