Commit Graph
82 Commits
Author SHA1 Message Date
Christophe Simonis 219d2296d6 [MERGE] forward port branch saas-15 up to c4ee29345a 2018-07-23 15:45:08 +02:00
Christophe Simonis c4ee29345a [MERGE] forward port branch saas-14 up to 9ee882564f 2018-07-23 14:57:03 +02:00
Christophe Simonis 6e71cf8a71 [MERGE] forward port branch 9.0 up to af2e480e41 2018-07-23 13:41:04 +02:00
Xavier Morel 9f8eae34d1 [FIX] undefined variables (potential nameerror)
Backport 9ec0455abc and
6a601fe6dc as they fixed various
possible NameError but did so in later sub-releases.
2018-07-19 13:37:10 +02:00
Christophe Simonis 84210074e5 [MERGE] forward port branch saas-15 up to b06c09db60 2018-07-05 16:23:47 +02:00
Christophe Simonis b06c09db60 [MERGE] forward port branch saas-14 up to 92e5da6b8f 2018-07-05 15:35:24 +02:00
Christophe Simonis 26e7d5d8ee [MERGE] forward port branch 9.0 up to b5c50fa824 2018-07-05 14:19:33 +02:00
Christophe Simonis b05e4d5f95 [MERGE] forward port branch saas-15 up to a53bea49fe 2018-06-14 21:28:39 +02:00
Christophe Simonis 803df909b1 [MERGE] forward port branch saas-14 up to 804d68efe5 2018-06-14 18:05:38 +02:00
Christophe Simonis 23a1bce2a9 [MERGE] forward port branch 9.0 up to 90165e2d96 2018-06-14 17:29:56 +02:00
Christophe Simonis c301122b5f [MERGE] forward port branch saas-14 up to a002210d93 2018-06-05 12:00:11 +02:00
Adrian Torres c25b68f324 [FIX] orm: re-create constraints of extended fields
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-05 11:07:33 +02:00
Adrian Torres a5ccc1b6b5 [FIX] orm: re-create constraints of extended fields
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 10:55:35 +02:00
Christophe Simonis 021d0e6a98 [MERGE] forward port branch saas-14 up to cabe0951af 2018-05-18 18:54:26 +02:00
Fabien Meghazi 3862c03ec2 [FIX] base: honor registry/cache signaling for multiple threaded servers
Before this patch the registry and cache signaling was only activated
for PreforkServer. In case Odoo was deployed in a multi process/multi
threaded architecture the signaling was not ensured, causing registry
de-synchronisation amongst threaded servers.

Backported from fd4939dc78
2018-05-18 14:33:22 +02:00
Fabien Meghazi c60b22335b [FIX] base: honor registry/cache signaling for multiple threaded servers
Before this patch the registry and cache signaling was only activated
for PreforkServer. In case Odoo was deployed in a multi process/multi
threaded architecture the signaling was not ensured, causing registry
de-synchronisation amongst threaded servers.
2018-05-18 14:20:35 +02:00
Adrian Torres 84b6c46943 [FIX] registry, loading: re-init inherited SQL views
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-03-13 09:41:43 +01:00
Christophe Simonis 72508cc241 [MERGE] forward port branch saas-16 up to 7792755946 2018-02-14 18:26:57 +01:00
Christophe Simonis 7792755946 [MERGE] forward port branch saas-15 up to d24bdbde81 2018-02-14 17:18:59 +01:00
Christophe Simonis d24bdbde81 [MERGE] forward port branch saas-14 up to 9d0de61114 2018-02-14 16:34:13 +01:00
Christophe Simonis 73c2ac451a [MERGE] forward port branch 9.0 up to b7b82f1267 2018-02-14 15:32:37 +01:00
Christophe Simonis f96a797fe6 [MERGE] forward port branch saas-16 up to b8540eefe3 2017-12-06 11:59:38 +01:00
Christophe Simonis a8d01cbf4e [MERGE] forward port branch saas-15 up to a447da75fd 2017-12-04 20:12:19 +01:00
Christophe Simonis a447da75fd [MERGE] forward port branch saas-14 up to e7d174a142 2017-12-04 19:25:51 +01:00
Adrian Torres 3d1e23aaba [FIX] *: Reset module states on registry init error
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-12-01 14:15:42 +00:00
Adrian Torres e0b6eb3e62 [FIX] loading: Don't add None to installed apps (#19850)
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-09 09:35:59 +02:00
Richard Mathot e2349f4546 [FIX] odoo: bad imports in tests don't fail silently anymore
Before this fix, you can break a test class by simply adding an
incorrect import like this:
`from gloubiboulga import Casimir`
--> No error message, the test is simply not run

This is due to the fact that we want to ignore ImportError's... only
when there is no `.tests` submodules (actually, we ignored them all!)

This commit fixes the condition and re-enables error logging when tests
actually encounter ImportErrors
2017-10-03 14:29:01 +02:00
Christophe Monniez aaa30a74b5 [imp] module,http: open manifest files as utf-8 in a python2/3 compatible way 2017-10-03 12:01:53 +02:00
Christophe Monniez 0bab2e7fbd [FIX] modules: Verify that an addons path exists 2017-10-03 12:01:52 +02:00
Christophe Simonis 5ce21c7355 [MERGE] forward port branch saas-16 up to b3d0897f2d 2017-10-02 13:05:17 +02:00
Olivier Dony e4672db97d [IMP] module: make internal methods private
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-28 14:15:30 +02:00
Daniel Reis 53fe7ae462 [IMP] modules: on module update or init always update module list
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-26 13:32:53 +02:00
Christophe Simonis 66ca687324 [MERGE] forward port branch saas-17 up to ed901bedcb 2017-09-15 18:09:39 +02:00
Christophe Simonis 4bcd444eae [FIX] core: python3 compatibility for migration engine 2017-09-14 14:09:29 +02:00
Raphael Collet 68fb4b95b4 [FIX] odoo.modules.loading: environment is reset while installing a database 2017-09-06 16:05:10 +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
Xavier Morel 72083bc8ba [FIX] P3: ImportError text changed & text model fix 2017-08-20 23:25:54 +02:00
Xavier Morel d634fbd9ab [FIX] P3: reorder finders in meta_path
So that was a fun one: mock.patch calls would regularly fail refusing
to find the addon in odoo.addon (e.g. essentially getattr(odoo.addon,
'account_budget' deep within the bowels of mock).

Turns out the answer is that our import hooks would not be used for
many imports: while in Python 2, sys.meta_path is empty and the
default finders are run after all meta_path finders fail as noted by
the documentation[0].

However when the import system was rewritten in Python 3.3[1]
meta_path was "despecialised" and the default finders were moved to
meta_path rather than be a hidden part of the import machinery[2]:

> sys.meta_path and sys.path_hooks now store all of the meta path
> finders and path entry hooks used by import. Previously the finders
> were implicit and hidden within the C code of import instead of
> being directly exposed.

The result of this change is that ``sys.meta_path.append`` means the
default finders should take priority and the custom ones should be
fallback. This is the exact opposite of what we want.

Fix issue by ``sys.meta_path.insert``-ing our finders at the start of
the path rather than appending them at the end. This should change
nothing in Python 2 but seems to fix the issue in P3.

[0]
https://docs.python.org/2/library/sys.html?highlight=meta_path#sys.meta_path
[1] https://docs.python.org/3/whatsnew/3.3.html#importlib
[2] https://docs.python.org/3/whatsnew/3.3.html#visible-changes
2017-08-19 02:34:24 +02:00
Raphael Collet faacacb45f [IMP] registry: check existence of tables with a single SQL query 2017-07-10 12:38:25 +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 77e7799d5a [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-05-03 15:57:27 +02:00
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