diff --git a/openerp/addons/openupgrade_records/lib/compare.py b/openerp/addons/openupgrade_records/lib/compare.py index 28e160115e91..f5de2fa85821 100644 --- a/openerp/addons/openupgrade_records/lib/compare.py +++ b/openerp/addons/openupgrade_records/lib/compare.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution -# This module copyright (C) 2011 Therp BV (). +# Copyright (C) 2011 Therp BV (). +# (C) 2015 Opener B.V. (). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -108,12 +108,26 @@ def report_generic(new, old, attrs, reprs): text += ', default = %s' % new['req_default'] fieldprint(old, new, None, text, reprs) elif attr == 'isfunction': - if old['isfunction'] != new['isfunction']: + if old[attr] != new[attr]: if new['isfunction']: text = "now a function" else: text = "not a function anymore" fieldprint(old, new, None, text, reprs) + elif attr == 'isproperty': + if old[attr] != new[attr]: + if new[attr]: + text = "now a property" + else: + text = "not a property anymore" + fieldprint(old, new, None, text, reprs) + elif attr == 'isrelated': + if old[attr] != new[attr]: + if new[attr]: + text = "now related" + else: + text = "not related anymore" + fieldprint(old, new, None, text, reprs) elif attr == 'oldname': if new.get('oldname') == old['field']: text = 'was renamed to %s [nothing to to]' % new['field'] @@ -202,7 +216,8 @@ def match(match_fields, report_fields, warn=False): ] for column in old_records: # we do not care about removed function fields - if column['isfunction'] or column['field'] in IGNORE_FIELDS: + if (column['isfunction'] or column['isrelated'] or + column['field'] in IGNORE_FIELDS): continue if column['mode'] == 'create': column['mode'] = '' @@ -213,7 +228,8 @@ def match(match_fields, report_fields, warn=False): for column in new_records: # we do not care about newly added function fields - if column['isfunction'] or column['field'] in IGNORE_FIELDS: + if (column['isfunction'] or column['isrelated'] or + column['field'] in IGNORE_FIELDS): continue if column['mode'] == 'create': column['mode'] = '' diff --git a/openerp/addons/openupgrade_records/model/openupgrade_record.py b/openerp/addons/openupgrade_records/model/openupgrade_record.py index cd902e6e9b71..521aff8e3936 100644 --- a/openerp/addons/openupgrade_records/model/openupgrade_record.py +++ b/openerp/addons/openupgrade_records/model/openupgrade_record.py @@ -93,6 +93,8 @@ def field_dump(self, cr, uid, context=None): 'field', 'type', 'isfunction', + 'isproperty', + 'isrelated', 'relation', 'required', 'selection_keys', diff --git a/openerp/openupgrade/openupgrade_loading.py b/openerp/openupgrade/openupgrade_loading.py index d2e65a376e2d..4144c4879446 100644 --- a/openerp/openupgrade/openupgrade_loading.py +++ b/openerp/openupgrade/openupgrade_loading.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution -# This module copyright (C) 2014 Therp BV () +# Copyright (C) 2014 Therp BV () +# (C) 2015 Opener B.V. () # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -22,7 +22,8 @@ import types import logging from openerp import release -from openerp.osv.orm import TransientModel +from openerp.osv import orm +from openerp import models from openerp.osv import fields from openupgradelib.openupgrade_tools import table_exists from openerp.tools import config, safe_eval @@ -117,9 +118,29 @@ def log_model(model, local_registry): return # persistent models only - if isinstance(model, TransientModel): + if isinstance(model, (orm.TransientModel, models.TransientModel)): return + def isfunction(model, k): + if ((isinstance(model._columns[k], fields.function) and + not isinstance(model._columns[k], + (fields.property, fields.related))) or + (model._fields[k].compute and not model._fields[k].related)): + return 'function' + return '' + + def isproperty(model, k): + if (isinstance(model._columns[k], fields.property) or + model._fields[k].company_dependent): + return 'property' + return '' + + def isrelated(model, k): + if (isinstance(model._columns[k], fields.related) or + model._fields[k].related): + return 'property' + return '' + model_registry = local_registry.setdefault( model._name, {}) if model._inherits: @@ -127,8 +148,9 @@ def log_model(model, local_registry): for k, v in model._columns.items(): properties = { 'type': v._type, - 'isfunction': ( - isinstance(v, fields.function) and 'function' or ''), + 'isfunction': isfunction(model, k), + 'isproperty': isproperty(model, k), + 'isrelated': isrelated(model, k), 'relation': v._type in ('many2many', 'many2one', 'one2many') and v._obj or '', 'required': v.required and 'required' or '',