Skip to content

Commit bd89b29

Browse files
committed
[IMP] OCA openupgrade_framework uses
1 parent daba62f commit bd89b29

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

base/17.0.0.0/pre-0-model-checks.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from odoo import api, models
2+
3+
from odoo.addons.base.models.ir_model import (
4+
IrModelSelection,
5+
)
6+
7+
8+
def _process_ondelete(self):
9+
"""Don't break on missing models when deleting their selection fields"""
10+
to_process = self.browse([])
11+
for selection in self:
12+
try:
13+
self.env[selection.field_id.model] # pylint: disable=pointless-statement
14+
to_process += selection
15+
except KeyError:
16+
continue
17+
return IrModelSelection._process_ondelete._original_method(to_process)
18+
19+
20+
_process_ondelete._original_method = IrModelSelection._process_ondelete
21+
IrModelSelection._process_ondelete = _process_ondelete
22+
23+
24+
def migrate(env, version):
25+
pass

0 commit comments

Comments
 (0)