Пример #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 init(self, module_name):
     super(ProjectWork, self).init(module_name)
     cursor = Transaction().cursor
     table = TableHandler(cursor, self, module_name)
     log.debug(table)
     if table.column_exist('billable'):
         log.debug("drop billable from table")
         table.drop_column('billable', exception=True)
Пример #3
0
    def __register__(cls, module_name):
        cursor = Transaction().cursor
        table = TableHandler(cursor, cls, module_name)

        super(SaleOpportunityLine, cls).__register__(module_name)

        # Migration from 2.4: drop required on sequence
        table.not_null_action('sequence', action='remove')
Пример #4
0
    def __register__(cls, module_name):
        cursor = Transaction().cursor
        reference_exists = True
        if TableHandler.table_exist(cursor, cls._table):
            table = TableHandler(cursor, cls, module_name)
            reference_exists = table.column_exist('reference')
        super(SaleOpportunity, cls).__register__(module_name)
        table = TableHandler(cursor, cls, module_name)

        # Migration from 2.8: make party not required and add reference as
        # required
        table.not_null_action('party', action='remove')
        if not reference_exists:
            cursor.execute('UPDATE "' + cls._table +
                           '" SET reference=id WHERE '
                           'reference IS NULL')
            table.not_null_action('reference', action='add')
Пример #5
0
    def init(self, module_name):
        cursor = Transaction().cursor
        super(BalanceProductGoodsBalance, self).init(module_name)
        table = TableHandler(cursor, self, module_name)
        # Проверяем счетчик
        cursor.execute("SELECT last_value, increment_by FROM %s"%table.sequence_name)
        last_value, increment_by = cursor.fetchall()[0]

        # Устанавливаем счетчик
        if str(last_value)[len(str(last_value))-1] != str(_ID_TABLES_BALANCES_PERIOD[self._table]):
            cursor.execute("SELECT setval('"+table.sequence_name+"', %s, true)"%_ID_TABLES_BALANCES_PERIOD[self._table])
        if increment_by != 10:
            cursor.execute("ALTER SEQUENCE "+table.sequence_name+" INCREMENT 10")
 def init(self, module_name):
     super(PaymentTermLine, self).init(module_name)
     cursor = Transaction().cursor
     table = TableHandler(cursor, self, module_name)