Remove migration before 3.0
issue6470 review52421002
This commit is contained in:
1 parent
6061d12944
commit
e8168fa7fd
4 files changed
+1
-136
No files matched your search
-24
@@ -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()
|
||||
|
||||
-28
@@ -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(
|
||||
|
||||
+1
-67
@@ -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'
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user