Commit Graph
128 Commits
Author SHA1 Message Date
Cédric Krier 1618881692 Allow copying Python instances of Model
issue9869
review337071002
2020-12-05 11:58:41 +01:00
Cédric Krier 4a1f2c938b Use different hash for records without id
In order to have store them efficiently in dictionary, we generate a different
hash for each unsaved record by using the instance id.

issue9240
review295421002
2020-06-17 00:30: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 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 d0e95329a3 Replace __unicode__ by __str__
The unicode method is no supported by Python3. There is only __str__.

issue8769
review262341002
2019-10-30 14:09:20 +01:00
Cédric Krier 1ef4a01585 Correctly test field access to set readonly attribute
Since r 1094d993d89c, field variable is the field instance and no more the
field name.

issue8692
review276071002
2019-10-08 18:10:23 +02:00
Cédric Krier d9b4d71a11 Ensure context is correctly set when initializing Model
We make the assignation twice if any field has a context defined. This ensures
that the context will be evaluated with all initialized values when
the target records will be instantiated.

issue8586
review282041002
2019-09-09 22:41:54 +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 589e27cc87 Add lazy_gettext
issue8560
review283901002
2019-08-25 13:00:28 +02:00
Cédric Krier 1f2256d545 Call change_with selection method with an instance
issue8293
2019-08-07 17:12:33 +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 0fbf5cecd2 Add cache management on RPC
issue8233
review257231002
2019-04-08 10:10:40 +02: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 98bb26a386 Move field definition from Model to Field
issue8037
review74441002
2019-02-13 10:37:40 +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 d1bb790cb8 New API to read related fields
issue7888
review58431002
2018-12-21 23:41:56 +01:00
Cédric Krier e4e7ae740d Disable sortable and searchable on ModelView only
Those feature depends on the Model having a search method.

issue7878
review56491002
2018-12-17 23:03:19 +01:00
Cédric Krier 81375e0d45 Use callable instead of instance of collections.Callable
issue7666
review50571002
2018-09-11 00:19:52 +02: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 ae06a8bca2 Add transactional queue and workers
issue7406
review45461002
2018-07-27 09:32:28 +02:00
Cédric Krier d2a461390a Remove support for Python 2.7
issue7497
review53261002
2018-06-26 19:11:19 +02:00
Nicolas Évrard ff5b79819b Add support for search_* attributes on relational fields
issue6081
review25871002
2018-03-21 17:59:55 +01:00
Cédric Krier f7c1de84c4 Support instantiate model with _parent_ of _parent_
This is a valid depends value for a field but the __init__ method lose the
second _parent_ once it has been instantiated a first time.
Setting _parent_ value must be done recursively.

issue6441
review40261002
2017-04-19 10:31:45 +02:00
Cédric Krier a908e8cc74 Add MultiValueMixin and ValueMixin and remove Propery
issue2349
review23351002
2017-04-01 00:24:55 +02:00
Sergi Almacellas Abellana 95e000c9e8 Add filter to xxx2Many fields
issue4005
review32001002
2017-03-30 09:40:41 +02:00
Cédric Krier f6deed5941 Allow to use domain_<field name> method with Function fields
issue6113
review26961003
2016-12-21 23:08:30 +01:00
Cédric Krier 8b99a62f10 Use 'default_rec_name' context key in Model.default_get
This allow the client to set searched value as default rec_name when the user
choose to create the record.

issue4136
review22131002
2016-08-04 23:54:50 +02:00
Nicolas Évrard 33224eeaa3 Check self.id against None before comparing to 0
issue5590
review25111002
2016-06-03 13:01:39 +02: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 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 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 2c31955934 Make Property field on Many2One not searchable
issue4673
review14171002
2015-03-27 14:59:57 +01:00
Cédric Krier 0991a552de Add TimeDelta field
And remove float_time widget.

issue4026
review5911002
2015-02-09 22:58:56 +01:00
Sergi Almacellas Abellana c4e96f4a08 Improve error message when model does not have any docstring
issue4390
review12921002
2015-02-04 23:16:11 +01:00
Cédric Krier c144f8c349 Fix most flake8 errors
review8771002
2014-12-02 12:54:01 +01:00
Cédric Krier ab3a4692ee Don't compare record values
changeset 8e8f1a801098 introduced a equality comparison of records without id
using the values.  This prevents to store in a dictonary different instances
having by chance the same values.  So it seems better to consider only as equal
the same instances without id.

issue4306
review10621002
2014-10-31 10:54:30 +01:00
Cédric Krier fee97ca399 New API for on_change
Modify the instance instead of returning a dictionary.

issue4203
review8581002
2014-10-29 20:38:17 +01:00
Cédric Krier 0602387444 Keep fields.depends over multiple setup calls
Since changeset 690d629e0050, the field is always an original copy so it loose
the depends set on previous setup calls. The depends should be comptute all
over the mro.

issue4200
review13531002
2014-09-30 09:37:26 +02:00
Cédric Krier e740b5f432 Remove on_change call from default_get
The on_change call doesn't work for xxx2many fields, so it is moved on the
client side where it is properly managed.

issue3923
review6301002
2014-06-08 00:33:31 +02:00
Nicolas Évrard f7133b8670 Use total_ordering
issue3884
review8291003
2014-06-06 13:26:44 +02:00
Cédric Krier 22899c33e2 Set relation_field of one2many only when exists
The client use this value if it exists for string concatenation, so having None
fails.
2014-05-09 14:52:30 +02:00
Cédric Krier 5c00bf48bf Set relation_field only if there is no ambiguity
issue3899
review6271002
2014-05-09 14:37:30 +02:00
Cédric Krier a0093e8899 Copy the original field definition
To prevent side-affect with mutable attributes.

issue3814
review4821002
2014-05-06 22:42:42 +02:00
Cédric Krier f72b983c0f Check relation access in fields_get and for default fields in read
issue3750
review4261002
2014-03-15 11:01:14 +01:00
Cédric Krier a130816cbd Add support of domain for non-relation field
issue3743
review4181002
2014-03-15 10:44:45 +01:00
Cédric Krier 729aaa8a00 Better guess "selection_change_with" attribute
Testing on the instance for Selection field is not enough because some field
selection could come from a Function field.
So it is better to use a duck typing style in this case.

issue3649
review3451002
2014-02-14 00:04:31 +01:00
Cédric Krier 2e7c28d348 Add with_on_change switch to default_get
default_get should not call on_change when called in create because it could
modify values set by the caller.

issue3602
review2781002
2014-01-26 21:57:15 +01:00
Cédric Krier 905343c900 Add fields.depends decorator
issue3487
review2301002
2014-01-26 14:27:24 +01:00
Cédric Krier 3f5dba2235 Add relation_field for many2one
issue3173
review1201002
2013-10-27 19:31:36 +01:00
Cédric Krier fc6c6cfdda Migration to python-sql
* Use python-sql
* Add convert_domain method on Fields
* Add sql_format and sql_type methods on Fields
* Allow to return a full domain for Function.searcher
* Replace static backend by dynamic get method
* Replace order_field by order_<field name> method

review1001002
2013-09-06 22:32:37 +02:00