diff --git a/invoice.py b/invoice.py index 53eb3a59e2..db395a2f11 100644 --- a/invoice.py +++ b/invoice.py @@ -2,12 +2,10 @@ # this repository contains the full copyright notices and license terms. from itertools import chain from functools import wraps -from sql import Table from trytond.model import ModelView, Workflow, fields from trytond.pool import Pool, PoolMeta from trytond.transaction import Transaction -from trytond import backend __all__ = ['Invoice', 'InvoiceLine'] @@ -112,28 +110,6 @@ class Invoice(metaclass=PoolMeta): class InvoiceLine(metaclass=PoolMeta): __name__ = 'account.invoice.line' - @classmethod - def __register__(cls, module_name): - TableHandler = backend.get('TableHandler') - cursor = Transaction().connection.cursor() - sql_table = cls.__table__() - - super(InvoiceLine, cls).__register__(module_name) - - # Migration from 2.6: remove purchase_lines - rel_table_name = 'purchase_line_invoice_lines_rel' - if TableHandler.table_exist(rel_table_name): - rel_table = Table(rel_table_name) - cursor.execute(*rel_table.select( - rel_table.purchase_line, rel_table.invoice_line)) - for purchase_line, invoice_line in cursor.fetchall(): - cursor.execute(*sql_table.update( - columns=[sql_table.origin], - values=['purchase.line,%s' % purchase_line], - where=sql_table.id == invoice_line)) - TableHandler.drop_table( - 'purchase.line-account.invoice.line', rel_table_name) - @property def origin_name(self): pool = Pool() diff --git a/product.py b/product.py index 6b4f09a2db..f8c40a1165 100644 --- a/product.py +++ b/product.py @@ -190,36 +190,8 @@ class ProductSupplier(sequence_ordered(), ModelSQL, ModelView, MatchMixin): table = cls.__table_handler__(module_name) sql_table = cls.__table__() - # Migration from 2.2 new field currency - created_currency = table.column_exist('currency') - super(ProductSupplier, cls).__register__(module_name) - # Migration from 2.2 fill currency - if not created_currency: - Company = Pool().get('company.company') - company = Company.__table__() - limit = transaction.database.IN_MAX - cursor.execute(*sql_table.select(Count(sql_table.id))) - product_supplier_count, = cursor.fetchone() - for offset in range(0, product_supplier_count, limit): - cursor.execute(*sql_table.join(company, - condition=sql_table.company == company.id - ).select(sql_table.id, company.currency, - order_by=sql_table.id, - limit=limit, offset=offset)) - for product_supplier_id, currency_id in cursor.fetchall(): - cursor.execute(*sql_table.update( - columns=[sql_table.currency], - values=[currency_id], - where=sql_table.id == product_supplier_id)) - - # Migration from 2.4: drop required on sequence - table.not_null_action('sequence', action='remove') - - # Migration from 2.6: drop required on delivery_time - table.not_null_action('delivery_time', action='remove') - # Migration from 3.8: change delivery_time inte timedelta lead_time if table.column_exist('delivery_time'): cursor.execute(*sql_table.select( diff --git a/purchase.py b/purchase.py index 3e3151dac6..d323877148 100644 --- a/purchase.py +++ b/purchase.py @@ -4,8 +4,7 @@ import datetime from itertools import chain from decimal import Decimal -from sql import Table, Literal, Null -from sql.functions import Overlay, Position +from sql import Literal, Null from sql.aggregate import Count from sql.operators import Concat @@ -277,34 +276,9 @@ class Purchase(Workflow, ModelSQL, ModelView, TaxableMixin): InvoiceLine = pool.get('account.invoice.line') TableHandler = backend.get('TableHandler') cursor = Transaction().connection.cursor() - model_data = Table('ir_model_data') - model_field = Table('ir_model_field') sql_table = cls.__table__() - # Migration from 1.2: packing renamed into shipment - cursor.execute(*model_data.update( - columns=[model_data.fs_id], - values=[Overlay(model_data.fs_id, 'shipment', - Position('packing', model_data.fs_id), - len('packing'))], - where=model_data.fs_id.like('%packing%') - & (model_data.module == module_name))) - cursor.execute(*model_field.update( - columns=[model_field.relation], - values=[Overlay(model_field.relation, 'shipment', - Position('packing', model_field.relation), - len('packing'))], - where=model_field.relation.like('%packing%') - & (model_field.module == module_name))) - cursor.execute(*model_field.update( - columns=[model_field.name], - values=[Overlay(model_field.name, 'shipment', - Position('packing', model_field.name), - len('packing'))], - where=model_field.name.like('%packing%') - & (model_field.module == module_name))) table = cls.__table_handler__(module_name) - table.column_rename('packing_state', 'shipment_state') # Migration from 3.8: if table.column_exist('supplier_reference'): @@ -312,20 +286,7 @@ class Purchase(Workflow, ModelSQL, ModelView, TaxableMixin): table.column_rename('supplier_reference', 'reference') super(Purchase, cls).__register__(module_name) - - # Migration from 1.2: rename packing to shipment in - # invoice_method values - cursor.execute(*sql_table.update( - columns=[sql_table.invoice_method], - values=['shipment'], - where=sql_table.invoice_method == 'packing')) - table = cls.__table_handler__(module_name) - # Migration from 2.2: warehouse is no more required - table.not_null_action('warehouse', 'remove') - - # Migration from 2.2: purchase_date is no more required - table.not_null_action('purchase_date', 'remove') # Migration from 3.2 # state confirmed splitted into confirmed and processing @@ -356,7 +317,6 @@ class Purchase(Workflow, ModelSQL, ModelView, TaxableMixin): where=sql_table.id.in_(sub_query.select(sub_query.id)))) # Add index on create_date - table = cls.__table_handler__(module_name) table.index_action('create_date', action='add') @classmethod @@ -1112,21 +1072,9 @@ class PurchaseLine(sequence_ordered(), ModelSQL, ModelView): @classmethod def __register__(cls, module_name): - cursor = Transaction().connection.cursor() - sql_table = cls.__table__() super(PurchaseLine, cls).__register__(module_name) table = cls.__table_handler__(module_name) - # Migration from 1.0 comment change into note - if table.column_exist('comment'): - cursor.execute(*sql_table.update( - columns=[sql_table.note], - values=[sql_table.comment])) - table.drop_column('comment') - - # Migration from 2.4: drop required on sequence - table.not_null_action('sequence', action='remove') - # Migration from 4.6: drop required on description table.not_null_action('description', action='remove') @@ -1673,20 +1621,6 @@ class HandleShipmentExceptionAsk(ModelView): domain_moves = fields.Many2Many( 'stock.move', None, None, 'Domain Moves') - @classmethod - def __register__(cls, module_name): - cursor = Transaction().connection.cursor() - model = Table('ir_model') - # Migration from 1.2: packing renamed into shipment - cursor.execute(*model.update( - columns=[model.model], - values=[Overlay(model.model, 'shipment', - Position('packing', model.model), - len('packing'))], - where=model.model.like('%packing%') - & (model.module == module_name))) - super(HandleShipmentExceptionAsk, cls).__register__(module_name) - class HandleShipmentException(Wizard): 'Handle Shipment Exception' diff --git a/stock.py b/stock.py index 90e2f80423..ca1c862c20 100644 --- a/stock.py +++ b/stock.py @@ -198,23 +198,6 @@ class Move(metaclass=PoolMeta): ('recreated', 'Recreated'), ], 'Exception State'), 'get_purchase_exception_state') - @classmethod - def __register__(cls, module_name): - cursor = Transaction().connection.cursor() - sql_table = cls.__table__() - - super(Move, cls).__register__(module_name) - - table = cls.__table_handler__(module_name) - - # Migration from 2.6: remove purchase_line - if table.column_exist('purchase_line'): - cursor.execute(*sql_table.update( - columns=[sql_table.origin], - values=[Concat('purchase.line,', sql_table.purchase_line)], - where=sql_table.purchase_line != Null)) - table.drop_column('purchase_line') - @classmethod def _get_origin(cls): models = super(Move, cls)._get_origin()