From 8900f729a9127ca19ffe72c3bf18b8af6ec82ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 9 Aug 2018 20:43:51 +0200 Subject: [PATCH] Remove migration before 3.0 issue6470 review52421002 --- invoice.py | 58 +++++-------------------------------------------- party.py | 17 --------------- payment_term.py | 25 --------------------- 3 files changed, 5 insertions(+), 95 deletions(-) diff --git a/invoice.py b/invoice.py index 535bf2975e..b2d97f2c92 100644 --- a/invoice.py +++ b/invoice.py @@ -3,10 +3,9 @@ from decimal import Decimal from collections import defaultdict, namedtuple from itertools import combinations -import base64 -from sql import Literal, Null -from sql.aggregate import Count, Sum +from sql import Null +from sql.aggregate import Sum from sql.conditionals import Coalesce, Case from sql.functions import Round @@ -333,44 +332,6 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin): cursor = transaction.connection.cursor() table = cls.__table_handler__(module_name) - # Migration from 1.2 invoice_date is no more required - table.not_null_action('invoice_date', action='remove') - - # Migration from 2.0 invoice_report renamed into invoice_report_cache - # to remove base64 encoding - - if (table.column_exist('invoice_report') - and table.column_exist('invoice_report_cache')): - limit = transaction.database.IN_MAX - cursor.execute(*sql_table.select(Count(Literal(1)))) - invoice_count, = cursor.fetchone() - for offset in range(0, invoice_count, limit): - cursor.execute(*sql_table.select( - sql_table.id, sql_table.invoice_report, - order_by=sql_table.id, - limit=limit, offset=offset)) - for invoice_id, report in cursor.fetchall(): - if report: - report = fields.Binary.cast( - base64.decodestring(bytes(report))) - cursor.execute(*sql_table.update( - columns=[sql_table.invoice_report_cache], - values=[report], - where=sql_table.id == invoice_id)) - table.drop_column('invoice_report') - - # Migration from 2.6: - # - proforma renamed into validated - # - open renamed into posted - cursor.execute(*sql_table.update( - columns=[sql_table.state], - values=['validated'], - where=sql_table.state == 'proforma')) - cursor.execute(*sql_table.update( - columns=[sql_table.state], - values=['posted'], - where=sql_table.state == 'open')) - # Migration from 3.8: remove invoice/credit note type cursor.execute(*sql_table.select(sql_table.id, where=sql_table.type.like('%_invoice') @@ -413,12 +374,12 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin): values=[type_], where=sql_table.type == '%s_credit_note' % type_)) - # Add index on create_date - table.index_action('create_date', action='add') - # Migration from 4.0: Drop not null on payment_term table.not_null_action('payment_term', 'remove') + # Add index on create_date + table.index_action('create_date', action='add') + @staticmethod def default_type(): return Transaction().context.get('type', 'out') @@ -1761,12 +1722,6 @@ class InvoiceLine(sequence_ordered(), ModelSQL, ModelView, TaxableMixin): cursor = Transaction().connection.cursor() table = cls.__table_handler__(module_name) - # Migration from 1.0 invoice is no more required - table.not_null_action('invoice', action='remove') - - # Migration from 2.4: drop required on sequence - table.not_null_action('sequence', action='remove') - # Migration from 3.4: company is required cursor.execute(*sql_table.join(invoice, condition=sql_table.invoice == invoice.id @@ -2246,9 +2201,6 @@ class InvoiceTax(sequence_ordered(), ModelSQL, ModelView): table = cls.__table_handler__(module_name) - # Migration from 2.4: drop required on sequence - table.not_null_action('sequence', action='remove') - # Migration from 4.6: drop base_sign and tax_sign table.not_null_action('base_sign', action='remove') table.not_null_action('tax_sign', action='remove') diff --git a/party.py b/party.py index 761034bf48..5ede8ffdf6 100644 --- a/party.py +++ b/party.py @@ -37,23 +37,6 @@ class Party(ModelSQL, ModelView): payment_terms = fields.One2Many( 'party.party.payment_term', 'party', "Payment Terms") - @classmethod - def __register__(cls, module_name): - ModelField = Pool().get('ir.model.field') - - # Migration from 2.2: property field payment_term renamed - # to customer_payment_term - fields = ModelField.search([ - ('name', '=', 'payment_term'), - ('model.model', '=', 'party.party') - ]) - if fields: - ModelField.write(fields, { - 'name': 'customer_payment_term', - }) - - super(Party, cls).__register__(module_name) - @classmethod def multivalue_model(cls, field): pool = Pool() diff --git a/payment_term.py b/payment_term.py index 86883d67a7..9c057ee0f0 100644 --- a/payment_term.py +++ b/payment_term.py @@ -145,31 +145,6 @@ class PaymentTermLine(sequence_ordered(), ModelSQL, ModelView): cursor = Transaction().connection.cursor() table = cls.__table_handler__(module_name) - # Migration from 1.0 percent change into percentage - if table.column_exist('percent'): - cursor.execute(*sql_table.update( - columns=[sql_table.percentage], - values=[sql_table.percent * 100])) - table.drop_column('percent') - - # Migration from 2.2 - if table.column_exist('delay'): - cursor.execute(*sql_table.update( - columns=[sql_table.day], - values=[31], - where=sql_table.delay == 'end_month')) - table.drop_column('delay') - lines = cls.search([]) - for line in lines: - if line.percentage: - cls.write([line], { - 'divisor': cls.round(Decimal('100.0') / - line.percentage, cls.divisor.digits[1]), - }) - - # Migration from 2.4: drop required on sequence - table.not_null_action('sequence', action='remove') - # Migration from 3.8: rename percentage into ratio if table.column_exist('percentage'): cursor.execute(*sql_table.update(