Commit Graph
167 Commits
Author SHA1 Message Date
Sergi Almacellas Abellana b637c503e7 Only convert dict fields when they are strings
issue6382
review28101002
2017-06-09 13:22:42 +02:00
Cédric Krier 8479768619 Ensure Many2One target join is unique if Target has history
The joins added in tables must ensure to make a Cartesian product.
So when joining on a history table, the target id is not unique so the latest
must be used only for the join. Otherwise a search query may return multiple
times the same id.

issue6458
review37341002
2017-04-26 19:33:32 +02:00
Sergi Almacellas Abellana 7cc9585630 Ensure all _parent_ values are set on fields.depends
If the client does not sent all the values of the parent model fields, we must
ensure that the empty ones have None value

issue6450
review40271002
2017-04-26 13:56:30 +02:00
Cédric Krier a178546d0d Use _field for sql_format of Function field
It is useful to allow to use sql_format on Function field when writing SQL
query that emulate the field.

issue6410
review34051002
2017-04-01 19:55:35 +02:00
Cédric Krier a908e8cc74 Add MultiValueMixin and ValueMixin and remove Propery
issue2349
review23351002
2017-04-01 00:24:55 +02:00
Nicolas Évrard 5cee718423 Move low level handling of the SQL type to the backend
This changeset defines on the field the (somehow) abstract SQL type a field
should use letting the duty of specifying the real SQL type the database
supports and the conversion to/from the python types to the backend.

issue6351
review33951002
2017-03-31 12:44:22 +02:00
Sergi Almacellas Abellana 95e000c9e8 Add filter to xxx2Many fields
issue4005
review32001002
2017-03-30 09:40:41 +02:00
Cédric Krier e7ff9ee619 Use compact separators to dump json
issue6373
review33991002
2017-03-23 22:51:36 +01:00
Cédric Krier 1124d15853 Support complex domain with where clause on Many2Many
issue6272
review33841002
2017-02-20 23:16:54 +01:00
Nicolas Évrard 39c12cf496 Add set_rpc on Field
The __rpc__ attribute is currently filled by method in ModelView. Allowing
fields to define themselves what endpoints should be remotely callable make
this process more flexible.

issue4044
review30991002
2017-02-01 16:11:00 +01:00
Cédric Krier 37cd24210a Use integer as default value for id when compare to 0
In Python3, it is no more allowed to compare None with integer.

issue6231
review27941002
2017-02-01 10:29:54 +01:00
Sergi Almacellas Abellana 8339247071 Ensure add_remove attribute is a valid domain
issue6230
review34671002
2017-02-01 10:15:12 +01:00
Cédric Krier dd3e0a4c2a Improve assertion in convert_domain of Function field
The field name from the domain could be a nested if the Function field is
relational. So it must just if it starts with the name of the field.
2016-12-22 01:15:46 +01: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 f9c0457416 Remove support for simplejson
On Python 3, simplejson has a different behaviour than the stdlib json,
especially for dumping bytes.

issue6010
review33601002
2016-11-05 19:54:12 +01:00
Cédric Krier 21e4b96fea Support selection method in TranslatedSelection
The Selection field could have a method name as selection so
TranslatedSelection must call this method to get the selection values.

issue5999
review27791002
2016-10-31 17:19:47 +01:00
Jan Grasnick 1eadd71f98 Add support for datetime_field to fields.Reference
issue4579
review26811002
2016-10-21 12:52:26 +02:00
Cédric Krier 972a1b6c91 Do not link the cache of the instances if id is negative
Otherwise trytond will try to read it from the database and fail.

issue5874
2016-09-22 11:33:51 +02:00
Cédric Krier bf7148d9d3 Link the cache of the instances in xxx2Many setter
Just as it is done when browsing xxx2Many field, the instances set by the
xxx2Many fields should share the same local cache.

issue5874
review30471002
2016-09-21 00:36:49 +02:00
Cédric Krier 5a9ea33f85 Add Many2Many targets to all records
If at least one record had already the target, the target was not added to any
records. This is because the test for existing link was only done on the target
id instead of the tuple origin and target.

issue5792
review26551002
2016-08-19 21:34:47 +02:00
Cédric Krier 7ca7f4c6f0 Allow to store Binary field in filestore
Two options are added on Binary field to define the column to use to store the
filestore id and the prefix to use.
Those options are used for Attachment and are configurable with conservative
default values.

issue5692
review25471003
2016-07-29 10:51:53 +02:00
Cédric Krier b2e5e20a06 Remove remaining files with sha field
issue3713
2016-07-11 18:34:43 +02: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
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 29129855ec Add support for Python 3
issue3211
review7311002
2016-02-07 16:46:16 +01:00
Nicolas Évrard d4e3b605ef Add 'where' operator to xxx2many
issue4507
review12951002
2016-01-21 10:48:32 +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 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 c18ec6ba74 Add support for float and integer on Property fields
issue4942
review18531002
2015-09-14 10:37:38 +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 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
Cédric Krier a739a80228 Fix Rule.domain_get usage in many2one
Since changeset a96d8a738cee, Rule.domain_get returns a domain instead of SQL
expression.
2015-06-15 02:19:49 +02:00
Cédric Krier 5478e5463f Don't use subquery to enforce record rule
Rule.domain_get returns now only a domain and Rule.query_get returns the query
which domain_get used to.

issue4800
review8151002
2015-06-15 01:14:47 +02:00
Cédric Krier 0c4725b891 Add target_search option on Many2One
The option allow to select between the subquery or the join format for target
search clause.

issue4798
review16341002
2015-06-15 01:10:59 +02:00
Cédric Krier 375cde4422 Remove unecessary join in Many2Many getter
The target Many2One can be directly used now.

issue4799
review15471002
2015-06-15 01:09:18 +02:00
Cédric Krier a913a10d0f Add only fields define in context for read
instead of all the depend fields.

issue4401
review8111002
2015-04-11 13:35:28 -04:00
Cédric Krier 611b96c5f0 Add is_instance_method tool compatible with Python3
issue3211
2015-03-18 23:34:55 +01:00
Cédric Krier 31e8634bf4 Fix bytes and bytearray usage
- sqlite can not convert bytearray, must use buffer
- binary value could be stored as unicode
- don't dump bytes as base64 in xmlrpclib if bytes is str
2015-03-16 20:13:03 +01:00
Cédric Krier 5cfde31ed2 Use bytes and bytearray for Binary
issue4637
review11091002
2015-03-16 19:28:34 +01:00
Cédric Krier d7db35c995 Fix selection_change_with
Initialize selection_change_with with en empty set. It must be a set to allow
later fields.depends to update it. The ModelAccess.check_relation must also
manage instance method.

issue4636
review14091002
2015-03-15 16:26:10 +01:00
Cédric Krier 0235d02ae7 Fix TimeDelta for MySQL
MySQL doesn't have a INTERVAL type so it must fallback to storing the total
seconds as DOUBLE.

issue4026
review8951002
2015-02-19 13:45: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
Nicolas Évrard dcf57d8c33 Allow to use the dotted notation for search order parameters
issue4370
review5801002
2015-01-02 16:33:00 +01:00
Cédric Krier 67d5291bfd Use Field.sql_column for SELECT queries in ModelSQL
By using sql_column, it increases the possibilities of customisation of fields.

issue4369
review14711002
2014-12-20 19:24:42 +01:00
Sergi Almacellas Abellana dc3ee92a88 Fix One2One to create all the relations when called with multiple records
issue4353
review12711002
2014-12-05 18:32:00 +01:00