Commit Graph
403 Commits
Author SHA1 Message Date
Felix Yan cda1d98656 [IMP] models: correct a typo in comment
Closes #20303
2017-10-19 10:28:47 +02: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
Cédric Pigeon (ACSONE) 4206d1c2a2 [FIX] models: in create, add translations after setting x2many fields. (#19348)
Otherwise if a record rule is defined on a x2many field on the model, the creation will fail because
ir.translation creation check access rules on the model and in this case, the x2many relation are
not set yet.
2017-10-10 15:53:09 +02:00
Raphael Collet a16c44210a [FIX] models: skip an SQL query when its result is known to be empty
In method `search`, simply make an abstract interpretation of the domain to
determine whether it is equivalent to false.  In that case, skip the query.
2017-09-29 16:14:57 +02:00
Raphael Collet c6b184bb23 [FIX] fields: optimize many2many command (6, 0, ids) on new records
The command does not need to remove existing relations, as there is no relation
yet on new records.  This saves one query per many2many field with that command
in a `create`.
2017-09-21 16:10:13 +02:00
Raphael Collet 3069734d4f [FIX] models: in method onchange, filter out pseudo-fields 2017-09-19 17:06:04 +02:00
Raphael Collet 886003af93 [FIX] models: in onchange, consider all levels of subfields 2017-09-13 10:12:16 +02:00
Raphael Collet e7205b7992 [FIX] models: _in_cache_without may not return new ids 2017-09-12 09:36:30 +02:00
Raphael Collet 32a58c0db3 [REF] api: wrap the record cache implementation into a class
This makes the rest of the ORM independent from the cache's implementation, and
rely on a well-defined API instead.
2017-09-08 13:21:00 +02:00
Raphael Collet 64e945aa44 [REF] models: make the API of RecordCache more consistent
Make `RecordCache` work on a single record only, and implement a mapping from
field names (only) to values.

Also add explicit methods on `RecordCache` to wrap special behavior in cache,
and simplify all special values as a wrapper for a getter function.

The record cache may contain regular and special values.  Modify `RecordCache`
so that only methods ending with `_value` check for regular values.  The
dictionary methods considers both regular and special values as equivalent.

    name in record._cache               # test if cache has a value
    iter(record._cache)                 # iterate on values
    record._cache[name]                 # get value
    record._cache.get(name)             # get value or default

    record._cache.has_value(name)       # test if cache has a regular value
    record._cache.get_value(name)       # get regular value or default
2017-09-08 13:21:00 +02:00
Christophe Simonis 99426b95b5 [MERGE] forward port branch 10.0 up to c5df78f38b 2017-09-04 16:15:28 +02:00
Adrien Peiffer (ACSONE) 4ca6945256 [FIX] base: consider materialized view as table
Closes #18442
opw-769167
2017-08-31 15:00:22 +02:00
Christophe Simonis daaaaa552e [FIX] core,test_new_api: adapt code to removal of ir.values 2017-08-31 13:22:39 +02:00
Christophe Simonis 4879ce0407 [MERGE] forward port branch saas-17 up to fe77df3ba4 2017-08-31 12:55:41 +02:00
Raphael Collet 6cf98c4c87 [IMP] models: in onchange, keep track of virtual ids of new records
The x2many "create" command is now like: `(0, ref, vals)`, where `ref` is an
arbitrary reference that may be used to identify a new line in the relation.
The reference is returned in a similar command by the method `onchange`.
`onchange` now supports self-modifying x2many fields.
2017-08-30 14:38:29 +02:00
Christophe Simonis d0f132b297 [MERGE] forward port branch saas-16 up to 4ac347735d 2017-08-28 14:49:11 +02:00
Raphael Collet 10cb1beead [REM] base: remove model ir.values 2017-08-28 09:53:23 +02:00
Raphael Collet 55549f1e61 [ADD] base: direct support for binding an action to a model 2017-08-28 09:53:23 +02:00
Raphael Collet 60d9f6fef9 [ADD] base: model ir.default to store user-defined defaults 2017-08-28 09:53:23 +02:00
Christophe Simonis 017ee5eab3 [MERGE] forward port branch saas-17 up to 877e709871 2017-08-24 13:17:53 +02:00
Raphael Collet 32aa7dc9a0 [FIX] models: implement change_default behavior for fields
The behavior is no longer implemented by the web client.  Implement it
server-side as part of the onchange mechanism, simply by defining onchange
methods for the fields that have the flag.
2017-08-24 09:37:55 +02:00
Christophe Simonis 59f8b849fb [MERGE] forward port branch saas-15 up to d5f2a38b50 2017-08-23 11:23:08 +02:00
Christophe Simonis d5f2a38b50 [MERGE] forward port branch saas-14 up to 6956ad54de 2017-08-22 17:20:15 +02:00
Christophe Simonis 6956ad54de [MERGE] forward port branch 10.0 up to 6dc0f31415 2017-08-22 16:45:43 +02:00
Olivier Dony 695716efb0 [FIX] P3: remove pycompat.{keys,items,values} helpers
Now that we're closer to switching to P3 for good, these helpers have
outlived their usefulness, and mostly add noise.

All remaining dict.iter*() or dict.view*() must be converted to the
normal keys(), values() or items() calls.

Whenever the result is likely to be used for more than the scope of a
loop, or when the dict needs to be modified during iteration, the calls
must be wrapped in a ``list()``, to protect the new P3 semantics.
Those cases are very exceptional.

Also removed some dead code or improved the API to remove unnecessary
conversions.
2017-08-20 23:25:54 +02:00
Xavier Morel a5e21f69e7 [FIX] P3: view arch should be text-'encoded' XML 2017-08-20 23:25:54 +02:00
Xavier Morel 7dd062f835 [FIX] P3: text model types
* remove references to basestring & unicode (use relevant pycompat
  helpers)
* remove some str calls (either entirely or replaced by relevant
  helper, either text or native)
* use better API to avoid unnecessary conversions
* remove some XML declarations in views
2017-08-20 23:25:54 +02:00
Martin Trigaux cf8985e37d [FIX] models: properly format load error
In case of foreign language, using unicode characters, the error message may be
badly formated.

e.g.
Unknown error during import: <class 'odoo.exceptions.AccessError'>: เฉพาะผู้ดูแลร..

insted of
Unknown error during import: <class 'odoo.exceptions.AccessError'>: (u'\u0e40\u0e09\u0e1e\u0e32\u0e30\u0e1c\u0e39

opw-766580
2017-08-18 11:12:16 +02:00
Raphael Collet 8b49007a32 [IMP] avoid one query when recomputing a field (#18846)
Specifically, instead of reading fields on `recs.exists()`, simply read those
fields and catch `MissingError`.  This generates around 5% less queries.
2017-08-16 16:55:09 +02:00
Christophe Simonis 48b2ce60ed [MERGE] forward port branch saas-16 up to 85571bb78c 2017-08-10 17:01:05 +02:00
Christophe Simonis 85571bb78c [MERGE] forward port branch saas-15 up to dde62073ba 2017-08-10 16:22:36 +02:00
Christophe Simonis dde62073ba [MERGE] forward port branch saas-14 up to a2361e23ea 2017-08-10 16:17:28 +02:00
Christophe Simonis a2361e23ea [MERGE] forward port branch 10.0 up to 544aa9b04a 2017-08-10 15:45:07 +02:00
xmo-odoo d140f0ef0e [FIX] prefetch issues on computed/related fields (#18644)
When deciding to prefetch records (getting records from the cache with
no value for the field being fetched), if the field was computed
`determine_value` would just get all records, not limited by the normal
prefetch limit; for large recordsets this would generate gigantic
prefetch lists for records we may not need at all.

Fix by applying the `PREFETCH_MAX` limit to records from the cache as is
done in `_prefetch_field`.

Complementarily, when traversing related fields the prefetch
environment would be lost and every record would get an empty prefetch
environment, so the values would ultimately be read one by one.

Example: select (search) 1000 product.product records, access a
related field (e.g. categ_id) in a loop, on the first iteration the
system would first read 1000 templates, then it would read each
categ_id individually, resulting in >1000 SQL queries rather than the
~2 we would expect.

Fixes #18511
2017-08-10 14:51:27 +02:00
Raphael Collet e25bcf41e2 [REF] models: group recomputation triggers to minimize the number of requests
When several fields are modified and trigger the same recomputations, the same
SQL queries were made to determine the records to recompute, because each field
was processed independently.  In order to avoid duplicated SQL queries, process
the triggers of the modified fields altogether.

This reduces the number of queries by 15% to 25%, depending on the number of
computed fields.
2017-07-10 16:18:33 +02:00
Raphael Collet 439fa82676 [IMP] models: improve code of read()
Remove the `ORDER BY` clause from the query.  The values fetched from the
database are stored in the records' cache, and their ordering is irrelevant.
2017-07-10 15:02:44 +02:00
Raphael Collet ffd93a9937 [REF] models: do vacuum of transient models by cron only 2017-07-10 15:02:44 +02:00
Christophe Simonis bf51fe55a1 [MERGE] forward port branch saas-16 up to 0f2b2c4e2b 2017-07-07 14:30:30 +02:00
Denis Vermylen e0a1549307 [IMP] models: add access_user to get_access_action
In order to be able to identify what action to return based on the
access_user.

Typically portal users will need to be redirected to the front-end,
while internal users will need to be redirected to the back-end.
2017-07-06 12:53:39 +02:00
Denis Ledoux 6078c04266 [IMP] models: allow to use a not automatic create_date field
Without this, you cannot use a `create_date` field
in a model with `_log_access` set to `False`
2017-07-05 13:50:15 +02:00
Christophe Simonis 780ae8a808 [MERGE] forward port branch saas-15 up to 10cb34bcac 2017-07-04 18:14:13 +02:00
Christophe Simonis 10cb34bcac [MERGE] forward port branch saas-14 up to 97258040d8 2017-07-04 14:40:20 +02:00
Christophe Simonis 97258040d8 [MERGE] forward port branch 10.0 up to 657e328903 2017-07-04 13:17:16 +02:00
Nicolas Martinelli c61ae3a3ed [FIX] models: copy field with unique constrain
When a model contains a field translatable which has a unique
constrain, it is impossible to copy a record. Indeed, the unicity
constrain is always triggered, even if the model takes in charge the
overriding of the copy method to avoid duplication.

Introduced with commit ce7f31b0b0, with the goal to target only
XML/HTML translations. We apply this behavior in case of a callable
translate property, to target only the desired problematic use case.

opw-749481
2017-06-30 10:52:15 +02:00
Xavier Morel 5ee9ec7d6c [FIX] P3: __nonzero__ -> __bool__
Also ~removed bool-testing on cursors
2017-06-26 16:45:03 +02:00
Xavier Morel 5810ea2a97 [FIX] P3: random.sample on a recordset
In P3, random.sample requires that its parameter be a Sequence or a
Set. This blows up _cart_accessories.

So opt BaseModel into both ABC, seems to work fine.
2017-06-26 16:45:02 +02:00
Christophe Simonis ed2ddeccdf [MERGE] forward port branch saas-16 up to 1b50c829ef 2017-06-15 18:46:47 +02:00