[FIX] stock: remove existing demo data on reinstall
Previous to this rev.:
*Install stock w/ demo data
*Uninstall stock
*Reinstall stock
Result: Boom! Installation crashes.
Reason: The demo data installed with stock is not properly deleted after
the module is uninstalled, which causes issues/conflicts upon
reinstallation of the same demo data.
Solution: Remove any demo data of stock models upon installation if any
exist through a pre_init_hook, ideally this would be done by overriding
the unlink() of the affected models / setting some ondelete='cascade',
or even a uninstall_hook, however these solutions prove insufficient for
databases that are currently affected by the problem.
Fixes #22243
This commit is contained in:
@@ -4,4 +4,16 @@
|
||||
import controllers
|
||||
import models
|
||||
import report
|
||||
import wizard
|
||||
import wizard
|
||||
|
||||
|
||||
from odoo import api, SUPERUSER_ID
|
||||
|
||||
|
||||
# TODO: Apply proper fix & remove in master
|
||||
def pre_init_hook(cr):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
env['ir.model.data'].search([
|
||||
('model', 'like', '%stock%'),
|
||||
('module', '=', 'stock')
|
||||
]).unlink()
|
||||
|
||||
@@ -101,4 +101,5 @@ Dashboard / Reports for Inventory Management will include:
|
||||
'installable': True,
|
||||
'application': True,
|
||||
'auto_install': False,
|
||||
'pre_init_hook': 'pre_init_hook',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user