Commit Graph
220 Commits
Author SHA1 Message Date
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 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 39a6751726 Set default value for missing depends field
This avoid to fill an instance with None value which will prevent it to be
saved with the default value for fields not explicitly assigned.

issue9726
review314481004
2020-10-21 23:23:17 +02:00
Cédric Krier 001245bf60 Support timedelta in CSV import/export
issue9220
review297531002
2020-10-11 19:04:16 +02:00
Cédric Krier e11a23deb2 Rationalize import path
We use absolute path when imported module is from a different context.
And we remove unnecessary __all__ definition.

issue9466
review323591002
2020-07-21 14:38:36 +02:00
Sergi Almacellas Abellana d3f7ea5889 Do not write to existing targets on xxx2Many add
issue9194
review313581011
2020-06-17 13:55:00 +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 fc66c17eb0 Call getter function when accessing Function field
If the record is unsaved and the getter is based on on_change_with, we can call
the getter to compute the value.
This value must not be stored in the cache as it may change prior to saving.

issue4193
issue9263
review317291002
2020-05-03 14:34:44 +02:00
Cédric Krier 8824c5a11b Add context field to on_change calls
Those fields are required to instantiate the fields with the proper context.

issue9236
review293501002
2020-04-19 16:36:15 +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 b12d729c2d Add test on target of relation fields
issue9132
review291211004
2020-04-02 00:01:14 +02: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
Nicolas Évrard e2d8b6b295 Add MultiSelection entry to Dict field
issue8903
review284571003
2019-12-30 14:26:14 +01:00
Cédric Krier 6b14518eff Position new record based on order
We sent an order to the client for action and xxx2Many so its screen has
always a default order set.
To position a new record on non editable tree, we use the order of the 'id'
column if presents.

issue8880
review276501003
2019-12-28 18:16:28 +01:00
Nicolas Évrard 8fb13634ea Use direct access to backend classes
issue8836
review258421002
2019-12-06 17:33:47 +01:00
Cédric Krier ec24fc7727 Fill the reverse field in the One2Many setter
issue8742
review262301002
2019-11-16 14:34:29 +01:00
Cédric Krier def268915a Add MultiSelection field
issue7851
review249911002
2019-09-20 11:32:56 +02:00
Cédric Krier 54e2d31843 Ensure to convert to string LazyString of selection 2019-08-25 20:51:31 +02:00
Cédric Krier 589e27cc87 Add lazy_gettext
issue8560
review283901002
2019-08-25 13:00:28 +02:00
Cédric Krier 51c99aaa12 Allow SQL expression as value of fields
issue6460
review279431002
2019-06-26 21:56:16 +02:00
Cédric Krier e39129ee3d Add sort and translate options to Reference field
As Reference field uses the SelectionMixin, they could have the same options.

issue8278
review253331002
2019-04-15 16:11:00 +02:00
Cédric Krier eb3882e113 Verify keys of fields and buttons states
issue8262
review279221003
2019-04-12 13:08:01 +02:00
Cédric Krier 722db3252a Remove id to on_change calls that are cached
issue8234
review275131002
2019-04-08 10:14:39 +02:00
Cédric Krier 3e9784c8d7 Set context on record instantiated in Field.__set__ and read related
Field may have a context defined so when it instantiate a relational record,
the field should set this context like when the record is read from the
database in ModelStorage.__getattr__.
And when such field is read as related field, the context should also be set.

issue8225
review287171002
2019-04-04 19:06:09 +02: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 e2318257bb Allow to extend Field string and help
Those attributes are stored as StringPartitioned and each part creates its own
translation record. The translated strings are constructed by concatenation of
each translated part.

issue8040
review46731002
2019-03-15 13:01:11 +01:00
Cédric Krier 986da58a48 Use model name instead of class to translate field definition
The typo was introduced in changeset 1094d993d89c.
2019-03-09 15:23:11 +01:00
Cédric Krier f6c3fa2d68 Fill add_remove definition only if it is not None
issue8037
2019-02-18 17:03:13 +01:00
Cédric Krier 8a9d5297c6 Fill size definition only if it is not None
The clients expect to have an integer for the size or no key.

issue8037
2019-02-13 13:57:33 +01:00
Cédric Krier 9ea41ef4c8 Wrong class in super call
Introduced in changeset 5075df5e9872

issue8084
2019-02-13 12:30:05 +01:00
Cédric Krier 67cdf02720 Fill relation_field definition only with real field name
proteus expects the definition to have a field name for relation_field key or
no key at all. So parent_name is always a string.

issue8037
2019-02-13 11:38:16 +01:00
Cédric Krier 98bb26a386 Move field definition from Model to Field
issue8037
review74441002
2019-02-13 10:37:40 +01:00
Cédric Krier 951dbdfa82 Make DateTime field inherit from Timestamp field
The DateTime is a particular case of Timestamp.
This allows to share the sql_cast of DateTime with Timestamp.

issue8084
review64561002
2019-02-13 10:17:27 +01:00
Cédric Krier 889b1cc9f8 Allow to search and order on Dict key value
issue7905
review62391002
2019-01-18 11:32:47 +01:00
Cédric Krier 93e3c0f9df Order selection field with instance method on column
issue7934
review66491002
2018-12-30 00:14:27 +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 c3d2be19f5 Add support of timestamp field on client
issue6463
review50521002
2018-08-01 11:37:09 +02:00
Cédric Krier d2a461390a Remove support for Python 2.7
issue7497
review53261002
2018-06-26 19:11:19 +02:00
Cédric Krier 23ab0cdb13 Ensure second domain argument is a string before testing against OPERATORS
If the second argument is a PYSON expression, the Python 'in' test calls
__eq__ on it which return a PYSON Equal object between the expression and the
operator. If the PYSON expression does not have the string type, an
incompatibility exception is raised.
So this operation must be prevented if the argument is not a string.

issue7491
review45251003
2018-06-11 23:10:27 +02:00
Cédric Krier 4ed54e9bbc Support child_of/parent_of with None in the value list
This was a implicit behaviour before the changeset 6fefd00369c1.
As a lot of code rely on this behaviour, we make it explicit by adding a test
case.

issue7405
review36251002
2018-05-03 11:57:10 +02:00
Cédric Krier 4c1fe028c1 Use recursive common table expression for child_of/parent_of operators
issue7116
review46331002
2018-04-30 16:03:34 +02:00
Cédric Krier 00e4a51a41 Add sql_cast on Field
issue7266
review37141002
2018-04-30 14:59:01 +02:00
Cédric Krier 710c0ab2e9 Rename with_inactive_records decorator
issue7026
2018-04-03 14:55:01 +02:00
Cédric Krier 8c61a67c2b Remove active test in search_domain of Many2One and Reference
As the target is stored on the record, the target is always visible so
searching on it should not add active clause.

issue7026
review41231002
2018-04-03 13:20:37 +02:00
Nicolas Évrard ff5b79819b Add support for search_* attributes on relational fields
issue6081
review25871002
2018-03-21 17:59:55 +01:00
Nicolas Évrard acdbe5a08f Allow to perform unaccented searches on Char fields
issue7115
review44611002
2018-03-16 18:17:53 +01:00
Cédric Krier 478c4e6928 Refactor fields tests
issue7085
review40051002
2018-02-02 00:04:19 +01:00
Cédric Krier 2d2ec90141 Use field name to call searcher or domain of Function field
The name from the domain may be nested.

issue7015
review44511002
2017-12-26 17:26:00 +01:00
Cédric Krier 8cfd0eb692 Use JSON canonical form for Dict value
It allows to make equality comparison.

issue7013
review39041002
2017-12-20 19:26:44 +01:00
Cédric Krier af498348a7 Allow to search and order translated fields using the derivative translations
Since rev 049635454a98, translations are derivatives so the search and order
must be done using all the parent languages.

issue6934
review39971002
2017-12-18 17:45:37 +01:00