Commit Graph

325 Commits

Author SHA1 Message Date
Christophe Simonis ecfaf213c4 [FIX] module loading: pre/post_init_hook execution
New installation was detected using the `installed_version` attribute
(`latest_version` in `ir_module_module` table), but this field wasn't
reset at module uninstallation (now fixed by cb29f9e) avoiding
execution of hooks.

Same logic was applied for migration scripts at 8ff7230.

Fixes #7708
2015-07-29 12:30:14 +02:00
Raphael Collet 3e497ea35f [FIX] registry: recompute `pure_function_fields` after every setup
The lazy property `pure_function_fields` was not invalidated upon every setup
of models, and hence could contain old instances of fields.  As every model
setup re-creates instances of fields, the property has to be recomputed.
2015-05-06 09:11:53 +02:00
Christophe Simonis 14fd77c132 [FIX] core: ormcache is now per regisry.
A cross-registry cache was introduced by e2ea691ce.
The initial idea was praiseworthy but sub-optimal for servers with a
lot of registries.
When there is lot of registry loaded, the cache size was huge and
clearing some entries took a lot of CPU time, increasing the chances
of timeout.

Also, the cache was not cleaned when a registry is removed from
registry LRU (this operation would also consume time).
2015-04-03 16:11:57 +02:00
Raphael Collet b156c2e27e [IMP] registry: adapt LRU sizes for registries and ormcache
The registry size is now assumed to be around 10Mb, and ormcache size is
proportional to the maximum number of registries.  Statistics about ormcache
usage is shown to the log when receiving signal SIGUSR1.
2015-03-23 14:36:15 +01:00
Raphael Collet e2ea691cef [IMP] ormcache: turn it into a global LRU cache shared among registries
The ormcache is now shared among registries.  The cached methods use keys like
(DBNAME, MODELNAME, METHOD, args...).  This allows registries with high load to
use more cache than other registries.
2015-03-23 14:36:14 +01:00
Jeremy Kersten 0c964f0b7b [TYPO] modules: better safe than sorry
Too many people copy-past this line without understand !
2015-02-23 20:15:57 +01:00
Samus CTO 7126ae8143 [FIX] mail: prevent sending mail during registry loading 2015-01-28 16:17:43 +01:00
Raphael Collet cf26f7ed80 [IMP] models, registry: let the registry retrieve manual fields from database 2015-01-21 11:26:23 +01:00
Raphael Collet 5d7bba4eb7 [FIX] loading: move code that should not be executed on simply installed modules 2015-01-21 11:26:23 +01:00
Raphael Collet 5fee95ca63 [FIX] models, fields: reorganize model setup to retrieve all inherited fields
The model setup sometimes misses entries in _inherit_fields and _all_columns.
This is because those dictionaries are computed from parent models which are
not guaranteed to be completely set up: sometimes a parent field is only
partially set up, and columns are missing (they are generated from fields after
their setup).

To avoid this bug, the setup has been split in three phases:
(1) determine all inherited and custom fields on models;
(2) setup fields, except for recomputation triggers, and generate columns;
(3) add recomputation triggers and complete the setup of the model.

Making these three phases explicit brings good invariants:
- when setting up a field, all models know all their fields;
- when adding recomputation triggers, you know that fields have been set up.
2015-01-21 11:26:23 +01:00
Xavier Morel 9808ca3e31 [IMP] test discovery, documentation, deprecation warnings
* document and warn that checks and fast_suite in tests sub-packages are
  deprecated and have no effect
* avoid iterating all currently loaded modules when looking for test
  modules in a tests sub-package
* replace use of __import__ by importlib

Fixes #3152
2015-01-15 13:28:25 +01:00
Raphael Collet d9fedfebbd [IMP] registry loading: setup models only if necessary
When loading the registry without any module installation/upgrade, models are
set up once instead of twice.  In other cases, models are always set up before
installations/upgrades.
2014-12-19 13:57:08 +01:00
Raphael Collet 8f38a7806a [IMP] enable loading custom models/fields and views from module data files
Loading views for custom models from module data files was not possible because
custom models and fields were introduced into the registry after all modules
were loaded.  As a consequence, the view architecture did not pass the checks.

This patch takes a different approach: custom models and fields are loaded
early on in the registry, so that views can be validated.  The trick is to take
special care of relational custom fields: we skip them if their comodel does
not appear in the registry.  This allows to install and upgrade modules that
create/modify custom models, fields and views for them.
2014-12-19 13:57:08 +01:00
Raphael Collet 7afbb0a7ed [IMP] module/loading: do not try to load module graph when nothing to load
This simple optimization in load_marked_modules() avoids unnecessary calls to
load_module_graph().  This provides a small speedup, and avoids confusing log:
some module updates were making it look like the registry was loaded 5 times
instead of once.
2014-12-15 14:51:18 +01:00
Christophe Simonis 6bbc21b906 [FIX] graph.py: correct Node() creation.
Fixes #3730
2014-11-19 15:14:14 +01:00
Olivier Dony c87b9c6539 [FIX] decimal_precision: avoid refreshing float precisions at each cache invalidation
Changing the decimal precision of float fields is a rare
operation, while cache clearing occurs fairly frequently.
Signaling a full registry change when the decimal precision
is changed (instead of a mere cache change) is therefore
a better trade-off, and more semantically correct as well.
This way we avoid the decimal precision refresh for each
invalidation.

Registry invalidation implies cache invalidation.
2014-11-19 12:53:58 +01:00
Raphael Collet e038fec696 [IMP] models: improve performance of _setup_fields()
There was an issue in _setup_fields(): the method invokes _inherits_reload(),
which recomputes inherited fields, and invokes itself recursively on children
models.  This may be problematic if the children models have already been set
up.

This optimization avoids recursive calls of method _inherits_reload().  In
_setup_fields(), first all parent models are set up, then their fields are
inspected to determine inherited fields, and their setup is done.  This scheme
guarantees that inherited fields are computed once per model.
2014-11-13 14:54:04 +01:00
Christophe Simonis cc4fba6089 [IMP] core: manage registries via an LRU.
When working with a large number of databases, the memory allocated to
registries wasn't limited, resulting to waste memory (especially in the
longpolling worker, which is not recycled).
The size of the LRU is depending on the soft limit configured for
workers.
2014-10-29 18:28:07 +01:00
Christophe Simonis 8ff7230e2d [FIX] migration: test if package is installed using its state.
checking if there is an installed version set is not enough because this field is not reset when the module is uninstalled
2014-10-07 14:57:26 +02:00
Denis Ledoux 1c6c289f7b [FIX] api: clear environments on module installation 2014-10-02 17:46:25 +02:00
Christophe Simonis a1eb27b8ef [FIX] migration: allow debugging of migration scripts + avoid useless copies 2014-10-01 16:34:13 +02:00
Thibault Delavallée 7cad4baa84 [FIX] [CLEAN] Various: fixed / cleaned use of dict.fromkeys.
Indeed using fromkeys with a list / dict as argument leads to the creation
of shared list / dict. This could create some ugly side effects when
used in loops. This commit fixes or cleans this kind of statement to avoid
unwanted side effects.
2014-09-18 11:18:30 +02:00
Raphael Collet 764c5acd81 [IMP] fields: reset decimal precision on new-style fields
When a decimal_precision record is created/modified, the float fields of the
models in the registry must be reset.  This was done on old-API columns only.
It is now handled by the new-API fields.
2014-09-18 11:11:19 +02:00
Olivier Dony e5bff82aff [MERGE] Forward-port saas-5 up to f9bcd67 2014-09-17 16:39:06 +02:00
Olivier Dony c926b54a49 [MERGE] Forward-port saas-3 up to 09ab2d4 2014-09-17 15:16:30 +02:00
Olivier Dony 09ab2d4109 [MERGE] Forward-port 7.0 up to 938502a 2014-09-17 15:13:42 +02:00
Olivier Dony 938502aa37 [FIX] loading: always process auto-installed modules for new databases
If the server was started without -i or -u and
happened to initialize a fresh database,
auto-installed modules that depend
on `base` only would stay in status "to install"
without actually being installed (until the next
installation round was triggered).
This was of little consequence in 7.0, but causes
a crash in 8.0.

Fixes #953
2014-09-17 15:11:01 +02:00
Daniel Reis ec0b770ed3 [IMP] modules: add support for loading module description from README.{md,rst,txt}
Showcase the feature by moving auth_ldap's description to README.rst

(Manual rebase of PR #1759)
2014-09-12 18:31:32 +02:00
Raphael Collet 2ad092b5e5 [ADD] doc: new documentation, with training tutorials, and new scaffolding 2014-08-22 17:51:20 +02:00
Raphael Collet 2d2274aeed [FIX] module loading: manual x2x fields can now refer to manual models
The fix consists in this: when setting up models, ignore manual fields that
refer to unknown models if all models have not been loaded yet.
2014-08-04 15:10:12 +02:00
Xavier Morel 92be431236 [REM] asynchronous database creation method
It's broken (though easy to fix) and not very useful, if third parties want to
create databases asynchronously they can handle the asynchronicity on the
client-side (an HTTP request is easy to make asynchronously after all) and
call the synchronous `create_database()`.

fixes #1137, after a fashion
2014-07-15 12:26:55 +02:00
Christophe Simonis e5b0933743 [FIX] data-dir management
- sessions are now shared between series.
- use site data dir instead of user data dir if user has no home dir.
- in http and module handling, `data-dir` was used before being
initialized, using the default value instead of user input

(fixes #308, #904)
2014-07-07 15:49:24 +02:00
Raphael Collet cbe2dbb672 [MERGE] new v8 api by rco
A squashed merge is required as the conversion of the apiculture branch from
bzr to git was not correctly done. The git history contains irrelevant blobs
and commits. This branch brings a lot of changes and fixes, too many to list
exhaustively.

- New orm api, objects are now used instead of ids
- Environements to encapsulates cr uid context while maintaining backward compatibility
- Field compute attribute is a new object oriented way to define function fields
- Shared browse record cache
- New onchange protocol
- Optional copy flag on fields
- Documentation update
- Dead code cleanup
- Lots of fixes
2014-07-06 17:05:41 +02:00
Antony Lesuisse ed34640d3a [IMP] test display sql query counter 2014-07-01 21:57:55 +02:00
Antony Lesuisse 78e044b5c7 [IMP] test impprove HTTPCase opener
Simplify website crawler using the generic HTTPCase opener
2014-06-29 20:04:30 +02:00
Antony Lesuisse f9e24e1918 [IMP] module loading and tests profiling
Add a loglevel 25 to log some INFO to runbot
Add timers for loading and testing
Silence empty test suite
ir_logging use relative pathname, warning this doesnt work for --addons-path modules yet.
2014-06-29 18:58:15 +02:00
Christophe Simonis 1f57528bc6 [MERGE] forward port of branch saas-5 up to 8dfd5ea 2014-06-27 16:14:40 +02:00
Christophe Simonis a4bc65cdba [MERGE] forward port of branch saas-3 up to bdc4dd4 2014-06-27 16:06:37 +02:00
Christophe Simonis bdc4dd4a65 [MERGE] forward port of branch 7.0 up to 95cff0b 2014-06-27 16:00:28 +02:00
Christophe Simonis 4cd699df15 [IMP] js testing
- output "error" if any qunit tests failed
- failed js tests are logged as errors
- when running phantomjs considere empty waiting condition or initialisation code as "true"
- lint phantomtest.js file
2014-06-22 11:31:07 +02:00
Yann Papouin 2c28adaade Overwrite translation on module update if option is set
Launchpad bug: https://bugs.launchpad.net/ocb-server/+bug/1319285
2014-06-20 11:48:18 +02:00
Xavier Morel 64762086b8 [IMP] unpack a listcomp in a dict passed to an update, pass gencomp directly to update 2014-06-20 07:52:42 +02:00
Christophe Simonis 4105b5f028 [ADD] module install/uninstall hooks.
Since 4ec71c74d1, migration scripts
are not executed at module install anymore.
As this behavior was missused as "init" scripts (see [1]), this
commit re-add this possiblity via hooks.

There are 3 hooks that can be declared in the manifest file:
 - pre_init_hook: called before module installation
 - post_init_hook: called after module installation
 - uninstall_hook: called before module uninstallation

Like the "post_load" manifest option, the values for these hooks
must be a string containing the name of a method available at the
module root.
The signatures of these functions are:
 - (cr) for pre_init_hook
 - (cr, registry) for post_init_hook and uninstall_hook

[1] https://bugs.launchpad.net/openobject-server/+bug/1314680
2014-06-07 00:41:29 +02:00
Fabien Meghazi faa60474ce Allow initialize_sys_path() to be called more than once 2014-05-30 18:25:05 +02:00
Fabien Meghazi 0e01164842 Moved get_module_root in openerp.modules.module 2014-05-29 18:23:48 +02:00
Martin Trigaux 5e406734ab [FIX] module: do not crash in case of not found module
bzr revid: mat@openerp.com-20140505121840-f84u36mng3p1gstn
2014-05-05 14:18:40 +02:00
Christophe Simonis c3cf8000e6 [FIX] module loading: mark module as initialized *after* the data files have been loaded
When the registry is updating, the view verification only validates the views 
from initialized modules. Not taking the current module allow update of views
that have also an inherited view in the same module. The verification of the base view
must not try to apply the old inherited view against it as it may not be applicable
anymore. 

After module update, we re-validate all the views of this module. This is needed because
a module can declare two (or more) inherited views that are correct when applyed alone,
but not when combined with others.

bzr revid: chs@openerp.com-20140418141550-7b57b1xl4fx0rgqq
2014-04-18 16:15:50 +02:00
Raphael Collet ea167ad7ab [IMP] test cursor: code cleanup to make it more robust to concurrent accesses
bzr revid: rco@openerp.com-20140414075906-2d0i4qhe4x7czsao
2014-04-14 09:59:06 +02:00
Raphael Collet be0096c4a7 [FIX] registry: stupid typo
bzr revid: rco@openerp.com-20140409135225-6ks1kbuchba7u4li
2014-04-09 15:52:25 +02:00
Raphael Collet 980f6fc4b1 [IMP] registry: avoid every direct access registry.db, and rename attribute as registry._db
bzr revid: rco@openerp.com-20140409133515-x2ywcm0d2qkdq3hq
2014-04-09 15:35:15 +02:00