summaryrefslogtreecommitdiff
path: root/odoo/modules/loading.py
AgeCommit message (Collapse)Author
2018-11-22[FIX] odoo: ormcache invalidation on loading registryRaphael Collet
Do not propagate cache invalidations to other workers when simply loading the registry. Only do it when installing/upgrading/uninstalling modules.
2018-10-19[FIX] loading: set dbdemo if demo install successAdrian Torres
opw-1896028 closes odoo/odoo#27945
2018-09-25[FIX] ir_ui_view: do not check arch twice upon install/upgradeRaphael Collet
After a module upgrade, validate the architecture of the module's views that are impacted by updates, but have not been checked yet. Before this patch, views were checked twice on average. This patch speeds up the installation of modules by about 15% without demo data. With demo data, the speedup is around 10%.
2018-09-24[IMP] core: require install mode for db bootstrapOlivier Dony
The registry loading system should not alter databases unless it is asked to do so, by a module installation or update instruction. This property should hold true as well for database bootstrap, and this is what this commit changes.. In order to avoid any behavior change for command-line users, an implicit `-i base` is assumed when starting the server from the command-line with `-d <db>`, causing the db boostrap to happen if the database did not exist yet.
2018-08-01[MERGE] forward port branch saas-11.4 up to 8d9366197e1Christophe Simonis
2018-07-23[MERGE] forward port branch 11.0 up to 219d2296d67Christophe Simonis
2018-07-23[MERGE] forward port branch saas-15 up to c4ee29345a6Christophe Simonis
2018-07-23[MERGE] forward port branch saas-14 up to 9ee882564f6Christophe Simonis
2018-07-23[MERGE] forward port branch 9.0 up to af2e480e419Christophe Simonis
2018-07-16[IMP] base: disable demo data if they can't installXavier Morel
Task 1856935 Currently, if installing a module's demo data fails (because the module was uninstalled and some were left over and can't be reinstalled, or because they're broken, or…) the installation of the module fails and further installations are skipped (?). Since demo data are non-essential (though required to run tests), rather than fail everything if they fail just roll them back and notify the user. This change generates a warning log *and* shows a notification popup to the end user.
2018-07-16[IMP] de-commit-ify db/module installXavier Morel
Try to remove cr.commit (and rollback) from module and db install: * put a savepoint around test data loading * remove a bunch of commits sprinkled throughout * remove rollback on data loading failure (assuming it bubbles up, the entire module's installation should be rolled back) * add commit right before the tests are run, so they can run isolated and still see whatever was done when installing their module * convert a few explicit closing to context managers
2018-07-11[IMP] allow installing demo data post db initAdrian Torres
Intended for demo / throwaway databases only Task-ID: 1856493
2018-07-05[MERGE] forward port branch 11.0 up to 84210074e55Christophe Simonis
2018-07-05[MERGE] forward port branch saas-15 up to b06c09db604Christophe Simonis
2018-07-05[MERGE] forward port branch saas-14 up to 92e5da6b8fdChristophe Simonis
2018-07-05[MERGE] forward port branch 9.0 up to b5c50fa824aChristophe Simonis
2018-06-05[MERGE] forward port branch 11.0 up to 1b272a20504Christophe Simonis
2018-06-05[MERGE] forward port branch saas-14 up to a002210d930Christophe Simonis
2018-06-05[FIX] orm: re-create constraints of extended fieldsAdrian Torres
Before this commit: * Module A defines a field X of model M * Module B inherits from model M without touching field X * Module C inherits from model M and extends field X by giving an INDEX / NOT NULL constraint. * Module B and C depend from Module A, but not each other If all three modules are installed and Module B is updated, the INDEX / NOT NULL constraint could be dropped. This happens because Module B can be loaded before Module C is loaded, if that's the case, then after the upgrade of Module B, during the schema checking, we verify that the field object we have and the field on the DB are the same, since Module B doesn't introduce the index then this check is false and we drop the index. When we get to loading Module C, we do not do any schema checking because the module is not marked as `to upgrade`, therefore the index is lost forever. To solve this, we re-init the models that belong to the set of the intersection between upgraded and modified models and loaded and modified models. Fixes #24958
2018-06-01[FIX] orm: re-create constraints of extended fieldsAdrian Torres
Before this commit: * Module A defines a field X of model M * Module B inherits from model M without touching field X * Module C inherits from model M and extends field X by giving an INDEX / NOT NULL constraint. * Module B and C depend from Module A, but not each other If all three modules are installed and Module B is updated, the INDEX / NOT NULL constraint could be dropped. This happens because Module B can be loaded before Module C is loaded, if that's the case, then after the upgrade of Module B, during the schema checking, we verify that the field object we have and the field on the DB are the same, since Module B doesn't introduce the index then this check is false and we drop the index. When we get to loading Module C, we do not do any schema checking because the module is not marked as `to upgrade`, therefore the index is lost forever. To solve this, we re-init the models that belong to the set of the intersection between upgraded and modified models and loaded and modified models. Fixes #24958
2018-03-20[MERGE] forward port branch 11.0 up to 2835d299792Christophe Simonis
2018-03-13[FIX] registry, loading: re-init inherited SQL viewsAdrian Torres
Before this commit: * Install any module that creates a SQL view and another that extends this view. e.g.: sale and pos_sale for `report.all.channels.sales`. * Uninstall the module that extended the SQL view. e.g.: uninstall pos_sale. * Try to access the view from the web client -> Traceback, table not found. This happens because when reloading the registry, postgres drops the sql view and it must be re-initialized. After this commit: We solve this issue by calculating all missing tables/views during the uninstallation process, and re-initializing all of them right before reloading the registry. Also remove sql-view hacks in the modules `sale` and `sale_margin`. Fixes #23528, #23529, #23530
2018-01-18[REM] config, loading: remove test-commit and test-report-directoryChristophe Monniez
As there are few use cases for the --test-commit and --test-report-directory options, they are removed.
2017-12-06[MERGE] forward port branch 11.0 up to f96a797fe62Christophe Simonis
2017-12-06[MERGE] forward port branch saas-16 up to b8540eefe3bChristophe Simonis
2017-12-04[MERGE] forward port branch saas-15 up to a447da75fd6Christophe Simonis
2017-12-04[MERGE] forward port branch saas-14 up to e7d174a1422Christophe Simonis
2017-12-01[FIX] *: Reset module states on registry init errorAdrian Torres
Commit 763d714 introduced cron job locking for databases which had modules with states set to 'to x', however if an installation/uninstallation/upgrade fails, the state will stay at 'to x', and it may stay in that state for an indefinite amount of time, meaning that cron jobs could stay locked forever. This commit fixes this in part by adding a cleanup function to loading.py that will be executed whenever load_modules fails, the function will change every 'to x' module to their original state, effectively unlocking the execution of cron jobs. This however only works to prevent "zombie" transient states for brand new databases, however for existing databases which already contain some modules in a zombie state it won't do anything unless a module is installed/uninstalled/upgraded, which may never happen. This is where the second part comes in (ir_cron.py), when failing to execute crons, we check if the failure was due to bad module state and if an arbitrary amount of time (5 hours as of this commit) has passed since the last time it was supposed to be executed, if it is the case, it means that the cron execution failed around 5 * 60 times (1 failure per minute for 5h) in which case we assume that the crons are stuck because the db has zombie states and we force a call to reset_module_states.
2017-11-16[REM] tools: Remove the yml import engineYannick Tivisse
2017-10-09[FIX] loading: Don't add None to installed apps (#19850)Adrian Torres
Previous to this rev., sometimes None could be added to the list of _init_modules in the registry, this would then be problematic in ir_http since a sorted would be performed on this list, which works in py2 but in py3 None and string can't be compared implicitly.
2017-10-02[MERGE] forward port branch saas-16 up to b3d0897f2d8Christophe Simonis
2017-09-28[IMP] module: make internal methods privateOlivier Dony
Only methods that are meant to be accessed by the client-side directly (or via RPC) should be public. All others should be private by default.
2017-09-26[IMP] modules: on module update or init always update module listDaniel Reis
Was only done when updating base. The cost of scanning the addons path should small in comparison to the update time itself. Followup of #9133 Closes #9140
2017-09-06[FIX] odoo.modules.loading: environment is reset while installing a databaseRaphael Collet
2017-08-20[FIX] P3: remove pycompat.{keys,items,values} helpersOlivier Dony
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-05-10[FIX] P3: list -> iterable builtins (#16811)xmo-odoo
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-03[REF] registry: always perform registry/cache signaling at the end of requestRaphael Collet
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[REF] registry: delegate addition of custom models/fieldsRaphael Collet
Delegate to models `ir.model` and `ir.model.fields`, so that this functionality can be extended easily.
2017-05-03[REF] registry: replace `partial` by attribute `registry.loaded`Raphael Collet
2017-02-08[IMP] tests: allow post-install tests to play real transactionsmge-odoo
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-01-06[MERGE] forward port branch saas-11 up to 9073ecb6f59Christophe Simonis
2017-01-04[FIX] core: leftover `openerp` use from last forward-portChristophe Simonis
2017-01-04[MERGE] forward port branch saas-11 up to 573293a06daChristophe Simonis
2016-09-02[FIX] odoo: rename imports and adapt import hooksRaphael Collet
2016-09-02[REF] openerp: move `openerp` to `odoo`Raphael Collet