Commit Graph
11 Commits
Author SHA1 Message Date
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
Xavier Morel 313f69e948 [ADD] doc: JS document extraction system
* Fix a bunch of ill-documented/incomplete/incorrect method docs
* add start of Sphinx extension to extract & integrate jsdoc into
  Sphinx documentation:

  - parse JS files (and don't blow up), uses a fork of pyjsparser as
    the project currently does not parse comments
  - extract cross-module dependency information
  - parse JsDoc comments using pyjsdoc and infer structure from code &
    jsdoc
  - ``ast`` CLI printing a simplified AST of the input files
  - ``dependencies`` creating a dependency graph of either all modules
    in the provided input files or the modules matching the specified
    filters (warning: will not work if missing dependencies),
    generates a .dot file
  - ``extractor`` generating a plain text module documentation (mix of
    rst and markdown styles, not anything formal)
* sphinx extension with an "automodule" directive taking a module name
  and generating the documentation for it
2017-09-18 11:54:36 +02:00
Raphael Collet d7190a3fd0 [IMP] api: reindex the record cache to improve cache hit
The record cache is indexed by `(field, record_id, key)`, where `key` depends
on the environment.  The key is either `(cr, uid, context)` or `(cr, uid)`,
depending on whether the field's value is context-dependent.  As most fields
are not context-dependent, this should avoid some cache prefetching when
swiching context.
2017-09-08 13:21:00 +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 30bd5ac0e9 [MERGE] forward port branch saas-16 up to aec6248bb3 2017-08-23 16:44:58 +02:00
batuto feef39aee0 [IMP] doc: add warning about constrain method trigger
It may be confusing that a constraint is not triggered in a name_create call.
Testing the absence of value should be done in an override of create, not in a
api.constrains.

Closes #18382
2017-08-22 15:46:48 +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
xmo-odoo fffaf735f5 [FIX] P3: list -> iterable builtins (#16811)
In Python 3:

* various builtins and dict methods were changed to return
  view/iterable objects rather than lists
* and the separate Python 2 view/iterable builtins and methods were
  removed altogether

This is problematic when using these items as list (which the happens
repeatedly in Odoo), but more viciously when iterating *multiple times*
over them (which also happens, which I've messed up multiple times while
writing this, and which is a pain to debug even when you've just created
the issue).

Convert all code using these to semantics-matching cross-version
helper functions to get the LCD behaviour between P2 and P3, and
forbid the builtins via lint.

issue #8530
2017-05-10 09:39:55 +02:00
Raphael Collet 4a700d0ad9 [FIX] odoo: rename imports and adapt import hooks 2016-09-02 17:28:12 +02:00
Raphael Collet 9e64f9f951 [REF] openerp: move openerp to odoo 2016-09-02 17:28:12 +02:00