Commit Graph
126 Commits
Author SHA1 Message Date
Christophe Simonis f36e6917bd [MERGE] forward port branch saas-11.3 up to 37eed7c509 2018-05-29 17:34:43 +02:00
Raphael Collet 6a601fe6dc [IMP] test-pylint: check for undefined variables 2018-05-16 13:58:39 +02:00
Christophe Simonis bca769a1e8 [MERGE] forward port branch saas-11.2 up to e70e5b6cf3 2018-05-14 17:31:53 +02:00
Christophe Simonis e70e5b6cf3 [MERGE] forward port branch 11.0 up to 2787de8c68 2018-05-14 16:46:11 +02:00
Raphael Collet 7f27992998 [FIX] fields: convert selection value to int
When a string value is assigned to a selection field expecting integers, the
value simply rejected.  In such a case, convert the value to an integer before
validating it.
2018-05-14 12:08:59 +02:00
Christophe Simonis 1f22b81203 [MERGE] forward port branch saas-11.2 up to 7113b70762 2018-04-23 19:36:25 +02:00
Christophe Simonis e8bf128318 [MERGE] forward port branch 11.0 up to 3ab25b60bc 2018-04-23 18:15:25 +02:00
Nicolas Lempereur 96ce375c61 [FIX] models: more than one prefetch in onchange
When a record fields are prefetched, the currently accessed record is
prefetched as well as PREFETCH_MAX (=1000) minus currenly accessed
records.

Since 439fa826 the id field was thought as "prefetched" but was not,
which caused that in an onchange, we would have a prefetching as follow
for 1200 records:

- get records 1-1000
- get record 1001 (1001-1200 INTERSECTION 1-999 (id) + 1001 (current))
- get record 1002 (1002-1200 INTERSECTION 1-999 (id) + 1002 (current))
- get record 1003 (1003-1200 INTERSECTION 1-999 (id) + 1003 (current))
- ...
- get record 1200 (1200 INTERSECTION 1-999 (id) + 1200 (current))

So we would do 201 queries instead of 2 when prefetching the records.

The added test without this change failed the query count with:

 "AssertionError: 284 not less than or equal to 5 : admin"

opw-1837548
opw-1837552
closes #24326
2018-04-20 10:54:29 +02:00
Christophe Simonis e82030433d [MERGE] forward port branch saas-11.2 up to 7084a5190c 2018-04-19 16:33:40 +02:00
Christophe Simonis 7084a5190c [MERGE] forward port branch 11.0 up to 841f3914cc 2018-04-19 15:04:26 +02:00
Raphael Collet c9caf55177 [FIX] models: bad setup of inherited custom fields
Assume a custom field F is defined on model 'res.partner'.  The setup of F may
silently fail because of missing stuff.  In that situation, setting up the
field inherited from F on model 'res.users' should also silently fail.

To reproduce the bug, install Invoicing, create a related custom field F on
'res.partner' with 'property_account_position_id.active', and install another
module.  Setting up F after loading module 'base' will fail because the field
'property_account_position_id' does not exist yet.  The error is not caught by
the inheritance of F on model 'res.users', and the installation crashes.
2018-04-19 10:00:49 +02:00
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