def __register__(cls, module_name): cursor = Transaction().cursor super(InvoiceLine, cls).__register__(module_name) # Migration from 2.6: remove sale_lines rel_table = 'sale_line_invoice_lines_rel' if TableHandler.table_exist(cursor, rel_table): cursor.execute('SELECT sale_line, invoice_line ' 'FROM "' + rel_table + '"') for sale_line, invoice_line in cursor.fetchall(): cursor.execute('UPDATE "' + cls._table + '" ' 'SET origin = %s ' 'WHERE id = %s', ('sale.line,%s' % sale_line, invoice_line)) TableHandler.drop_table(cursor, 'sale.line-account.invoice.line', rel_table)
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')