43
43
44
44
from .exceptions import MigrationError , SleepyDeveloperError
45
45
from .helpers import _validate_table , model_of_table
46
- from .misc import Sentinel , log_progress
46
+ from .misc import Sentinel , log_progress , version_gte
47
47
48
48
_logger = logging .getLogger (__name__ )
49
49
@@ -472,6 +472,54 @@ def _column_info(cr, table, column):
472
472
return cr .fetchone ()
473
473
474
474
475
+ _COLUMNS = {}
476
+ if version_gte ("10.0" ): # Since at least 9.0
477
+ _COLUMNS [("ir_model_fields" , "depends" )] = True
478
+ _COLUMNS [("ir_model_fields" , "domain" )] = True
479
+ _COLUMNS [("ir_model_fields" , "relation_table" )] = True
480
+
481
+ _COLUMNS [("ir_ui_view" , "arch_db" )] = True
482
+ _COLUMNS [("ir_ui_view" , "active" )] = True
483
+
484
+ _COLUMNS [("ir_filters" , "sort" )] = True
485
+ _COLUMNS [("ir_filters" , "domain" )] = True
486
+ _COLUMNS [("ir_filters" , "model_id" )] = True
487
+
488
+ _COLUMNS [("ir_model_rule" , "domain_force" )] = True
489
+
490
+ _COLUMNS [("ir_model_data" , "res_id" )] = True
491
+ _COLUMNS [("ir_model_data" , "model" )] = True
492
+ _COLUMNS [("ir_model_data" , "name" )] = True
493
+
494
+ _COLUMNS [("ir_attachment" , "res_field" )] = True
495
+ _COLUMNS [("ir_attachment" , "res_model" )] = True
496
+ _COLUMNS [("ir_attachment" , "res_id" )] = True
497
+
498
+ _COLUMNS [("ir_ui_menu" , "action" )] = True
499
+
500
+ _COLUMNS [("ir_act_window" , "res_model" )] = True
501
+ _COLUMNS [("ir_act_window" , "res_id" )] = True
502
+ _COLUMNS [("ir_act_window" , "domain" )] = True
503
+
504
+ _COLUMNS [("ir_value" , "res_id" )] = True
505
+
506
+ if version_gte ("14.0" ): # Since at least 13.0
507
+ _COLUMNS [("ir_module_module_dependency" , "auto_install_required" )] = True
508
+ _COLUMNS [("ir_act_window" , "src_model" )] = False
509
+
510
+ if version_gte ("saas~16.1" ): # Since 16.0
511
+ _COLUMNS [("ir_translation" , "name" )] = False
512
+
513
+ if version_gte ("saas~17.1" ): # Since 17.0
514
+ _COLUMNS [("ir_cron" , "resource_ref" )] = True
515
+ _COLUMNS [("ir_act_server" , "resource_ref" )] = True
516
+
517
+ if version_gte ("saas~18.1" ): # Since 18.0
518
+ _COLUMNS [("ir_model_fields" , "company_dependent" )] = True
519
+ _COLUMNS [("ir_filters" , "embedded_parent_res_id" )] = True
520
+ _COLUMNS [("ir_act_report_xml" , "domain" )] = True
521
+
522
+
475
523
def column_exists (cr , table , column ):
476
524
"""
477
525
Return whether a column exists.
@@ -480,7 +528,7 @@ def column_exists(cr, table, column):
480
528
:param str column: column to check
481
529
:rtype: bool
482
530
"""
483
- return _column_info (cr , table , column ) is not None
531
+ return _COLUMNS [( table , column )] if ( table , column ) in _COLUMNS else ( _column_info (cr , table , column ) is not None )
484
532
485
533
486
534
def column_type (cr , table , column ):
0 commit comments