Commit Graph
41 Commits
Author SHA1 Message Date
Raphael Collet b59318ec12 [REF] registry: always perform registry/cache signaling at the end of request
Problem: the update of custom models/fields is not fully transactional, and may
potentially lead to an inconsistent database.  An other problem is creating two
custom fields by writing on a model: if the second one fails, the first one has
been committed without notice.  Retrying the request will give an unexpected
error (duplicate field name).

Solution: never commit in the middle of a request.  If the changes have an
impact on the registry, then mark it as invalid (with a new flag), and signal
registry invalidation after everything has been committed.  If the request
fails, reset the registry.  Both registry and cache invalidation are handled
the same way.
2017-05-03 15:41:05 +02:00
Raphael Collet 1458f1b313 [REF] registry: delegate addition of custom models/fields
Delegate to models `ir.model` and `ir.model.fields`, so that this functionality
can be extended easily.
2017-05-03 15:41:05 +02:00
Raphael Collet f3f41ec551 [REF] registry: replace partial by attribute registry.loaded 2017-05-03 15:41:05 +02:00
Raphael Collet 5d3474254d [REF] registry: remove deprecated RegistryManager 2017-05-03 15:41:05 +02:00
xmo-odoo b4429c2a91 [FIX] Various P3-related import changes
* LDAP import: python-ldap is not python3-compatible, pyldap is

  Warning: only supported from debian Stretch (current testing)?
  https://packages.debian.org/search?searchon=names&keywords=pyldap

* implicitly relative imports
* imports of moved or removed stdlib modules

issue #8530
2017-04-28 09:06:53 +02:00
Christophe Simonis 22e50c66f1 [MERGE] forward port branch saas-15 up to f265359187 2017-04-27 14:56:21 +02:00
xmo-odoo 2e6a589f41 [FIX] builtins removed from Python 3
* Reverse wrapper courtesy of @rco-odoo's original P3 branch
* thin compat module stripped down from werkzeug (to augment as needed)

issue 8530
2017-04-27 13:59:33 +02:00
Christophe Simonis f265359187 [MERGE] forward port branch saas-14 up to bf23946e3d 2017-04-27 13:50:20 +02:00
Christophe Simonis 595b38fbdc [MERGE] forward port branch 10.0 up to 1faa4a74aa 2017-04-27 11:22:56 +02:00
Martin Trigaux 79519ce400 [FIX] registry: load inheritS models too
When adding a field on a model, only the _inherit were checked, not the _inherits.

This commit fixes the following bug:
1. install `sale` (adding the field `sale_order_count` on `res.partner`)
   - field `sale_order_count` is created on `res.partner`
   - the ir.model.field is tagged with module `sale`

2. install `point_of_sale` (adding another field on `res.users`)
   - field `sale_order_count` is created on `res.users`
   - the ir.model.field is tagged with module `point_of_sale`

When installing sale, the model res.partner is returned in the list of impacted
models, on which _create_fields method is called but not res.users.

A direct consequence of this bug is that, the fields translations are in the
wrong module. May fix some uninstallation bugs too.

Closes #16104
2017-04-25 14:20:34 +02:00
Christophe Simonis e92ae40d71 [MERGE] forward port branch saas-15 up to b0992d082d 2017-04-14 13:32:15 +02:00
Christophe Simonis b0992d082d [MERGE] forward port branch saas-14 up to 8f30e707e5 2017-04-13 15:31:27 +02:00
Christophe Simonis 13ad16104a [MERGE] forward port branch 10.0 up to 00e169c05a 2017-04-13 13:22:27 +02:00
Raphael Collet 00e169c05a [FIX] modules: do not log warnings for studio_customization 2017-04-13 12:17:05 +02:00
Xavier Morel 76852a2fad [#8530] fix uses of `reduce` builtin
Demoted to library in Python 3, see if uses can be replaced by more
specific construct, just import functools.reduce otherwise.

Futurize fixers:
* lib2to3.fixes.fix_reduce
2017-04-12 13:48:42 +02:00
Xavier Morel 3979f6802e [#8530] convert exception handlers to except..as syntax
Futurize fixers:
* lib2to3.fixes.fix_except
2017-04-11 14:53:29 +02:00
Christophe Simonis 2df5faa551 [MERGE] forward port branch saas-14 up to 2f68e9e93a 2017-03-28 18:05:31 +02:00
Raphael Collet c9edb9dccb [FIX] registry: use a weak dictionary for model_cache to avoid memory leaks
The class attribute `model_cache` refers to model classes, which refer to their
own registry.  This cache potentially keeps all past registries alive!
2017-03-21 15:50:20 +01:00
Raphael Collet d024c76021 [REF] tools: add functions for SQL schema manipulation
This helps factoring out a certain number of similar queries, and removing a
few methods from `BaseModel`.
2017-02-22 15:24:07 +01:00
Raphael Collet 8225f36497 [IMP] models: speed up schema update for models
Simply remove most `commit()` statements from code that updates the database
schema.  This improves the performance of the schema update by 30%.
2017-02-22 15:24:06 +01:00
Raphael Collet daa1eb1fc4 [IMP] base: remove ir_model_* tables from base.sql 2017-02-22 15:24:05 +01:00
Raphael Collet b6103d0b1b [REF] models: foreign keys use Registry.post_init() instead of BaseModel._auto_end()
Also use Registry.post_init() for the creation of foreign keys in
`_sql_constraints`.
2017-02-22 15:22:26 +01:00
Raphael Collet a1d061080e [REF] models: improve the API for post-init functions
Add a method to the registry to register function calls that must be done after
methods `_auto_init` and `init` have been invoked on all models.
2017-02-22 15:22:26 +01:00
Christophe Simonis a282d4ae7f [MERGE] forward port branch saas-14 up to be9dfb331f 2017-02-10 18:41:06 +01:00
mge-odoo ff2f188d20 [IMP] tests: allow post-install tests to play real transactions
Move the post-install tests execution outside `Registry.new`, and add a flag on
class `HttpCase` to enable/disable the registry "test mode".

This allows a test to run actual transactions that will reload the registry,
which may be used to test the creation of `ir.model` instances, etc.
2017-02-08 16:13:01 +01:00
Olivier Dony 8235f03f56 [FIX] module: allow disabling 1-click install
As discussed on issue #15225, it should be possible for system administrators
to disable the 1-click installation system.
The plan is to disable the feature by default, but make it relatively easy
to turn on when it is explicitly desired.

1. At the moment we cannot guarantee that all Apps published on the Odoo Apps
   Store are safe. And it is a security risk to let end-users deploy Python
   code on their Odoo servers without requiring any review/deployment by a
   competent system administrator.
   We will work on improving the validation process of the Store, but this
   will require time, and won't probably be a 100% safe process in any case.
2. The one-click install feature is however really useful to help
   non-technical users install Apps, as long as the feature has been
   explicitly allowed by the system administrator. This is a common feature
   in other software suites as well. So we'd like to keep it as an opt-in
   feature.
3. Administrators of multi-tenant servers, cloud hosting services, etc.
   understandably expect to be able to turn off the feature for
   security/control reasons.
4. By turning off the feature by default, but still exposing it in the UI,
   we keep it *discoverable* for users. The error message should be
   helpful to direct users to their sysadmins.
5. By using the permissions of the download folder as a flag for turning
   off the feature, we avoid introducing an extra server parameter.
   The folder is still created (read-only) by default, for the sole purpose
   of making it easier to locate.

Fixes #15225
2017-01-27 13:56:05 +01:00
Christophe Simonis 98c71b23d3 [MERGE] forward port branch saas-11 up to 9073ecb6f5 2017-01-06 18:06:14 +01:00
Christophe Simonis 799e7f7740 [FIX] core: leftover openerp use from last forward-port 2017-01-04 19:24:16 +01:00
Christophe Simonis 2217b37130 [MERGE] forward port branch saas-11 up to 573293a06d 2017-01-04 19:15:31 +01:00
angelfentanez e965ac14dd [FIX] modules: add missing parameter to find_module
AddonsImportHook's find_module method to follow PEP302 by setting None as
default for the path parameter
Similar to edeb5a8c

Fixes #14087
Closes #14088
2016-11-22 14:51:05 +01:00
Raphael Collet f825f415f8 [FIX] registry: ensure that all non-abstract models have a table (#14194)
After modifying the database schema, if some models do not have a table/view,
attempt to recreate it by calling their method `init()`, following inter-model
dependencies.

Fix the model `board.board` by making it an abstract model.

Add the missing model dependencies on report `crm.partner.report.assign` to make
it depend on report `account.invoice.report`.
2016-11-10 13:50:04 +01:00
=?UTF-8?q?St=C3=A9phane=20Bidoul=20=28ACSONE=29?= 389c2ba97b [REF] packaging: make odoo a namespaced package
by auto-extending addons path with odoo.addons.__path__.

This patch also introduce
  * an explicit declaration of odoo.addons as a namespace package
    This is necessary because the standard way of declaring namespace
    packages in setup.py does not work as long as odoo/__init__.py
    contains code.
  * a more reliable way to find odoo root path.
2016-09-30 12:05:49 +02:00
Raphael Collet 979c553918 [IMP] base: refactor _instanciate on ir.model to make it extendable 2016-09-28 16:55:51 +02:00
Christophe Simonis 09c2e4a5bc [FIX] core: fix registry initialisation
Registry.init_models now expect a list of model names instead of the
models themself.
2016-09-22 16:15:26 +02:00
Christophe Simonis 856476d441 [MERGE] forward port branch saas-12 up to b1b700a 2016-09-22 15:23:45 +02:00
Christophe Simonis a256e1ed34 [FIX] core: adpat 9874892b9 to multiple manifest files 2016-09-16 11:34:22 +02:00
Christophe Simonis f4fc3985b6 [MERGE] forward port branch saas-12 up to 10cde43 2016-09-16 11:03:50 +02:00
Olivier Dony 4339196e52 [IMP] support v10 manifest file naming convention
- As of v10, manifest files should be named `__manifest__.py`
- For backwards-compatibility, __openerp__.py manifest files
  will still be supported for the time being
- Limited refactoring, to add support for the 2 different
  naming conventions
- All textual references to __openerp_.py updated in
  documentation and examples
2016-09-05 11:57:50 +02:00
Olivier Dony c0566b2896 [IMP] module: parse manifest files with literal_eval
Manifest files are literal Python dictionaries, and
aren't supposed to contain expressions that require
a full-fledged eval.
`literal_eval` is therefore sufficient *and* safer.

This parsing method was already used when listing addons
during startup of the Root controller (http.py, load_addons())
2016-09-05 11:57:50 +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