Пример #1
0
    def __register__(cls, module_name):
        """Migrations

        :param module_name: Module Name (Automatically passed by caller)
        """
        cursor = Transaction().cursor
        table = TableHandler(cursor, cls, module_name)

        # Drop the required index on methods
        table.not_null_action('methods', action="remove")

        # Rename methods to old_methods
        table.column_rename('methods', 'old_methods')

        # Check if the new boolean fields exist
        http_method_fields_exists = table.column_exist('http_method_get')

        super(URLRule, cls).__register__(module_name)

        if not http_method_fields_exists:
            # if the http method fields did not exist before this method
            # should transition old_methods to the boolean fields
            rules = cls.search([])
            for rule in rules:
                cls.set_methods([rule.id], 'methods', rule.old_methods)
Пример #2
0
    def __register__(cls, module_name):
        """Migrations

        :param module_name: Module Name (Automatically passed by caller)
        """
        cursor = Transaction().cursor
        table = TableHandler(cursor, cls, module_name)

        # Drop the required index on methods
        table.not_null_action('methods', action="remove")

        # Rename methods to old_methods
        table.column_rename('methods', 'old_methods')

        # Check if the new boolean fields exist
        http_method_fields_exists = table.column_exist('http_method_get')

        super(URLRule, cls).__register__(module_name)

        if not http_method_fields_exists:
            # if the http method fields did not exist before this method
            # should transition old_methods to the boolean fields
            rules = cls.search([])
            for rule in rules:
                cls.set_methods([rule.id], 'methods', rule.old_methods)
Пример #3
0
    def __register__(cls, module_name):
        cursor = Transaction().cursor
        # Migration from 1.2: packing renamed into shipment
        table = TableHandler(cursor, cls, module_name)
        table.drop_constraint('check_packing')
        for suffix in ('in', 'out', 'in_return', 'out_return', 'internal'):
            old_column = 'packing_%s' % suffix
            new_column = 'shipment_%s' % suffix
            if table.column_exist(old_column):
                table.index_action(old_column, action='remove')
            table.drop_fk(old_column)
            table.column_rename(old_column, new_column)

        # Migration from 1.8: new field internal_quantity
        internal_quantity_exist = table.column_exist('internal_quantity')

        super(Move, cls).__register__(module_name)

        # Migration from 1.8: fill new field internal_quantity
        if not internal_quantity_exist:
            offset = 0
            limit = cursor.IN_MAX
            moves = True
            while moves:
                moves = cls.search([], offset=offset, limit=limit)
                offset += limit
                for move in moves:
                    internal_quantity = cls._get_internal_quantity(
                            move.quantity, move.uom, move.product)
                    cursor.execute(
                        'UPDATE "' + cls._table + '" '
                        'SET internal_quantity = %s '
                        'WHERE id = %s', (internal_quantity, move.id))
            table = TableHandler(cursor, cls, module_name)
            table.not_null_action('internal_quantity', action='add')

        # Migration from 1.0 check_packing_in_out has been removed
        table = TableHandler(cursor, cls, module_name)
        table.drop_constraint('check_packing_in_out')

        # Migration from 2.6: merge all shipments
        table.drop_constraint('check_shipment')
        shipments = {
            'shipment_in': 'stock.shipment.in',
            'shipment_out': 'stock.shipment.out',
            'shipment_out_return': 'stock.shipment.out.return',
            'shipment_in_return': 'stock.shipment.in.return',
            'shipment_internal': 'stock.shipment.internal',
            }
        for column, model in shipments.iteritems():
            if table.column_exist(column):
                cursor.execute('UPDATE "' + cls._table + '" '
                    'SET shipment = \'' + model + ',\' || "' + column + '" '
                    'WHERE "' + column + '" IS NOT NULL')
                table.drop_column(column)

        # Add index on create_date
        table.index_action('create_date', action='add')
Пример #4
0
 def __register__(cls, module_name):
     cursor = Transaction().cursor
     # Migration from 1.6 product renamed into category
     table = TableHandler(cursor, cls)
     if table.column_exist('product'):
         table.index_action('product', action='remove')
         table.drop_fk('product')
         table.column_rename('product', 'category')
     super(CategorySupplierTax, cls).__register__(module_name)
Пример #5
0
    def __register__(cls, module_name):
        super(Surgery, cls).__register__(module_name)

        cursor = Transaction().cursor
        table = TableHandler(cursor, cls, module_name)
        # Rename the date column to surgery_surgery_date

        if table.column_exist('date'):
            table.column_rename('date', 'surgery_date')
Пример #6
0
    def __register__(cls, module_name):
        cursor = Transaction().cursor
        table = TableHandler(cursor, cls, 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)

        # 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')
Пример #7
0
    def __register__(cls, module_name):
        cursor = Transaction().cursor
        table = TableHandler(cursor, cls, 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)

        # 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")
Пример #8
0
    def __register__(cls, module_name):
        cursor = Transaction().cursor
        # Migration from 1.4: calendar_rdate renamed to calendar_date
        table = TableHandler(cursor, cls, module_name)
        old_column = 'calendar_rdate'
        if table.column_exist(old_column):
            table.column_rename(old_column, 'calendar_date')

        super(TodoRDate, cls).__register__(module_name)

        table = TableHandler(cursor, cls, module_name)

        # Migration from 2.6: Remove inherits calendar.date
        if table.column_exist('calendar_date'):
            cursor.execute('UPDATE "' + cls._table + '" AS e '
                'SET date = (SELECT a.date '
                    'FROM calendar_date AS a '
                    'WHERE a.id = e.calendar_date), '
                'datetime = (SELECT a.datetime '
                    'FROM calendar_date AS a '
                    'WHERE a.id = e.calendar_date)')
            table.drop_column('calendar_date', True)