Commit Graph
372 Commits
Author SHA1 Message Date
Jairo Llopis ee365bbf98 [FIX] modules: choose the right addons path
When launching a server with two similar addons path, e.g.:
- /home/alice/dev
- /home/alice/devodoo

launching the server in dev mode may crash due to the poor matching using
`path.startswith(...)` method which may make `/home/alice/devodoo/bob/main.xml`
match in addons folder `/home/alice/dev` and with a non-exitant local path
`odoo/bob/main.xml`.

Instead of relying on the name, use the `os.path.commonprefix()` method to match
on real paths and avoid partial matching.
commonprefix will only work if the folder name ends with the appropriate
separator (which is not guarantee for a user provided addons-path) so force a
trailing `/` using os.path.join(..., '')`.

Closes #12359
2016-07-12 17:21:50 +02:00
Christophe Simonis 87d160a742 [FIX] models: partial loading of manual fields
Related and function manual fields may not be loadable during initial
setup (partial=True) due to dependencies being not loaded. Ignore
theses fields during partial loading.
2016-04-11 14:52:42 +02:00
Christophe Simonis 9e2de9b1ae [MERGE] forward port of branch saas-6 up to 7f5ca1d 2016-04-05 19:04:36 +02:00
Christophe Simonis 7f5ca1d94a [MERGE] forward port of branch 8.0 up to ceb87b7 2016-04-05 18:59:00 +02:00
Alexandre Fayolle cc60504bff [FIX] base: only run postinstall tests for installed or updated modules
Uninstalled modules are skipped with the filtering on the state.
Fixes #9768, Closes #11378
2016-04-04 14:32:20 +02:00
Christophe Simonis 53742a4a70 [FIX] core: parent store compute on registry loading
When loading the registry, the parent store are defered at the end of
the registry initialisation. However, when modules should be removed, a
brand new registry is build without deleted modules, losing the list of
models on which parent store should be recomputed.
2016-02-23 18:10:53 +01:00
Denis Ledoux a842199687 [MERGE] forward port of branch saas-6 up to 2616def 2016-01-29 12:29:17 +01:00
Denis Ledoux 2616defe35 [MERGE] forward port of branch 8.0 up to edeb5a8 2016-01-29 11:41:24 +01:00
xmo-odoo edeb5a8c0f [FIX] module finder path parameter should be optional
According to PEP302, the signature of `Finder.find_module` should be 
`find_module(fullname, path=None)`.

Ever since it was introduced in 64ec5f36df the addons import hook 
defines the second parameter as mandatory, which is an issue for
systems relying on the specified behaviour (and not needing to
provide a path) like the stdlib's `pkgutil.find_loader`.

fixes #10670
2016-01-29 10:20:08 +01:00
Olivier Dony dde3432fb2 [FIX] res.lang: do not leak load_language global
During database creation via the database manager,
or when using the startup option `--load-language`,
the selected language(s) will be installed as soon
as either:
 - the base module is installed/updated (because
base_data.xml includes a call to res.lang.install_lang()
 - the registry is loaded (after loading `base`,
the system installs the requested languages, even
if the server is not in update/install mode)

This is implemented by passing a global config
option `load_lang

This behavior was modified as of saas-7 by PR
for the command-line and for the database manager.

In both cases, we don't want the installation
to be repeated the next time either of these
event occur. Essentially the `load_language`
2015-12-14 10:24:59 +01:00
Olivier Dony e62b9e7c93 [FIX] registry: explicitly log registry loading errors
In case the caller happens to silently catch
the exception, leading to hard-to-diagnose
registry/routing problems.
2015-12-14 10:24:59 +01:00
Raphael Collet ac98af1e9f [IMP] models: recompute fields following a topological order on their dependencies
The goal is to avoid recomputing field several times.  Consider, for instance,
two fields F and G, such that G depends on F.  Suppose that G is recomputed
before F.  Saving G to database proceeds well, but when F is saved to database,
G is invalidated and marked for recomputation.  Field G is possibly recomputed
twice on some records.

Avoid this situation by chosing a field such that none of its dependencies must
be recomputed; use a topological sort based on field dependencies for that
purpose.  In the example above, G will never be recomputed before F.
2015-10-13 14:49:57 +02:00
Géry Debongnie 673f4aa4a7 [FIX] bus: disable longpolling in test mode
In test mode, only one cursor is available, and longpolling will take
it, and not give it back before 60s, causing a phantomjs timeout.  This
commit simply return an error when the server is in test mode.

Sadly, I had to patch the web client to prevent logging the error in
this case, because that's the way phantomjs detect if there is a
problem.
2015-10-01 14:00:20 +02:00
Raphael Collet 50f19afd9e [FIX] models: process the new-API fields to recompute in batch
When a new field has to be computed for the first time on existing records,
mark that field as todo, invalidate it in cache, and perform all recomputations
at once at the very end.
2015-09-29 14:14:48 +02:00
Leonardo Rochael Almeida 06b3026bcd [IMP] unittest2 > unittest
The `unittest2` package is simply a backport of `unittest` from the
Standard Library of Python 2.7 to previous versions.

There is no reason to use it any longer.

Closes #6941
2015-09-28 10:37:27 +02:00
Cedric Snauwaert f6054e8937 [FIX] module: move the process of loading translation before the post_init_hook and tests phase 2015-09-21 11:38:08 +02:00
Olivier Dony a3732aef6e [LEGAL] Switch to LGPLv3 License
99% of the contributors have signed the CLA
The rest of them have been contacted by email
and are free to either sign the CLA or ask
for their contributions to be removed from
Odoo Community Edition.

See also:
- https://www.odoo.com/cla
- https://www.odoo.com/blog/odoo-news-5/post/adapting-our-open-source-license-245
2015-09-08 17:58:38 +02:00
Yannick Tivisse e4be39cdde [IMP] openerp: Add authors 'Odoo SA' and website 'http://www.odoo.com'
in 'load_information_from_description_file' method
2015-08-20 16:03:42 +02:00
Raphael Collet 69f7f1c9ee [IMP] models: share fields across registries when possible
When a model is set up, it can retrieve fields from a similar model (with the
same base classes).  Only proper (not inherited), regular (non-related) fields
can be shared that way, since other fields may depend on other models.
2015-08-13 10:45:00 +02:00
Christophe Simonis 95ac2cfd10 [MERGE] forward port of branch saas-6 up to be58335 2015-08-06 16:09:19 +02:00
Antony Lesuisse e7e452f38c [IMP] ir.ui.menu more cleanups
- remove deprecated tree_but_open ir.values
- remove magic ir_ui_menu delete at loading
- remove unused icon and web_icon_hover
2015-08-02 14:10:24 +02:00
Christophe Simonis d38359821c [MERGE] forward port of branch 8.0 up to 030b157 2015-07-30 11:38:01 +02:00
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
Thomas Groutars 5c0bfaafd1 [IMP] ir_model: enable the creation of transient custom models
Rename the field 'osv_memory' on 'ir.model' into 'transient', and make it a
regular field instead of a computed one.  When instantiating a custom model,
use its value to make transient models.

This commit alone will make your server crash on an existing database.  A small
database migration is needed: simply add a boolean column `transient` (with
default value false) in table `ir_model`.
2015-06-15 12:19:52 +02:00
Olivier Dony 0bd4545348 [LEGAL] Use global LICENSE/COPYRIGHT files, remove boilerplate text
- Preserved explicit 3rd-party copyright notices
- Explicit boilerplate should not be necessary - copyright law applies
  automatically in all countries thanks to Berne Convention + WTO rules,
  and a reference to the applicable license is clear enough.
2015-06-02 03:16:04 +02:00
Christophe Simonis fe2b5f35a4 [MERGE] forward port of branch saas-6 up to bf1e999 2015-05-28 14:27:38 +02:00
Raphael Collet 8db2833a1e [IMP] ir_ui_menu: make it use ormcache instead of a home-brewed cache 2015-05-19 10:07:02 +02:00
Raphael Collet 4b7dd0f759 [IMP] decimal_precision, ir_rule, ir_ui_view: simplify ormcache invalidation
The patch speeds up the cache invalidation in the registry, and make most
models use the generic method `clear_caches` instead of specific `clear_cache`
methods.
2015-05-19 09:59:42 +02:00
Christophe Simonis 0da722aa6a [MERGE] forward port of branch 8.0 up to bff6dff 2015-05-11 15:12:24 +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 3206a35aed [MERGE] forward port of branch 8.0 up to 8ac8281 2015-04-13 12:07:58 +02:00
Olivier Dony fd73263c51 [FIX] tests: clear ormcache at teardown, to avoid side-effects between tests 2015-04-10 18:23:32 +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
Christophe Simonis fb8b970567 [MERGE] forward port of branch 8.0 up to 0ed63d7 2015-03-23 16:35:03 +01: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
Olivier Dony 95a2f8b121 [MERGE] Forward-port latest bugfixes from 8.0 up to cbb51610ee 2015-02-24 14:47:19 +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
Christophe Simonis fa75094e6f [MERGE] forward port of branch 8.0 up to 4af53de
ignore .po and .pot changes
2015-02-03 18:47:42 +01:00
Samus CTO 7126ae8143 [FIX] mail: prevent sending mail during registry loading 2015-01-28 16:17:43 +01:00
Christophe Simonis 4ccca49d34 [MERGE] forward port of branch 8.0 up to 592f1cd 2015-01-21 12:11:38 +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
Christophe Simonis 18e22be138 [MERGE] forward port of branch 8.0 up to 0aab81c 2015-01-19 17:15:56 +01:00
Goffin Simon 0fd773a486 [IMP] Cleanup and refactoring of exception handling
Unify and refactor exception handling in framework and addons.

The generic `except_osv` is now deprecated, and replaced by more specialized exception subtypes:
 - `UserError` (renamed from Warning, as it conflicts with the built-in `Warning`) raised when a non-technical error occurs during a business operation. It could be a missing information in the data provided by the user, or a misconfiguration.
 - `AccessError`: raised when any operation is denied because the user conducting it does not have the required access rights.
 - `AccessDenied`: raised when an operation that requires authenticated access is attempted via an unauthenticated request.
 - `MissingError`: raised when an operation is attempted on a record that does not exist.
 - `ValidationError`: raised when an operation violates a SQL or Python constraint.
 - All other exceptions are internal errors due to a system problem or bug, and raised untouched to the client-side, which should display a traceback.

All exceptions take a single message argument.

The `test_exceptions` module has been updated to showcase both new and old (deprecated) exceptions.

A great many old `except_osv` had a useless title with "Error!" or "Warning", those have been removed, as this is handled by the client-side widget that displays the messages.

This commit introduces a more consistent policy for logging errors and warnings:
 - All messages that do not require administrator attention should be logged at INFO level or lower. This includes all errors that are notified to the user in a friendly manner, even for access right problems or validation errors during business operations.
 - All messages that indicate a likely misconfiguration or malicious use by the users should be logged at WARNING level, as they typically require administrator attention.
 - All other unhandled internal errors cannot typically be handled by the user and should be logged at ERROR or higher level, as they require immediate administrator attention.
2015-01-16 17:15:18 +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
Christophe Simonis fab4d6d442 [MERGE] forward port of branch 8.0 up to ea54d4a 2015-01-06 11:49:04 +01:00
Leonardo Donelli 4a0b13ed92 [REF] remove vim modelines and resulting trailing blank lines
Let 2015 be a year without modelines!
cf #4174
2014-12-31 15:52:13 +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