Commit Graph
115 Commits
Author SHA1 Message Date
Raphael Collet 0eb8518786 [IMP] fields: describe group_operator when given on all field types 2018-04-06 10:57:02 +02:00
Christophe Simonis b51f2d38c2 [MERGE] forward port branch saas-11.2 up to 500e3f4970 2018-03-21 11:04:48 +01:00
Christophe Simonis e0345a4a3f [MERGE] forward port branch 11.0 up to 2835d29979 2018-03-20 11:45:11 +01:00
Christophe Simonis c921d94236 [MERGE] forward port branch saas-15 up to 3730a0d2df 2018-03-13 12:05:36 +01:00
Christophe Simonis 3730a0d2df [MERGE] forward port branch saas-14 up to 0e898eae35 2018-03-12 18:48:15 +01:00
Christophe Simonis 0e898eae35 [MERGE] forward port branch 10.0 up to 0440e25380 2018-03-12 18:16:02 +01:00
Nicolas Martinelli 2021f44c0e [FIX] fields: empty date or datetime
When the `create` or `write` method receives an empty string for a date
or a datetime field, PostgreSQL will fail since this is not an accepted
value for this field type.

We fallback on `None` for falsy values.

opw-1819336

@KangOl : watch out when forward-porting, the signature of
`convert_to_column` has changed in saas-14.
2018-03-12 12:01:42 +01:00
David Arnold 231cae2e7f [FIX] fields: copy_cache with failed values onto sudo env (#23122)
Do not copy failed values, as they usually reveal access error that should
not occur in the sudoed env.

Closes #23121
2018-03-12 10:14:01 +01:00
Christophe Simonis 0f57bdba72 [MERGE] forward port branch saas-11.2 up to 42659dc70c 2018-03-09 16:25:58 +01:00
Adrian Torres bbfb098a54 [IMP] fields: allow shared fields
Given the following variables:
    * Module A
    * Module B
    * Model M
    * Field X of model M

If module A defines M.X and is installed, an xmlid for this field is
generated in the form of A.field_M_X

Before this commit:

If module B defines M.X as well and is installed after module A, no
xmlid is generated.

This means that if module A is uninstalled, the single xmlid pointing to
M.X will be deleted and thus, the field itself will be deleted as well,
therefore any views from module B referencing M.X will crash.

After this commit:

If module B (or any subsequent modules) define M.X, an xmlid will be
generated in the form of B.field_M_X.

If module A is uninstalled, the xmlid A.field_M_X will be deleted, but
B.field_M_X will remain and thus the field itself won't be deleted.

This system means that for a single actual field, there can be multiple
xmlids, each xmlid sharing the same field, thus the name "shared
fields".

Task ID 38016
2018-03-09 15:44:39 +01:00
Christophe Simonis 4aa5ec3fa5 [MERGE] forward port branch 11.0 up to d67b410dfc 2018-03-07 18:46:38 +01:00
Raphael Collet b53c017052 [FIX] fields: use copy_cache during onchanges only
This fixes the bug introduced in rev 34c52e9938
that optimizes method `copy_cache`.
2018-03-05 11:25:37 +01:00
Christophe Simonis 3b959c313d [MERGE] forward port branch saas-11.1 up to a277b58507 2018-02-15 11:52:10 +01:00
Christophe Simonis a277b58507 [MERGE] forward port branch 11.0 up to 259686ba78 2018-02-15 10:58:08 +01:00
Raphael Collet 34c52e9938 [FIX] fields: performance of onchange on related fields
Optimize the copy of the cache being made by related fields to compute
themselves.  Instead of traversing records data in cache, follow the cache
structure itself and copy everything!

OPW 816125
2018-02-13 17:08:49 +01:00
Raphael Collet 869f062e08 [REF] models: improve code of _create/_write
Also remove method `self._check_selection_field_value`, and perform the check
in field method `convert_to_column`.
2018-01-16 10:47:13 +01:00
Christophe Simonis 03a36a9bba [MERGE] forward port branch saas-11.1 up to 56974322f8 2018-01-12 19:13:10 +01:00
Christophe Simonis 56974322f8 [MERGE] forward port branch 11.0 up to 3b80a059ff 2018-01-12 19:03:00 +01:00
Raphael Collet ca9d2b3006 [IMP] fields: log when a stored field depends on a non-stored field
Log an info when a field is computed and stored, but not all its dependencies
are stored.  Also allow to set explicitly `depends` on a field; this is useful
to restrict the dependencies of a related field.
2018-01-12 14:13:37 +01:00
Raphael Collet 3fbd86bcbe [IMP] field: compute transitive dependencies over non-stored fields
In other words, when a field F depends on a non-stored field G, it also depends
on G's dependencies.  This guarantees that whenever a dependency of G is
modified, F will be invalidated and marked to recompute (if necessary).

The transitive closure of dependencies is not computed over stored fields.
Anyway stored fields already trigger the recomputation of their dependent
fields during their recomputation.  The performance impact on the loading of a
registry is negligible (less than 1%), and the increase of recomputation
triggers is small (less than 10%).
2018-01-12 13:42:05 +01:00
Raphael Collet 309b6b8e5a [FIX] api: optimize odoo.api.Cache.get_records()
Assuming that `field.cache_key(record)` is independent from `record.id`,
compute the cache key once for all records, and avoid using `browse` on all
record ids.  This makes `get_records` about 20 times faster.

This has a good performance impact on `field.modified_draft()`, which is used
during onchanges for invalidating fields.
2018-01-11 13:52:16 +01:00
Christophe Simonis 4708812b6c [MERGE] forward port branch 11.0 up to b37cc1f9b7 2017-12-12 18:50:59 +01:00
Christophe Simonis b37cc1f9b7 [MERGE] forward port branch saas-16 up to a2ea4ba095 2017-12-12 18:39:43 +01:00
Christophe Simonis a2ea4ba095 [MERGE] forward port branch saas-15 up to 5701010d0d 2017-12-12 16:15:04 +01:00
Christophe Simonis 5701010d0d [MERGE] forward port branch saas-14 up to 744c2934b3 2017-12-12 15:35:11 +01:00
Christophe Simonis 744c2934b3 [MERGE] forward port branch 10.0 up to 219c93252f 2017-12-12 14:49:29 +01:00
Christophe Simonis 219c93252f [MERGE] forward port branch 9.0 up to 7a24a2f45f 2017-12-12 14:15:15 +01:00
Raphael Collet 6da1c3ac4c [FIX] fields: performance of convert_to_onchange on x2many fields
Suppose we convert a x2many field `foo_ids` with a many2one sub-field `bar_id`.
The conversion of the values of `bar_id` generates pairs `(id, name)`.  Before
this patch, the method `name_get` is invoked on every value, one by one.
Rewrite the code to ensure that `name_get()` is invoked on all values at once.
2017-12-06 15:56:25 +01:00
Christophe Simonis b8540eefe3 [MERGE] forward port branch saas-15 up to 970be94f37 2017-12-05 16:46:14 +01:00
Christophe Simonis 970be94f37 [MERGE] forward port branch saas-14 up to e9c2dcd28d 2017-12-05 14:52:16 +01:00
Lucas Perais (lpe) 2a86e9245c [FIX][BACKPORT] Always round monetary values in database
backport of afef71d6b9

Original commit message:

Let `create` and `write` round monetary field values before sending them to the
database. Pass the values to be written to `field.convert_to_column`, so that
the currency can be retrieved from the values, and the value be rounded.
2017-12-05 13:46:06 +01:00
Alexandre Kühn f38ace8de2 [DOC] fields: improve doc for trim attribute 2017-11-30 13:00:36 +01:00
Alexandre Kühn fb6c9c2443 [IMP] web: FieldChar trim its value by default
With this commit, we change the behaviour of the web client with respect
to spaces in char fields.  Most of the time, starting and ending spaces
have no value, and worse, make the data not so reliable.

After this commit, field char will trim by default (so, if the user input a
char as ' abc ', the string 'abc' will be sent to the server instead).
Note that this only applies when the value of the field is changed.  If
someone open a form view, then switches to edit mode and save, nothing
will change.

This is the desired behavior most of the time.  However, in some rare
cases, this is actually harmful.  For example, if we trim the
'decimal_point' field, it will not be possible to enter a whitespace as
decimal separator.  In those cases, we introduce a new attribute 'trim',
which allow the developer to desactivate that feature.
2017-11-24 13:09:10 +01:00
Christophe Simonis 1da064a1d3 [MERGE] forward port branch saas-16 up to 8ee9024a4c 2017-10-13 13:13:11 +02:00
Christophe Simonis aeae519a65 [MERGE] forward port branch saas-15 up to 945dd32eb0 2017-10-12 21:44:28 +02:00
Christophe Simonis 945dd32eb0 [MERGE] forward port branch saas-14 up to 91e2264b28 2017-10-12 18:43:14 +02:00
Christophe Simonis 91e2264b28 [MERGE] forward port branch 10.0 up to ba519bde84 2017-10-12 17:30:01 +02:00
Raphael Collet 10412d351c [FIX] fields: prefetching of related fields (#20017)
Prefetching is underused when all fields are traversed one record at a time.
So instead, traverse all records one field at a time.  This guarantees batch
prefetching/computation on every field being accessed.
2017-10-11 13:39:02 +02:00
Raphael Collet 0af8d4ffd2 [FIX] fields: performance optimization
Add a shortcut in `copy_cache`, to avoid iterating on all fields.
2017-10-11 11:55:02 +02:00
Christophe Simonis e1104ac344 [FIX] core: revert cb1cfadda2
Due to Cache reimplementation, this commit can't be applied as-it in
version 11.0 and need to be adapted correctly.

Undo PR #19963
2017-10-10 18:36:34 +02:00
Christophe Simonis 6c2ab192ea [MERGE] forward port branch saas-16 up to 88a9980b0c 2017-10-10 16:49:59 +02:00
Christophe Simonis 88a9980b0c [MERGE] forward port branch saas-15 up to 66945d3427 2017-10-10 14:15:24 +02:00
Christophe Simonis 66945d3427 [MERGE] forward port branch saas-14 up to 68d1ad5b7a 2017-10-10 13:27:29 +02:00
Christophe Simonis daa2194677 [MERGE] forward port branch 10.0 up to 0e28db88d1 2017-10-10 12:32:50 +02:00
Raphael Collet fcf6ef476c [FIX] fields: writing on a one2many with a domain should not remove all lines
Specifically, the command `(6, 0, ids)` should only unlink/detach the lines
that satisfy to the field's domain.

Test from #18440

opw-756983
2017-10-10 11:21:15 +02:00
Christophe Simonis 446ff1baf8 [MERGE] forward port branch saas-15 up to b60a41ce14 2017-10-09 17:54:36 +02:00
Christophe Simonis 6b0828b3bf [MERGE] forward port branch saas-14 up to 85c8000738 2017-10-09 13:24:17 +02:00
Christophe Simonis 85c8000738 [MERGE] forward port branch 10.0 up to cb1cfadda2 2017-10-09 12:44:22 +02:00
Raphael Collet cb1cfadda2 [FIX] fields: performance issue in copy_cache (#19963)
That function is called when computing related fields in onchange mode.
The new implementation makes a direct access to the cache's implementation.

opw-772303
2017-10-09 11:53:18 +02:00
Raphael Collet e671679183 [FIX] fields: do not use int() to retrieve record id
When reading a one2many field, the inverse field of the retrieved lines may
already be assigned in cache to a new record.  This can happen during an
onchange.  In that case, the algorithm crashes.  Let's clean it up!
2017-09-26 11:43:37 +02:00