Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions openerp/addons/openupgrade_records/lib/compare.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2011 Therp BV (<http://therp.nl>).
# Copyright (C) 2011 Therp BV (<http://therp.nl>).
# (C) 2015 Opener B.V. (<https://opener.am>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -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']
Expand Down Expand Up @@ -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'] = ''
Expand All @@ -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'] = ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ def field_dump(self, cr, uid, context=None):
'field',
'type',
'isfunction',
'isproperty',
'isrelated',
'relation',
'required',
'selection_keys',
Expand Down
34 changes: 28 additions & 6 deletions openerp/openupgrade/openupgrade_loading.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# This module copyright (C) 2014 Therp BV (<http://therp.nl>)
# Copyright (C) 2014 Therp BV (<http://therp.nl>)
# (C) 2015 Opener B.V. (<https://opener.am>)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
Expand All @@ -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
Expand Down Expand Up @@ -117,18 +118,39 @@ 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:
model_registry['_inherits'] = {'_inherits': unicode(model._inherits)}
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 '',
Expand Down