Remove migration before 3.0

issue6470
review52421002
This commit is contained in:
Cédric Krier committed 2018-08-09 20:43:52 +02:00
1 parent 29d72c8746
commit 4d779f27eb
11 files changed
+1 -317

No files matched your search

+1 -69
View File
@@ -1,17 +1,14 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import base64
import os
from operator import itemgetter
from collections import defaultdict
from functools import partial
from sql import Table, Null
from sql.aggregate import Count
from sql import Null
from ..model import ModelView, ModelStorage, ModelSQL, DeactivableMixin, fields
from ..tools import file_open
from .. import backend
from ..pyson import PYSONDecoder, PYSON, Eval
from ..transaction import Transaction
from ..pool import Pool
@@ -498,7 +495,6 @@ class ActionReport(ActionMixin, ModelSQL, ModelView):
@classmethod
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
super(ActionReport, cls).__register__(module_name)
transaction = Transaction()
@@ -506,57 +502,6 @@ class ActionReport(ActionMixin, ModelSQL, ModelView):
table = cls.__table_handler__(module_name)
action_report = cls.__table__()
# Migration from 1.0 report_name_uniq has been removed
table.drop_constraint('report_name_uniq')
# Migration from 1.0 output_format (m2o) is now extension (selection)
if table.column_exist('output_format'):
outputformat = Table('ir_action_report_outputformat')
cursor.execute(*action_report.join(
outputformat,
condition=action_report.output_format == outputformat.id)
.select(action_report.id,
where=outputformat.format == 'pdf'))
ids = [x[0] for x in cursor.fetchall()]
cls.write(cls.browse(ids), {'extension': 'pdf'})
ids = cls.search([('id', 'not in', ids)])
cls.write(cls.browse(ids), {'extension': 'odt'})
table.drop_column("output_format")
TableHandler.dropTable('ir.action.report.outputformat',
'ir_action_report_outputformat')
# Migrate from 2.0 remove required on extension
table.not_null_action('extension', action='remove')
cursor.execute(*action_report.update(
[action_report.extension],
[''],
where=action_report.extension == 'odt'))
# Migration from 2.0 report_content_data renamed into
# report_content_custom to remove base64 encoding
if (table.column_exist('report_content_data')
and table.column_exist('report_content_custom')):
limit = transaction.database.IN_MAX
cursor.execute(*action_report.select(
Count(action_report.id)))
report_count, = cursor.fetchone()
for offset in range(0, report_count, limit):
cursor.execute(*action_report.select(
action_report.id, action_report.report_content_data,
order_by=action_report.id,
limit=limit, offset=offset))
for report_id, report in cursor.fetchall():
if report:
report = fields.Binary.cast(
base64.decodestring(bytes(report)))
cursor.execute(*action_report.update(
[action_report.report_content_custom],
[report],
where=action_report.id == report_id))
table.drop_column('report_content_data')
# Migration from 3.4 remove report_name_module_uniq constraint
table.drop_constraint('report_name_module_uniq')
@@ -747,11 +692,6 @@ class ActionActWindow(ActionMixin, ModelSQL, ModelView):
table = cls.__table_handler__(module_name)
# Migration from 2.0: new search_value format
cursor.execute(*act_window.update(
[act_window.search_value], ['[]'],
where=act_window.search_value == '{}'))
# Migration from 3.0: auto_refresh removed
table.drop_column('auto_refresh')
@@ -929,14 +869,6 @@ class ActionActWindowView(DeactivableMixin, ModelSQL, ModelView):
super(ActionActWindowView, cls).__setup__()
cls._order.insert(0, ('sequence', 'ASC'))
@classmethod
def __register__(cls, module_name):
super(ActionActWindowView, cls).__register__(module_name)
table = cls.__table_handler__(module_name)
# Migration from 1.0 remove multi
table.drop_column('multi')
@classmethod
def create(cls, vlist):
pool = Pool()
-12
View File
@@ -70,18 +70,6 @@ class Attachment(ResourceMixin, ModelSQL, ModelView):
table = cls.__table_handler__(module_name)
attachment = cls.__table__()
# Migration from 1.4 res_model and res_id merged into resource
# Reference
if table.column_exist('res_model') and \
table.column_exist('res_id'):
table.drop_constraint('res_model_res_id_name')
cursor.execute(*attachment.update(
[attachment.resource],
[Concat(Concat(attachment.resource, ','),
attachment.res_id)]))
table.drop_column('res_model')
table.drop_column('res_id')
# Migration from 4.0: merge digest and collision into file_id
if table.column_exist('digest') and table.column_exist('collision'):
cursor.execute(*attachment.update(
-19
View File
@@ -73,25 +73,6 @@ class Cron(DeactivableMixin, ModelSQL, ModelView):
},
})
@classmethod
def __register__(cls, module_name):
cursor = Transaction().connection.cursor()
cron = cls.__table__()
# Migration from 2.0: rename numbercall, doall and nextcall
table = cls.__table_handler__(module_name)
table.column_rename('numbercall', 'number_calls')
table.column_rename('doall', 'repeat_missed')
table.column_rename('nextcall', 'next_call')
table.drop_column('running')
super(Cron, cls).__register__(module_name)
# Migration from 2.0: work_days removed
cursor.execute(*cron.update(
[cron.interval_type], ['days'],
where=cron.interval_type == 'work_days'))
@staticmethod
def default_next_call():
return datetime.datetime.now()
-26
View File
@@ -432,15 +432,6 @@ class ModelAccess(ModelSQL, ModelView):
'get_access': RPC(),
})
@classmethod
def __register__(cls, module_name):
super(ModelAccess, cls).__register__(module_name)
table = cls.__table_handler__(module_name)
# Migration from 2.6 (model, group) no more unique
table.drop_constraint('model_group_uniq')
@staticmethod
def check_xml_record(accesses, values):
return True
@@ -614,15 +605,6 @@ class ModelFieldAccess(ModelSQL, ModelView):
'write': 'You can not write on the field! (%s.%s)',
})
@classmethod
def __register__(cls, module_name):
super(ModelFieldAccess, cls).__register__(module_name)
table = cls.__table_handler__(module_name)
# Migration from 2.6 (field, group) no more unique
table.drop_constraint('field_group_uniq')
@staticmethod
def check_xml_record(field_accesses, values):
return True
@@ -1121,14 +1103,6 @@ class ModelData(ModelSQL, ModelView):
super(ModelData, cls).__register__(module_name)
table = cls.__table_handler__(module_name)
# Migration from 2.6: remove inherit
if table.column_exist('inherit'):
cursor.execute(*model_data.delete(
where=model_data.inherit == True))
table.drop_column('inherit', True)
# Migration from 4.6: register buttons on ir module
cursor.execute(*model_data.update(
[model_data.module], ['ir'],
-5
View File
@@ -415,11 +415,6 @@ class ModuleConfigWizardItem(ModelSQL, ModelView):
where=(model_data.model ==
'ir.module.module.config_wizard.item')))
table_h = cls.__table_handler__(module_name)
# Migrate from 2.2 remove name
table_h.drop_column('name')
super(ModuleConfigWizardItem, cls).__register__(module_name)
@staticmethod
-11
View File
@@ -105,17 +105,6 @@ class Rule(ModelSQL, ModelView):
'invalid_domain': 'Invalid domain in rule "%s".',
})
@classmethod
def __register__(cls, module_name):
super(Rule, cls).__register__(module_name)
table = cls.__table_handler__(module_name)
# Migration from 2.6: replace field, operator and operand by domain
table.not_null_action('field', action='remove')
table.drop_fk('field')
table.not_null_action('operator', action='remove')
table.not_null_action('operand', action='remove')
@classmethod
def validate(cls, rules):
super(Rule, cls).validate(rules)
-20
View File
@@ -99,26 +99,6 @@ class Sequence(DeactivableMixin, ModelSQL, ModelView):
'future on sequence "%s".'),
})
@classmethod
def __register__(cls, module_name):
table_h = cls.__table_handler__(module_name)
transaction = Transaction()
# Migration from 2.0 rename number_next into number_next_internal
table_h.column_rename('number_next', 'number_next_internal')
super(Sequence, cls).__register__(module_name)
# Migration from 2.0 create sql_sequence
if sql_sequence and not cls._strict:
sequences = cls.search([])
for sequence in sequences:
if sequence.type != 'incremental':
continue
if not transaction.database.sequence_exist(
transaction.connection, sequence._sql_sequence_name):
sequence.create_sql_sequence(sequence.number_next_internal)
@staticmethod
def default_type():
return 'incremental'
-27
View File
@@ -100,36 +100,9 @@ class Translation(ModelSQL, ModelView):
cursor = transaction.connection.cursor()
ir_translation = cls.__table__()
table = cls.__table_handler__(module_name)
# Migration from 1.8: new field src_md5
src_md5_exist = table.column_exist('src_md5')
if not src_md5_exist:
table.add_column('src_md5', cls.src_md5._sql_type)
table.drop_constraint('translation_uniq')
table.index_action(['lang', 'type', 'name', 'src'], 'remove')
super(Translation, cls).__register__(module_name)
# Migration from 1.8: fill new field src_md5
if not src_md5_exist:
offset = 0
limit = transaction.database.IN_MAX
translations = True
while translations:
translations = cls.search([], offset=offset, limit=limit)
offset += limit
for translation in translations:
src_md5 = cls.get_src_md5(translation.src)
cls.write([translation], {
'src_md5': src_md5,
})
table = cls.__table_handler__(module_name)
table.not_null_action('src_md5', action='add')
# Migration from 2.2 and 2.8
cursor.execute(*ir_translation.update([ir_translation.res_id],
[-1], where=(ir_translation.res_id == Null)
| (ir_translation.res_id == 0)))
# Migration from 3.8: rename odt type in report
cursor.execute(*ir_translation.update(
[ir_translation.type],
-24
View File
@@ -78,25 +78,6 @@ class View(ModelSQL, ModelView):
},
})
@classmethod
def __register__(cls, module_name):
table = cls.__table_handler__(module_name)
# Migration from 2.4 arch moved into data
if table.column_exist('arch'):
table.column_rename('arch', 'data')
super(View, cls).__register__(module_name)
# New instance to refresh definition
table = cls.__table_handler__(module_name)
# Migration from 1.0 arch no more required
table.not_null_action('arch', action='remove')
# Migration from 2.4 model no more required
table.not_null_action('model', action='remove')
@staticmethod
def default_priority():
return 16
@@ -329,11 +310,6 @@ class ViewTreeState(ModelSQL, ModelView):
@classmethod
def __register__(cls, module_name):
table = cls.__table_handler__(module_name)
# Migration from 2.8: table name changed
table.table_rename('ir_ui_view_tree_expanded_state', cls._table)
super(ViewTreeState, cls).__register__(module_name)
table = cls.__table_handler__(module_name)
-59
View File
@@ -1,9 +1,7 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from ..model import ModelSQL, DeactivableMixin, fields
from .. import backend
from ..pool import Pool, PoolMeta
from ..transaction import Transaction
__all__ = [
'UIMenuGroup', 'ActionGroup', 'ModelFieldGroup', 'ModelButtonGroup',
@@ -22,20 +20,6 @@ class UIMenuGroup(ModelSQL):
group = fields.Many2One('res.group', 'Group', ondelete='CASCADE',
select=True, required=True)
@classmethod
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
transaction = Transaction()
# Migration from 1.0 table name change
TableHandler.table_rename('ir_ui_menu_group_rel', cls._table)
transaction.database.sequence_rename(transaction.connection,
'ir_ui_menu_group_rel_id_seq', cls._table + '_id_seq')
# Migration from 2.0 menu_id and gid renamed into menu group
table = cls.__table_handler__(module_name)
table.column_rename('menu_id', 'menu')
table.column_rename('gid', 'group')
super(UIMenuGroup, cls).__register__(module_name)
@classmethod
def create(cls, vlist):
res = super(UIMenuGroup, cls).create(vlist)
@@ -64,20 +48,6 @@ class ActionGroup(ModelSQL):
group = fields.Many2One('res.group', 'Group', ondelete='CASCADE',
select=True, required=True)
@classmethod
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
transaction = Transaction()
# Migration from 1.0 table name change
TableHandler.table_rename('ir_action_group_rel', cls._table)
transaction.database.sequence_rename(transaction.connection,
'ir_action_group_rel_id_seq', cls._table + '_id_seq')
# Migration from 2.0 action_id and gid renamed into action and group
table = cls.__table_handler__(module_name)
table.column_rename('action_id', 'action')
table.column_rename('gid', 'group')
super(ActionGroup, cls).__register__(module_name)
@classmethod
def create(cls, vlist):
Action = Pool().get('ir.action')
@@ -119,20 +89,6 @@ class ModelFieldGroup(ModelSQL):
group = fields.Many2One('res.group', 'Group', ondelete='CASCADE',
select=True, required=True)
@classmethod
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
transaction = Transaction()
# Migration from 1.0 table name change
TableHandler.table_rename('ir_model_field_group_rel', cls._table)
transaction.database.sequence_rename(transaction.connection,
'ir_model_field_group_rel_id_seq', cls._table + '_id_seq')
table = cls.__table_handler__(module_name)
# Migration from 2.6: field_id and group_id renamed to field and group
table.column_rename('field_id', 'field')
table.column_rename('group_id', 'group')
super(ModelFieldGroup, cls).__register__(module_name)
class ModelButtonGroup(DeactivableMixin, ModelSQL):
"Model Button - Group"
@@ -183,21 +139,6 @@ class RuleGroupGroup(ModelSQL):
group = fields.Many2One('res.group', 'Group', ondelete='CASCADE',
select=True, required=True)
@classmethod
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
transaction = Transaction()
# Migration from 1.0 table name change
TableHandler.table_rename('group_rule_group_rel', cls._table)
transaction.database.sequence_rename(transaction.connection,
'group_rule_group_rel_id_seq', cls._table + '_id_seq')
# Migration from 2.0 rule_group_id and group_id renamed into rule_group
# and group
table = cls.__table_handler__(cls, module_name)
table.column_rename('rule_group_id', 'rule_group')
table.column_rename('group_id', 'group')
super(RuleGroupGroup, cls).__register__(module_name)
class Lang(metaclass=PoolMeta):
__name__ = 'ir.lang'
-45
View File
@@ -37,7 +37,6 @@ from ..model import (
ModelView, ModelSQL, Workflow, DeactivableMixin, fields, Unique)
from ..wizard import Wizard, StateView, Button, StateTransition
from ..tools import grouped_slice
from .. import backend
from ..transaction import Transaction
from ..cache import Cache
from ..pool import Pool
@@ -191,27 +190,6 @@ class User(DeactivableMixin, ModelSQL, ModelView):
super(User, cls).__register__(module_name)
table = cls.__table_handler__(module_name)
# Migration from 1.6
# For module dashboard
table.module_name = 'dashboard'
table.not_null_action('dashboard_layout', action='remove')
# For module calendar_scheduling
table.module_name = 'calendar_scheduling'
for field in ('calendar_email_notification_new',
'calendar_email_notification_update',
'calendar_email_notification_cancel',
'calendar_email_notification_partstat',
):
table.not_null_action(field, action='remove')
# Migration from 2.2
table.not_null_action('menu', action='remove')
# Migration from 2.6
table.drop_column('login_try')
# Migration from 3.0
if table.column_exist('password') and table.column_exist('salt'):
sqltable = cls.__table__()
@@ -729,14 +707,6 @@ class LoginAttempt(ModelSQL):
ip_address = fields.Char("IP Address")
ip_network = fields.Char("IP Network")
@classmethod
def __register__(cls, module_name):
super(LoginAttempt, cls).__register__(module_name)
table = cls.__table_handler__(module_name)
# Migration from 2.8: remove user
table.drop_column('user')
@staticmethod
def delay():
return (datetime.datetime.now()
@@ -846,21 +816,6 @@ class UserGroup(ModelSQL):
group = fields.Many2One('res.group', 'Group', ondelete='CASCADE',
select=True, required=True)
@classmethod
def __register__(cls, module_name):
TableHandler = backend.get('TableHandler')
transaction = Transaction()
# Migration from 1.0 table name change
TableHandler.table_rename('res_group_user_rel', cls._table)
transaction.database.sequence_rename(transaction.connection,
'res_group_user_rel_id_seq', cls._table + '_id_seq')
# Migration from 2.0 uid and gid rename into user and group
table = cls.__table_handler__(module_name)
table.column_rename('uid', 'user')
table.column_rename('gid', 'group')
super(UserGroup, cls).__register__(module_name)
class Warning_(ModelSQL, ModelView):
'User Warning'