Skip to content

Commit f3fd78e

Browse files
committed
[FIX] Change "env" for "cr" due odoo restriction on 18.0
1 parent 0d0d165 commit f3fd78e

8 files changed

+72
-5
lines changed

base/16.0.0.0/pre-0-disable-check-company.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ def _check_company(self, fnames=None):
1717
BaseModel._check_company = _check_company
1818

1919

20-
def migrate(env, version):
20+
def migrate(cr, version):
2121
pass

base/16.0.0.0/pre-0-disable-check-views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ def _check_xml(self):
1717
View._check_xml = _check_xml
1818

1919

20-
def migrate(env, version):
20+
def migrate(cr, version):
2121
pass

base/17.0.0.0/pre-0-disable-check-company.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ def _check_company(self, fnames=None):
1717
BaseModel._check_company = _check_company
1818

1919

20-
def migrate(env, version):
20+
def migrate(cr, version):
2121
pass

base/17.0.0.0/pre-0-disable-check-views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ def _check_xml(self):
1717
View._check_xml = _check_xml
1818

1919

20-
def migrate(env, version):
20+
def migrate(cr, version):
2121
pass

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ def _process_ondelete(self):
2121
IrModelSelection._process_ondelete = _process_ondelete
2222

2323

24-
def migrate(env, version):
24+
def migrate(cr, version):
2525
pass
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from odoo.models import BaseModel
2+
import logging
3+
_logger = logging.getLogger(__name__)
4+
5+
6+
_original_check_company = BaseModel._check_company
7+
8+
9+
def _check_company(self, fnames=None):
10+
""" Patch chec_check_company to avoid any error when run scripts, we enable later """
11+
try:
12+
_original_check_company
13+
except Exception as e:
14+
_logger.warning('incompatible companies. This is what we get:\n%s', e)
15+
16+
17+
BaseModel._check_company = _check_company
18+
19+
20+
def migrate(cr, version):
21+
pass
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from odoo.addons.base.models.ir_ui_view import View
2+
import logging
3+
_logger = logging.getLogger(__name__)
4+
5+
6+
_original_check_xml = View._check_xml
7+
8+
9+
def _check_xml(self):
10+
""" Patch check_xml to avoid any error when loading views, we check them later """
11+
try:
12+
_original_check_xml
13+
except Exception as e:
14+
_logger.warning('Invalid view definition. This is what we get:\n%s', e)
15+
16+
17+
View._check_xml = _check_xml
18+
19+
20+
def migrate(cr, version):
21+
pass

base/18.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(cr, version):
25+
pass

0 commit comments

Comments
 (0)