-
- Downloads
[FIX] sale_stock_margin: enforce implicit dependency
Strap yourself in, we're in for a ride:
The module sale_stock_margin overrides
`SaleOrderLine._compute_purchase_price` and adds some extra dependencies,
the key dependency here is 'move_ids'.
The field `move_ids` is defined in sale_stock's override of
sale.order.line, however sale_stock is **not** a dependency of
sale_stock_margin, but since they implicitly share the same dependencies
and are both `auto_install=True` it is impossible to install
sale_stock_margin without having sale_stock be automatically installed.
However, since sale_stock_margin does not **explicitly** depend on
sale_stock, if one were to uninstall sale_stock without uninstalling
sale_stock_margin first, the registry would crash because
sale_stock_margin's override of `_compute_purchase_price` would depend
on a field that no longer exists (`move_ids`).
This commit fixes this in an odd way, because of the following reasons:
- We cannot change a dependency in a stable branch.
- An uninstall_hook cannot inject an uninstall dependency because the
hook step is too late into the process (we'd need a
pre_uninstall_hook)
- A post_install_hook could create a dependency between
sale_stock_margin and sale_stock, however this would only apply to
**new** installs of sale_stock_margin and the bug would persist for
existing users
Thus the only solution left is to extend ir.module.module and override
the downstream_dependencies to inject sale_stock_margin as a sale_stock
dependant if sale_stock is one of the modules for which we're
calculating the downstream dependencies.
closes odoo/odoo#75690
Signed-off-by:
Raphael Collet (rco) <rco@openerp.com>
addons/sale_stock_margin/models/ir_module.py
0 → 100644
Please register or sign in to comment