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
20 lines
436 B
Python
20 lines
436 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
import controllers
|
|
import models
|
|
import report
|
|
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()
|