Clean migrations for series before 6.0

This commit is contained in:
Cédric Krier
2025-01-04 00:19:42 +01:00
parent cbdad75620
commit 1772caec90
57 changed files with 8 additions and 1234 deletions
+3 -248
View File
@@ -11,6 +11,9 @@ a database from another series.
.. note::
If you skip a series, all actions between them must be performed.
.. warning::
You cannot skip more than 2 series ending with ``.0``.
7.6
---
@@ -156,251 +159,3 @@ After
.. code-block:: SQL
ALTER TABLE IF EXISTS "ir_sequence_type" DROP COLUMN IF EXISTS "code";
5.6
---
Before
~~~~~~
* If ``project`` module is activated, update project status based on previous
state:
.. code-block:: SQL
UPDATE "project_work" SET "status" = "db_id" FROM "ir_model_data" WHERE "module" = 'project' AND "fs_id" = 'work_open_status' AND "state" = 'opened';
UPDATE "project_work" SET "status" = "db_id" FROM "ir_model_data" WHERE "module" = 'project' and "fs_id" = 'work_done_status' AND "state" = 'done';
* If ``sale_amendment`` module is activated, the foreign key of shipment_party
of sale amendment must be recreated:
.. code-block:: SQL
ALTER TABLE IF EXISTS "sale_amendment_line" DROP CONSTRAINT IF EXISTS "sale_amendment_line_shipment_party_fkey";
5.4
---
Before
~~~~~~
* If ``account_payment_sepa`` module is activated, replace
``account_payment_sepa_message`` from ``TEXT`` to ``BYTEA``:
.. code-block:: SQL
ALTER TABLE IF EXISTS "account_payment_sepa_message" ALTER COLUMN IF EXISTS "message" TYPE BYTEA USING "message"::BYTEA;
5.2
---
Before
~~~~~~
* Remove ``src_md5`` from ``ir.translation``:
.. code-block:: SQL
ALTER TABLE "ir_translation" DROP CONSTRAINT IF EXISTS "ir_translation_translation_md5_uniq";
ALTER TABLE "ir_translation" DROP COLUMN IF EXISTS "src_md5";
After
~~~~~
* Remove error translations:
.. code-block:: SQL
DELETE FROM "ir_translation" WHERE "type" = 'error';
* Remove old users:
.. code-block:: SQL
DELETE FROM "ir_model_data" WHERE "model" = 'res.user' AND "fs_id" = 'user_chorus' AND "module" = 'account_fr_chorus';
DELETE FROM "ir_model_data" WHERE "model" = 'res.user' AND "fs_id" = 'user_post_clearing_moves' AND "module" = 'account_payment_clearing';
DELETE FROM "ir_model_data" WHERE "model" = 'res.user' AND "fs_id" = 'user_stripe' AND "module" = 'account_payment_stripe';
DELETE FROM "ir_model_data" WHERE "model" = 'res.user' AND "fs_id" = 'user_marketing_automation' AND "module" = 'marketing_automation';
DELETE FROM "ir_model_data" WHERE "model" = 'res.user' AND "fs_id" = 'user_generate_line_consumption' AND "module" = 'sale_subscription';
DELETE FROM "ir_model_data" WHERE "model" = 'res.user' AND "fs_id" = 'user_generate_line_consumption' AND "module" = 'sale_subscription';
DELETE FROM "ir_model_data" WHERE "model" = 'res.user' AND "fs_id" = 'user_generate_invoice' AND "module" = 'sale_subscription';
DELETE FROM "ir_model_data" WHERE "model" = 'res.user' AND "fs_id" = 'user_role' AND "module" = 'user_role';
DELETE FROM "ir_model_data" WHERE "model" = 'res.user' AND "fs_id" = 'user_trigger' AND "module" = 'res';
5.0
---
Before
~~~~~~
* If ``account_product`` module is activated, set an accounting category to all
products which have accounts and taxes defined (see `#3805
<https://bugs.tryton.org/3805>`_).
After
~~~~~
* Remove old users:
.. code-block:: SQL
DELETE FROM "ir_model_data" WHERE "model" = 'res.user' AND "fs_id" = 'user_process_sale' AND "module" = 'sale';
DELETE FROM "ir_model_data" WHERE "model" = 'res.user' AND "fs_id" = 'user_process_purchase' AND "module" = 'purchase';
* If ``account`` module is activated, clean ``account.journal.type`` data:
.. code-block:: SQL
DELETE FROM "ir_model_data" WHERE "model" = 'account.journal.type';
4.8
---
Before
~~~~~~
* Assign any record rules linked to users to a group.
* Add parent language:
.. code-block:: SQL
ALTER TABLE IF EXISTS "ir_lang" ADD COLUMN IF NOT EXISTS "parent" VARCHAR;
* If ``account`` module is activated, update tax line sign:
.. code-block:: SQL
UPDATE "account_tax_line" SET "amount" = -"amount" WHERE "id" IN (SELECT "tl"."id" FROM "account_tax_line" AS "tl" JOIN "account_move_line" AS "ml" ON "tl"."move_line" = "ml"."id" JOIN "account_move" AS "m" ON "ml"."move" = "m"."id" JOIN "account_invoice" AS "i" ON "i"."id" = CAST(SUBSTRING("m"."origin", 17) AS INTEGER) AND "m"."origin" like 'account.invoice,%' WHERE "tl"."amount" > 0 AND "ml"."credit" > 0 AND "i"."type" = 'in');
UPDATE "account_tax_line" SET "amount" = -"amount" WHERE "id" IN (SELECT "tl"."id" FROM "account_tax_line" AS "tl" JOIN "account_move_line" AS "ml" ON "tl"."move_line" = "ml"."id" JOIN "account_move" AS "m" ON "ml"."move" = "m"."id" JOIN "account_invoice" AS "i" ON "i"."id" = CAST(SUBSTRING("m"."origin", 17) AS INTEGER) AND "m"."origin" like 'account.invoice,%' WHERE "tl"."amount" > 0 AND "ml"."debit" > 0 AND "i"."type" = 'out');
After
~~~~~
* If ``account`` module is activated, update tax lines of inactive tax to their
parent:
.. code-block:: SQL
UPDATE "account_tax_line" as "l" SET "tax" = (SELECT "parent" FROM "account_tax" WHERE "account_tax"."id" = "tax") FROM "account_tax" as "t" WHERE "l"."tax" = "t"."id" AND "t"."active" = false;
* If ``account`` module is activated, delete duplicate tax lines:
.. code-block:: SQL
DELETE FROM "account_tax_line" WHERE "id" IN (SELECT MAX("id") FROM "account_tax_line" GROUP BY "tax", "amount", "type", "move_line" HAVING count(*) > 1);
.. note:: Run multiple times until no record are deleted.
* Check taxes and tax codes definitions (inactivate old children taxes and add
them to the right codes)
4.6
---
Before
~~~~~~
* If ``web_user`` module is activated, update to lower case email of web users:
.. code-block:: SQL
UPDATE "web_user" SET "email" = LOWER("email");
4.4
---
Before
~~~~~~
* Remove deprecated modules:
.. code-block:: SQL
DELETE FROM "ir_module" WHERE "name" IN ('webdav', 'calendar', 'calendar_todo', 'calendar_scheduling', 'calendar_classification', 'party_vcarddav');
DELETE FROM "ir_ui_view" WHERE "module" IN ('webdav', 'calendar', 'calendar_todo', 'calendar_scheduling', 'calendar_classification', 'party_vcarddav');
* If ``party`` module is activated, update address formats:
.. code-block:: SQL
UPDATE "party_address_format" SET "format_" = REPLACE("format_", '${district}', '${subdivision}');
* If ``purchase`` module is activated, delete relation between purchase and invoice_line:
.. code-block:: SQL
DROP TABLE IF EXISTS "purchase_invoice_line_rel";
After
~~~~~
* If ``account_asset`` module is activated, the depreciation duration of the
products must be checked for all assets as previous value could not be
migrated (see `#6395 <https://bugs.tryton.org/6395>`_).
* After property migration old model data should be cleared:
.. code-block:: SQL
DELETE FROM "ir_model_data" WHERE "model" = 'ir.property';
4.2
---
Before
~~~~~~
* Language codes have been simplified.
If you want to keep custom translation you must update translation code to
match the new code.
Here is an example for the code change from ``en_US`` to ``en``:
.. code-block:: SQL
UPDATE "ir_translation" SET "lang" = 'en' WHERE "lang" = 'en_US';
UPDATE "ir_configuration" SET "language" = 'en' WHERE "language" = 'en_US';
4.0
---
Before
~~~~~~
* If ``account`` module is activated, change tax sign for credit note:
.. code-block:: SQL
UPDATE "account_tax_template" SET "credit_note_base_sign" = "credit_note_base_sign" * -1, "credit_note_tax_sign" = "credit_note_tax_sign" * -1;
UPDATE "account_tax" SET "credit_note_base_sign" = "credit_note_base_sign" * -1, "credit_note_tax_sign" = "credit_note_tax_sign" * -1;
* If ``project`` module is activated, drop the foreign key constraint
``project_work_work_fkey``:
.. code-block:: SQL
ALTER TABLE IF EXISTS "project_work" DROP CONSTRAINT IF EXISTS "project_work_work_fkey";
After
~~~~~
* If ``product`` module is activated, drop column ``category`` from
``product.template``:
.. code-block:: SQL
ALTER TABLE "product_template" DROP COLUMN IF EXISTS "category";
3.6
---
Before
~~~~~~
* If ``account`` module is activated, update amount second currency with:
.. code-block:: SQL
UPDATE "account_move_line" SET "amount_second_currency" = ("amount_second_currency" * -1) WHERE "amount_second_currency" IS NOT NULL AND SIGN("amount_second_currency") != SIGN("debit" - "credit");
-34
View File
@@ -149,14 +149,6 @@ class TypeTemplate(
childs = fields.One2Many(
'account.account.type.template', 'parent', "Children")
@classmethod
def __register__(cls, module_name):
super().__register__(module_name)
table_h = cls.__table_handler__(module_name)
# Migration from 5.0: remove display_balance
table_h.drop_column('display_balance')
def _get_type_value(self, type=None):
'''
Set the values for account creation.
@@ -275,14 +267,6 @@ class Type(
where=table.receivable | table.payable),
})
@classmethod
def __register__(cls, module_name):
super().__register__(module_name)
table_h = cls.__table_handler__(module_name)
# Migration from 5.0: remove display_balance
table_h.drop_column('display_balance')
@classmethod
def default_template_override(cls):
return False
@@ -698,15 +682,6 @@ class AccountTemplate(
table, (table.debit_type + table.credit_type) == Null),
'account.msg_only_one_debit_credit_types'))
@classmethod
def __register__(cls, module_name):
super().__register__(module_name)
table_h = cls.__table_handler__(module_name)
# Migration from 5.0: remove kind
table_h.drop_column('kind')
def _get_account_value(self, account=None):
'''
Set the values for account creation.
@@ -1003,15 +978,6 @@ class Account(
(table.left, Index.Range(cardinality='high')),
(table.right, Index.Range(cardinality='high'))))
@classmethod
def __register__(cls, module_name):
super().__register__(module_name)
table_h = cls.__table_handler__(module_name)
# Migration from 5.0: remove kind
table_h.drop_column('kind')
@classmethod
def validate_fields(cls, accounts, field_names):
super().validate_fields(accounts, field_names)
-20
View File
@@ -573,17 +573,7 @@ class Reconciliation(ModelSQL, ModelView):
@classmethod
def __register__(cls, module_name):
cursor = Transaction().connection.cursor()
table = cls.__table_handler__(module_name)
sql_table = cls.__table__()
pool = Pool()
Move = pool.get('account.move')
Line = pool.get('account.move.line')
move = Move.__table__()
line = Line.__table__()
line_h = Line.__table_handler__(module_name)
company_exist = table.column_exist('company')
# Migration from 6.6: rename name to number
if table.column_exist('name') and not table.column_exist('number'):
@@ -591,16 +581,6 @@ class Reconciliation(ModelSQL, ModelView):
super().__register__(module_name)
# Migration from 5.8: add company field
if not company_exist and line_h.column_exist('reconciliation'):
value = (line
.join(move, condition=line.move == move.id)
.select(
move.company,
where=line.reconciliation == sql_table.id,
group_by=move.company))
cursor.execute(*sql_table.update([sql_table.company], [value]))
@classmethod
def order_number(cls, tables):
table, _ = tables[None]
+1 -6
View File
@@ -1,11 +1,6 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.pool import Pool
from . import account
def register():
Pool.register(
account.TaxTemplate,
module='account_de_skr03', type_='model')
pass
-40
View File
@@ -1,40 +0,0 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from sql import Table
from trytond.pool import PoolMeta
from trytond.transaction import Transaction
class TaxTemplate(metaclass=PoolMeta):
__name__ = 'account.tax.template'
@classmethod
def __register__(cls, module_name):
cursor = Transaction().connection.cursor()
model_data = Table('ir_model_data')
# Migration from 5.6: Rename main tax ids
if module_name == 'account_de_skr03':
for old_id, new_id in (
('tax_ust_19', 'tax_ust_standard_rate'),
('tax_ust_7', 'tax_ust_reduced_rate'),
('tax_vst_19', 'tax_vst_standard_rate'),
('tax_vst_7', 'tax_vst_reduced_rate'),
('tax_eu_19_purchase', 'tax_purchase_eu_standard_rate'),
('tax_eu_7_purchase', 'tax_purchase_eu_reduced_rate'),
('tax_import_19', 'tax_import_standard_rate'),
('tax_import_7', 'tax_import_reduced_rate'),
):
cursor.execute(*model_data.select(model_data.id,
where=(model_data.fs_id == new_id)
& (model_data.module == module_name)))
if cursor.fetchone():
continue
cursor.execute(*model_data.update(
columns=[model_data.fs_id],
values=[new_id],
where=(model_data.fs_id == old_id)
& (model_data.module == module_name)))
super().__register__(module_name)
-20
View File
@@ -490,21 +490,9 @@ class Invoice(Workflow, ModelSQL, ModelView, TaxableMixin, InvoiceReportMixin):
@classmethod
def __register__(cls, module_name):
sql_table = cls.__table__()
super().__register__(module_name)
transaction = Transaction()
cursor = transaction.connection.cursor()
table = cls.__table_handler__(module_name)
# Migration from 5.6: rename state cancel to cancelled
cursor.execute(*sql_table.update(
[sql_table.state], ['cancelled'],
where=sql_table.state == 'cancel'))
# Migration from 5.8: drop foreign key for sequence
table.drop_fk('sequence')
# Migration from 6.6: drop not null on journal
table.not_null_action('journal', 'remove')
@@ -2427,14 +2415,6 @@ class InvoiceLine(sequence_ordered(), ModelSQL, ModelView, TaxableMixin):
('type.debt', '=', True),
]
@classmethod
def __register__(cls, module_name):
super().__register__(module_name)
table = cls.__table_handler__(module_name)
# Migration from 5.0: remove check constraints
table.drop_constraint('type_account')
table.drop_constraint('type_invoice')
@classmethod
def get_invoice_types(cls):
pool = Pool()
-45
View File
@@ -4,7 +4,6 @@ from decimal import Decimal
from dateutil.relativedelta import relativedelta
from trytond import backend
from trytond.i18n import gettext
from trytond.model import (
Check, DeactivableMixin, ModelSQL, ModelView, fields, sequence_ordered)
@@ -240,50 +239,6 @@ class PaymentTermLineRelativeDelta(sequence_ordered(), ModelSQL, ModelView):
super().__setup__()
cls.__access__.add('line')
@classmethod
def __register__(cls, module_name):
transaction = Transaction()
cursor = transaction.connection.cursor()
pool = Pool()
Month = pool.get('ir.calendar.month')
Day = pool.get('ir.calendar.day')
sql_table = cls.__table__()
month = Month.__table__()
day = Day.__table__()
table_h = cls.__table_handler__(module_name)
# Migration from 5.0: use ir.calendar
migrate_calendar = False
if (backend.TableHandler.table_exist(cls._table)
and table_h.column_exist('month')
and table_h.column_exist('weekday')):
migrate_calendar = (
table_h.column_is_type('month', 'VARCHAR')
or table_h.column_is_type('weekday', 'VARCHAR'))
if migrate_calendar:
table_h.column_rename('month', '_temp_month')
table_h.column_rename('weekday', '_temp_weekday')
super().__register__(module_name)
table_h = cls.__table_handler__(module_name)
# Migration from 5.0: use ir.calendar
if migrate_calendar:
update = transaction.connection.cursor()
cursor.execute(*month.select(month.id, month.index))
for month_id, index in cursor:
update.execute(*sql_table.update(
[sql_table.month], [month_id],
where=sql_table._temp_month == str(index)))
table_h.drop_column('_temp_month')
cursor.execute(*day.select(day.id, day.index))
for day_id, index in cursor:
update.execute(*sql_table.update(
[sql_table.weekday], [day_id],
where=sql_table._temp_weekday == str(index)))
table_h.drop_column('_temp_weekday')
@staticmethod
def default_months():
return 0
@@ -17,21 +17,6 @@ class Invoice(metaclass=PoolMeta):
fields.Timestamp("History DateTime"),
'get_history_datetime')
@classmethod
def __register__(cls, module_name):
super().__register__(module_name)
table_h = cls.__table_handler__(module_name)
table = cls.__table__()
cursor = Transaction().connection.cursor()
# Migration from 5.2: rename open_date into numbered_at
if table_h.column_exist('open_date'):
cursor.execute(
*table.update(
[table.numbered_at],
[table.open_date]))
table_h.drop_column('open_date')
@classmethod
def __setup__(cls):
super().__setup__()
-13
View File
@@ -4,7 +4,6 @@ from trytond.i18n import gettext
from trytond.model import fields
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval
from trytond.transaction import Transaction
from .exceptions import PartyIdentificationdError
@@ -78,18 +77,6 @@ class PartyIdentifier(metaclass=PoolMeta):
'invisible': Eval('type') != 'es_vat',
})
@classmethod
def __register__(cls, module_name):
cursor = Transaction().connection.cursor()
sql_table = cls.__table__()
super().__register__(module_name)
# Migration from 5.4: sepa identifier merged into eu_at_02
cursor.execute(*sql_table.update(
columns=[sql_table.type],
values=['eu_at_02'],
where=sql_table.type == 'sepa'))
@property
def sepa_identifier(self):
identifier = {
-33
View File
@@ -138,14 +138,6 @@ class Journal(metaclass=PoolMeta):
sql_table = cls.__table__()
super().__register__(module_name)
# Migration from 5.4: sepa identifier merged into eu_at_02
for name in {'payable', 'receivable'}:
column = getattr(sql_table, 'sepa_%s_initiator_id' % name)
cursor.execute(*sql_table.update(
columns=[column],
values=['eu_at_02'],
where=column == 'sepa'))
# Migration from 6.8: es_nif renamed into es_vat
cursor.execute(*sql_table.update(
[sql_table.sepa_payable_initiator_id],
@@ -592,18 +584,6 @@ class Mandate(Workflow, ModelSQL, ModelView):
t, (t.state, Index.Equality(cardinality='low')),
where=t.state.in_(['draft', 'requested'])))
@classmethod
def __register__(cls, module_name):
cursor = Transaction().connection.cursor()
table = cls.__table__()
super().__register__(module_name)
# Migration from 5.6: rename state canceled to cancelled
cursor.execute(*table.update(
[table.state], ['cancelled'],
where=table.state == 'canceled'))
@staticmethod
def default_company():
return Transaction().context.get('company')
@@ -868,19 +848,6 @@ class Message(Workflow, ModelSQL, ModelView):
},
})
@classmethod
def __register__(cls, module_name):
transaction = Transaction()
cursor = transaction.connection.cursor()
table = cls.__table__()
super().__register__(module_name)
# Migration from 5.6: rename state canceled to cancelled
cursor.execute(*table.update(
[table.state], ['cancelled'],
where=table.state == 'canceled'))
@staticmethod
def default_type():
return 'in'
-22
View File
@@ -179,19 +179,6 @@ class Statement(Workflow, ModelSQL, ModelView):
readonly=False, instantiate=0, fresh_session=True),
})
@classmethod
def __register__(cls, module_name):
transaction = Transaction()
cursor = transaction.connection.cursor()
sql_table = cls.__table__()
super().__register__(module_name)
# Migration from 5.6: rename state cancel to cancelled
cursor.execute(*sql_table.update(
[sql_table.state], ['cancelled'],
where=sql_table.state == 'cancel'))
@staticmethod
def default_company():
return Transaction().context.get('company')
@@ -1197,15 +1184,6 @@ class Origin(origin_mixin(_states), ModelSQL, ModelView):
information = fields.Dict(
'account.statement.origin.information', "Information", readonly=True)
@classmethod
def __register__(cls, module_name):
table = cls.__table_handler__(module_name)
# Migration from 5.0: rename informations into information
table.column_rename('informations', 'information')
super().__register__(module_name)
@fields.depends('statement', '_parent_statement.id')
def on_change_with_statement_id(self, name=None):
if self.statement:
@@ -168,18 +168,6 @@ class LandedCost(Workflow, ModelSQL, ModelView, MatchMixin):
},
})
@classmethod
def __register__(cls, module_name):
cursor = Transaction().connection.cursor()
sql_table = cls.__table__()
super().__register__(module_name)
# Migration from 5.6: rename state cancel to cancelled
cursor.execute(*sql_table.update(
[sql_table.state], ['cancelled'],
where=sql_table.state == 'cancel'))
@classmethod
def order_number(cls, tables):
table, _ = tables[None]
-9
View File
@@ -103,15 +103,6 @@ class Account(
cls._order.insert(0, ('code', 'ASC'))
cls._order.insert(1, ('name', 'ASC'))
@classmethod
def __register__(cls, module_name):
super().__register__(module_name)
table = cls.__table_handler__(module_name)
# Migration from 5.0: remove display_balance
table.drop_column('display_balance')
@staticmethod
def default_company():
return Transaction().context.get('company')
-8
View File
@@ -56,14 +56,6 @@ class Line(ModelSQL, ModelView):
})
cls._order.insert(0, ('date', 'ASC'))
@classmethod
def __register__(cls, module_name):
super().__register__(module_name)
table = cls.__table_handler__(module_name)
# Migration from 5.0: replace credit_debit constraint by credit_debit_
table.drop_constraint('credit_debit')
@staticmethod
def default_date():
Date = Pool().get('ir.date')
-24
View File
@@ -66,30 +66,6 @@ class Agent(DeactivableMixin, ModelSQL, ModelView):
'company': Eval('company', -1),
})
@classmethod
def __register__(cls, module_name):
pool = Pool()
Company = pool.get('company.company')
sql_table = cls.__table__()
company = Company.__table__()
super().__register__(module_name)
transaction = Transaction()
cursor = transaction.connection.cursor()
table = cls.__table_handler__(module_name)
# Migration from 5.4: Ensure currency is set
# Don't use UPDATE FROM because SQLite does not support it
cursor.execute(*sql_table.update(
columns=[sql_table.currency],
values=[company.select(
company.currency,
where=company.id == sql_table.company)],
where=(sql_table.currency == Null)))
# Migration from 5.4: Add not null on currency
table.not_null_action('currency', 'add')
@fields.depends('active', 'selections', 'company')
def on_change_active(self):
pool = Pool()
-29
View File
@@ -1,6 +1,5 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from sql import Null
from trytond.cache import Cache
from trytond.model import ModelSQL, fields
@@ -119,34 +118,6 @@ class User(metaclass=PoolMeta):
cls._context_fields.insert(0, 'employee')
cls._context_fields.insert(0, 'company_filter')
@classmethod
def __register__(cls, module):
pool = Pool()
UserCompany = pool.get('res.user-company.company')
transaction = Transaction()
table = cls.__table__()
user_company = UserCompany.__table__()
super().__register__(module)
table_h = cls.__table_handler__(module)
cursor = transaction.connection.cursor()
# Migration from 5.8: remove main_company
if table_h.column_exist('main_company'):
cursor.execute(*user_company.insert(
[user_company.user, user_company.company],
table.select(
table.id, table.main_company,
where=table.main_company != Null)))
cursor.execute(*user_company.insert(
[user_company.user, user_company.company],
table.select(
table.id, table.company,
where=(table.company != Null)
& (table.company != table.main_company))))
table_h.drop_column('main_company')
@classmethod
def default_companies(cls):
pool = Pool()
-10
View File
@@ -12,16 +12,6 @@ class Company(metaclass=PoolMeta):
hours_per_work_month = fields.Float("Hours per Work Month")
hours_per_work_year = fields.Float("Hours per Work Year")
@classmethod
def __register__(cls, module):
super().__register__(module)
table_h = cls.__table_handler__(module)
# Migration from 5.8:
for column in ['day', 'week', 'month', 'year']:
table_h.not_null_action(
'hours_per_work_%s' % column, action='remove')
@staticmethod
def default_hours_per_work_day():
return 8
-32
View File
@@ -7,7 +7,6 @@ from sql import Literal
from sql.conditionals import Coalesce
from sql.functions import Position, Substring
from trytond import backend
from trytond.model import DeactivableMixin, ModelSQL, ModelView, fields, tree
from trytond.pool import Pool
from trytond.pyson import Eval, If
@@ -172,19 +171,6 @@ class Country(DeactivableMixin, ModelSQL, ModelView):
super().__setup__()
cls._order.insert(0, ('name', 'ASC'))
@classmethod
def __register__(cls, module_name):
pool = Pool()
Data = pool.get('ir.model.data')
data = Data.__table__()
cursor = Transaction().connection.cursor()
super().__register__(module_name)
# Migration from 5.2: remove country data
cursor.execute(*data.delete(where=(data.module == 'country')
& (data.model == cls.__name__)))
@fields.depends('code')
def on_change_with_flag(self, name=None):
if self.code:
@@ -426,19 +412,10 @@ class Subdivision(DeactivableMixin, ModelSQL, ModelView):
@classmethod
def __register__(cls, module_name):
pool = Pool()
Data = pool.get('ir.model.data')
data = Data.__table__()
cursor = Transaction().connection.cursor()
super().__register__(module_name)
table_h = cls.__table_handler__(module_name)
# Migration from 5.2: remove country data
cursor.execute(*data.delete(where=(data.module == 'country')
& (data.model == cls.__name__)))
# Migration from 6.2: remove type required
table_h.not_null_action('type', action='remove')
@@ -526,15 +503,6 @@ class PostalCode(ModelSQL, ModelView):
cls._order.insert(0, ('country', 'ASC'))
cls._order.insert(0, ('postal_code', 'ASC'))
@classmethod
def __register__(cls, module):
# Migration from 5.8: rename zip to postal_code
backend.TableHandler.table_rename('country_zip', cls._table)
table_h = cls.__table_handler__(module)
table_h.column_rename('zip', 'postal_code')
super().__register__(module)
def get_rec_name(self, name):
if self.city and self.postal_code:
return '%s (%s)' % (self.city, self.postal_code)
-9
View File
@@ -75,19 +75,10 @@ class Currency(
@classmethod
def __register__(cls, module_name):
pool = Pool()
Data = pool.get('ir.model.data')
data = Data.__table__()
cursor = Transaction().connection.cursor()
super().__register__(module_name)
table_h = cls.__table_handler__(module_name)
# Migration from 5.2: remove country data
cursor.execute(*data.delete(where=(data.module == 'currency')
& (data.model == cls.__name__)))
# Migration from 6.6: remove required on symbol
table_h.not_null_action('symbol', 'remove')
-44
View File
@@ -4,7 +4,6 @@
from string import Template
from sql import Literal
from sql.functions import Substring
from sql.operators import Equal
from trytond.cache import Cache
@@ -80,15 +79,6 @@ class Address(
autocomplete_city=RPC(instantiate=0, cache=dict(days=1)),
)
@classmethod
def __register__(cls, module_name):
table = cls.__table_handler__(module_name)
# Migration from 5.8: rename zip to postal code
table.column_rename('zip', 'postal_code')
super().__register__(module_name)
@fields.depends('street')
def on_change_with_street_single_line(self, name=None):
if self.street:
@@ -298,40 +288,6 @@ class AddressFormat(DeactivableMixin, MatchMixin, ModelSQL, ModelView):
cls._order.insert(0, ('country_code', 'ASC NULLS LAST'))
cls._order.insert(1, ('language_code', 'ASC NULLS LAST'))
@classmethod
def __register__(cls, module_name):
pool = Pool()
Country = pool.get('country.country')
Language = pool.get('ir.lang')
country = Country.__table__()
language = Language.__table__()
table = cls.__table__()
cursor = Transaction().connection.cursor()
super().__register__(module_name)
table_h = cls.__table_handler__()
# Migration from 5.2: replace country by country_code
if table_h.column_exist('country'):
query = table.update(
[table.country_code],
country.select(
country.code,
where=country.id == table.country))
cursor.execute(*query)
table_h.drop_column('country')
# Migration from 5.2: replace language by language_code
if table_h.column_exist('language'):
query = table.update(
[table.language_code],
language.select(
Substring(language.code, 0, 2),
where=language.id == table.language))
cursor.execute(*query)
table_h.drop_column('language')
@classmethod
def default_format_(cls):
return """${attn}
-4
View File
@@ -833,10 +833,6 @@ class Identifier(sequence_ordered(), DeactivableMixin, ModelSQL, ModelView):
super().__register__(module_name)
# Migration from 5.8: Rename cn_rit into cn_ric
cursor.execute(*table.update([table.type], ['cn_ric'],
where=(table.type == 'cn_rit')))
# Migration from 6.8: Use vat alias
for old in IDENTIFIER_VAT:
new = replace_vat(old)
-16
View File
@@ -504,22 +504,6 @@ class Product(
if isinstance(tfield, fields.One2Many):
getattr(cls, attr).setter = '_set_template_function'
@classmethod
def __register__(cls, module):
table = cls.__table__()
table_h = cls.__table_handler__(module)
fill_suffix_code = (
table_h.column_exist('code')
and not table_h.column_exist('suffix_code'))
super().__register__(module)
cursor = Transaction().connection.cursor()
# Migration from 5.4: split code into prefix/suffix
if fill_suffix_code:
cursor.execute(*table.update(
[table.suffix_code],
[table.code]))
@classmethod
def _set_template_function(cls, products, name, value):
# Prevent NotImplementedError for One2Many
-8
View File
@@ -274,14 +274,6 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
super().__register__(module_name)
table = cls.__table__()
cursor = Transaction().connection.cursor()
# Migration from 5.6: rename state cancel to cancelled
cursor.execute(*table.update(
[table.state], ['cancelled'],
where=table.state == 'cancel'))
@classmethod
def order_number(cls, tables):
table, _ = tables[None]
-9
View File
@@ -166,15 +166,6 @@ class Work(sequence_ordered(), ModelSQL, ModelView):
},
})
@classmethod
def __register__(cls, module_name):
super().__register__(module_name)
table = cls.__table_handler__(module_name)
# Migration from 5.4: Drop not null on work_center
table.not_null_action('work_center', 'remove')
@fields.depends('operation')
def on_change_with_work_center_category(self, name=None):
return self.operation.work_center_category if self.operation else None
-3
View File
@@ -230,9 +230,6 @@ class Work(sequence_ordered(), tree(separator='\\'), ModelSQL, ModelView):
super().__register__(module_name)
# Migration from 5.4: replace state by status
table_project_work.not_null_action('state', action='remove')
# Migration from 6.0: remove left and right
table_project_work.drop_column('left')
table_project_work.drop_column('right')
-25
View File
@@ -9,8 +9,6 @@ from itertools import groupby
from sql import Cast, Null
from sql.aggregate import Sum
from sql.conditionals import NullIf
from sql.functions import Extract
from sql.operators import Concat
from trytond import backend
@@ -674,29 +672,6 @@ class WorkInvoicedProgress(ModelView, ModelSQL):
invoice_line = fields.Many2One('account.invoice.line', 'Invoice Line',
ondelete='CASCADE')
@classmethod
def __register__(cls, module_name):
cursor = Transaction().connection.cursor()
table = cls.__table_handler__(module_name)
sql_table = cls.__table__()
pool = Pool()
Work = pool.get('project.work')
work = Work.__table__()
created_progress = not table.column_exist('progress')
effort_exist = table.column_exist('effort_duration')
super().__register__(module_name)
# Migration from 5.0: Effort renamed into to progress
if created_progress and effort_exist:
# Don't use UPDATE FROM because SQLite does not support it.
value = work.select(
(Extract('EPOCH', sql_table.effort_duration)
/ NullIf(Extract('EPOCH', work.effort_duration), 0)),
where=work.id == sql_table.work)
cursor.execute(*sql_table.update([sql_table.progress], [value]))
class OpenInvoice(Wizard):
__name__ = 'project.open_invoice'
-11
View File
@@ -381,17 +381,6 @@ class ProductSupplier(
Index(t, (t.code, Index.Similarity())),
})
@classmethod
def __register__(cls, module_name):
table = cls.__table_handler__(module_name)
# Migration from 5.0: add product/template
if (table.column_exist('product')
and not table.column_exist('template')):
table.column_rename('product', 'template')
super().__register__(module_name)
@staticmethod
def default_company():
return Transaction().context.get('company')
-5
View File
@@ -360,11 +360,6 @@ class Purchase(
super().__register__(module_name)
# Migration from 5.6: rename state cancel to cancelled
cursor.execute(*sql_table.update(
[sql_table.state], ['cancelled'],
where=sql_table.state == 'cancel'))
# Migration from 6.6: rename invoice state waiting to pending
cursor.execute(*sql_table.update(
[sql_table.invoice_state], ['pending'],
@@ -123,7 +123,6 @@ class PurchaseRequest(ModelSQL, ModelView):
@classmethod
def __register__(cls, module_name):
request = cls.__table__()
table_h = cls.__table_handler__(module_name)
# Migration from 6.8: rename uom to unit
@@ -138,13 +137,6 @@ class PurchaseRequest(ModelSQL, ModelView):
super().__register__(module_name)
cursor = Transaction().connection.cursor()
# Migration from 5.6: rename state cancel to cancelled
cursor.execute(*request.update(
[request.state], ['cancelled'],
where=request.state == 'cancel'))
def get_rec_name(self, name):
pool = Pool()
Lang = pool.get('ir.lang')
-12
View File
@@ -191,18 +191,6 @@ class PurchaseRequisition(Workflow, ModelSQL, ModelView):
cls._states_cached = ['approved', 'done', 'rejected',
'processing', 'cancelled']
@classmethod
def __register__(cls, module_name):
cursor = Transaction().connection.cursor()
table = cls.__table__()
super().__register__(module_name)
# Migration from 5.6: rename state cancel to cancelled
cursor.execute(*table.update(
[table.state], ['cancelled'],
where=table.state == 'cancel'))
@classmethod
def order_number(cls, tables):
table, _ = tables[None]
-5
View File
@@ -433,11 +433,6 @@ class Sale(
super().__register__(module_name)
# Migration from 5.6: rename state cancel to cancelled
cursor.execute(*sql_table.update(
[sql_table.state], ['cancelled'],
where=sql_table.state == 'cancel'))
# Migration from 6.6: rename invoice state waiting to pending
cursor.execute(*sql_table.update(
[sql_table.invoice_state], ['pending'],
-3
View File
@@ -138,9 +138,6 @@ class SaleOpportunity(
super().__register__(module_name)
# Migration from 5.0: drop required on description
table.not_null_action('description', action='remove')
# Migration from 6.4: store currency
if not currency_exists:
value = company.select(
-3
View File
@@ -96,9 +96,6 @@ class Sale(metaclass=PoolMeta):
table = cls.__table__()
super().__register__(module)
table_h = cls.__table_handler__(module)
# Migration from 5.8: remove required on shipment_cost_method
table_h.not_null_action('shipment_cost_method', 'remove')
# Migration from 6.6: shipment_cost_method domain
cursor.execute(*table.update(
-8
View File
@@ -181,14 +181,6 @@ class ShipmentOut(ShipmentCostSaleMixin, metaclass=PoolMeta):
cursor = Transaction().connection.cursor()
table = cls.__table__()
# Migration from 5.8: rename cost into cost_sale
if (table_h.column_exist('cost')
and not table_h.column_exist('cost_sale')):
table_h.column_rename('cost', 'cost_sale')
if (table_h.column_exist('cost_currency')
and not table_h.column_exist('cost_sale_currency')):
table_h.column_rename('cost_currency', 'cost_sale_currency')
# Migration from 7.2: use suffix sale
table_h.column_rename('cost_method', 'cost_sale_method')
table_h.column_rename('cost_invoice_line', 'cost_sale_invoice_line')
-22
View File
@@ -108,28 +108,6 @@ class RecurrenceRule(ModelSQL, ModelView):
super().__setup__()
cls.__access__.add('set_')
@classmethod
def __register__(cls, module_name):
pool = Pool()
Day = pool.get('ir.calendar.day')
day = Day.__table__()
transaction = Transaction()
table = cls.__table__()
super().__register__(module_name)
table_h = cls.__table_handler__(module_name)
# Migration from 5.0: replace wkst by week_start_day
if table_h.column_exist('wkst'):
cursor = transaction.connection.cursor()
update = transaction.connection.cursor()
cursor.execute(*day.select(day.id, day.index))
for day_id, index in cursor:
update.execute(*table.update(
[table.week_start_day], [day_id],
where=table.wkst == str(index)))
table_h.drop_column('wkst')
@classmethod
def default_interval(cls):
return 1
+1 -31
View File
@@ -4,7 +4,7 @@ import datetime
from itertools import groupby
from sql import Literal, Null, operators
from sql.conditionals import Case, Coalesce
from sql.conditionals import Coalesce
from sql.functions import CharLength
from trytond.i18n import gettext
@@ -210,18 +210,6 @@ class Subscription(Workflow, ModelSQL, ModelView):
},
})
@classmethod
def __register__(cls, module_name):
cursor = Transaction().connection.cursor()
table = cls.__table__()
super().__register__(module_name)
# Migration from 5.6: rename state canceled to cancelled
cursor.execute(*table.update(
[table.state], ['cancelled'],
where=table.state == 'canceled'))
@classmethod
def order_number(cls, tables):
table, _ = tables[None]
@@ -612,24 +600,6 @@ class Line(sequence_ordered(), ModelSQL, ModelView):
super().__setup__()
cls.__access__.add('subscription')
@classmethod
def __register__(cls, module):
transaction = Transaction()
cursor = transaction.connection.cursor()
table = cls.__table__()
super().__register__(module)
table_h = cls.__table_handler__(module)
# Migration from 5.2: replace consumed by consumed_until
if table_h.column_exist('consumed'):
cursor.execute(*table.update(
[table.consumed_until],
[Case((table.consumed, Coalesce(
table.next_consumption_date,
table.end_date)), else_=Null)]))
table_h.drop_column('consumed')
@classmethod
def get_subscription_states(cls):
pool = Pool()
@@ -142,23 +142,6 @@ class ShipmentDrop(
('cancelled', 'Cancelled'),
], "State", readonly=True, sort=False)
@classmethod
def __register__(cls, module_name):
table = cls.__table__()
cursor = Transaction().connection.cursor()
table_h = cls.__table_handler__(module_name)
# Migration from 5.8: rename code into number
if table_h.column_exist('code'):
table_h.column_rename('code', 'number')
super().__register__(module_name)
# Migration from 5.6: rename state cancel to cancelled
cursor.execute(*table.update(
[table.state], ['cancelled'],
where=table.state == 'cancel'))
@classmethod
def __setup__(cls):
super().__setup__()
-16
View File
@@ -99,22 +99,6 @@ class Inventory(Workflow, ModelSQL, ModelView):
},
})
@classmethod
def __register__(cls, module_name):
super().__register__(module_name)
cursor = Transaction().connection.cursor()
table = cls.__table_handler__(module_name)
sql_table = cls.__table__()
# Migration from 5.4: remove lost_found
table.not_null_action('lost_found', 'remove')
# Migration from 5.6: rename state cancel to cancelled
cursor.execute(*sql_table.update(
[sql_table.state], ['cancelled'],
where=sql_table.state == 'cancel'))
@classmethod
def order_number(cls, tables):
table, _ = tables[None]
-7
View File
@@ -479,8 +479,6 @@ class Move(Workflow, ModelSQL, ModelView):
@classmethod
def __register__(cls, module_name):
cursor = Transaction().connection.cursor()
sql_table = cls.__table__()
table_h = cls.__table_handler__(module_name)
# Migration from 6.8: rename uom to unit
@@ -490,11 +488,6 @@ class Move(Workflow, ModelSQL, ModelView):
super().__register__(module_name)
# Migration from 5.6: rename state cancel to cancelled
cursor.execute(*sql_table.update(
[sql_table.state], ['cancelled'],
where=sql_table.state == 'cancel'))
@classmethod
def get_product_types(cls):
return ['goods', 'assets']
-43
View File
@@ -498,11 +498,6 @@ class ShipmentIn(
super().__register__(module_name)
# Migration from 5.6: rename state cancel to cancelled
cursor.execute(*sql_table.update(
[sql_table.state], ['cancelled'],
where=sql_table.state == 'cancel'))
# Migration from 6.6: fill warehouse locations
cursor.execute(*sql_table.update(
[sql_table.warehouse_input],
@@ -913,18 +908,6 @@ class ShipmentInReturn(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
'assign_force': {},
})
@classmethod
def __register__(cls, module_name):
cursor = Transaction().connection.cursor()
sql_table = cls.__table__()
super().__register__(module_name)
# Migration from 5.6: rename state cancel to cancelled
cursor.execute(*sql_table.update(
[sql_table.state], ['cancelled'],
where=sql_table.state == 'cancel'))
@staticmethod
def default_state():
return 'draft'
@@ -1377,21 +1360,11 @@ class ShipmentOut(
pool = Pool()
Location = pool.get('stock.location')
cursor = Transaction().connection.cursor()
table = cls.__table_handler__(module_name)
sql_table = cls.__table__()
location = Location.__table__()
# Migration from 5.6: rename assigned_by into picked_by
if table.column_exist('assigned_by'):
table.column_rename('assigned_by', 'picked_by')
super().__register__(module_name)
# Migration from 5.6: rename state cancel to cancelled
cursor.execute(*sql_table.update(
[sql_table.state], ['cancelled'],
where=sql_table.state == 'cancel'))
# Migration from 6.6: fill warehouse locations
cursor.execute(*sql_table.update(
[sql_table.warehouse_storage],
@@ -2035,11 +2008,6 @@ class ShipmentOutReturn(
super().__register__(module_name)
# Migration from 5.6: rename state cancel to cancelled
cursor.execute(*sql_table.update(
[sql_table.state], ['cancelled'],
where=sql_table.state == 'cancel'))
# Migration from 6.4: remove required on contact_address
table.not_null_action('contact_address', 'remove')
@@ -2557,17 +2525,6 @@ class ShipmentInternal(
'assign_force': {},
})
@classmethod
def __register__(cls, module_name):
cursor = Transaction().connection.cursor()
sql_table = cls.__table__()
super().__register__(module_name)
# Migration from 5.6: rename state cancel to cancelled
cursor.execute(*sql_table.update(
[sql_table.state], ['cancelled'],
where=sql_table.state == 'cancel'))
@classmethod
def order_effective_date(cls, tables):
table, _ = tables[None]
-23
View File
@@ -110,23 +110,6 @@ class Forecast(Workflow, ModelSQL, ModelView):
})
cls._active_field = 'active'
@classmethod
def __register__(cls, module_name):
cursor = Transaction().connection.cursor()
sql_table = cls.__table__()
super().__register__(module_name)
table = cls.__table_handler__(module_name)
# Migration from 5.0: remove check_from_to_date
table.drop_constraint('check_from_to_date')
# Migration from 5.6: rename state cancel to cancelled
cursor.execute(*sql_table.update(
[sql_table.state], ['cancelled'],
where=sql_table.state == 'cancel'))
@staticmethod
def default_state():
return 'draft'
@@ -320,12 +303,6 @@ class ForecastLine(ModelSQL, ModelView):
super().__register__(module_name)
table_h = cls.__table_handler__(module_name)
# Migration from 5.0: remove check on quantity
table_h.drop_constraint('check_line_qty_pos')
table_h.drop_constraint('check_line_minimal_qty')
@staticmethod
def default_minimal_quantity():
return 1.0
-44
View File
@@ -1,12 +1,9 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from sql import Table
from trytond.config import config
from trytond.model import ModelSQL, ValueMixin, fields
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval, Id
from trytond.transaction import Transaction
class Configuration(metaclass=PoolMeta):
@@ -58,47 +55,6 @@ class Template(metaclass=PoolMeta):
},
help="The sequence used to automatically number lots.")
@classmethod
def __register__(cls, module):
connection = Transaction().connection
cursor = connection.cursor()
super().__register__(module)
table_h = cls.__table_handler__(module)
template_lot_type_table_name = config.get(
'table', 'product.template-stock.lot.type',
default='product.template-stock.lot.type' .replace('.', '_'))
lot_type_table_name = config.get(
'table', 'stock.lot.type',
default='stock.lot.type'.replace('.', '_'))
# Migration from 5.2: fill lot_required
if (table_h.table_exist(template_lot_type_table_name)
and table_h.table_exist(lot_type_table_name)):
table = cls.__table__()
template_lot_type = Table(template_lot_type_table_name)
lot_type = Table(lot_type_table_name)
cursor_select = connection.cursor()
cursor_select.execute(*template_lot_type.select(
template_lot_type.template,
distinct_on=template_lot_type.template))
for template_id, in cursor_select:
cursor.execute(*template_lot_type
.join(lot_type,
condition=template_lot_type.type == lot_type.id)
.select(
lot_type.code,
where=template_lot_type.template == template_id))
value = cls.lot_required.sql_format([t for t, in cursor])
cursor.execute(*table.update(
[table.lot_required], [value],
where=table.id == template_id))
table_h.drop_table('product.template-stock.lot.type',
template_lot_type_table_name)
table_h.drop_table('stock.lot.type', lot_type_table_name)
@classmethod
def default_lot_sequence(cls, **pattern):
pool = Pool()
+1 -22
View File
@@ -1,7 +1,6 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from sql import Cast, Literal
from sql.functions import CharLength, Position, Substring
from sql.functions import CharLength
from trytond.i18n import gettext
from trytond.model import (
@@ -233,11 +232,7 @@ class Package(tree(), MeasurementsMixin, ModelSQL, ModelView):
@classmethod
def __register__(cls, module):
pool = Pool()
table_h = cls.__table_handler__(module)
table = cls.__table__()
company_exist = table_h.column_exist('company')
cursor = Transaction().connection.cursor()
# Migration from 6.8: rename code to number
if table_h.column_exist('code'):
@@ -245,22 +240,6 @@ class Package(tree(), MeasurementsMixin, ModelSQL, ModelView):
super().__register__(module)
# Migration from 5.8: add company
if not company_exist:
shipment_id = Cast(Substring(
table.shipment,
Position(',', table.shipment) + Literal(1)),
cls.id.sql_type().base)
for name in cls._get_shipment():
Shipment = pool.get(name)
shipment = Shipment.__table__()
value = (shipment
.select(shipment.company,
where=shipment.id == shipment_id))
cursor.execute(*table.update(
[table.company], [value],
where=table.shipment.like(name + ',%')))
@classmethod
def order_number(cls, tables):
table, _ = tables[None]
-32
View File
@@ -2,8 +2,6 @@
# this repository contains the full copyright notices and license terms.
import mimetypes
from sql import Column
from trytond.config import config
from trytond.i18n import gettext
from trytond.model import ModelView, Workflow, fields
@@ -62,36 +60,6 @@ class Package(metaclass=PoolMeta):
'depends': ['shipping_label'],
})
@classmethod
def __register__(cls, module_name):
pool = Pool()
PackageType = pool.get('stock.package.type')
cursor = Transaction().connection.cursor()
table = cls.__table__()
package_type = PackageType.__table__()
table_h = cls.__table_handler__(module_name)
dimension_columns = [
'length', 'length_uom',
'height', 'height_uom',
'width', 'width_uom']
dimension_exists = any(
table_h.column_exist(c) for c in dimension_columns)
super().__register__(module_name)
# Migration from 5.8: Update dimensions on package from package_type
if not dimension_exists:
columns = []
values = []
for c in dimension_columns:
columns.append(Column(table, c))
values.append(package_type.select(
Column(package_type, c),
where=package_type.id == table.type))
cursor.execute(*table.update(
columns=columns,
values=values))
@fields.depends('shipment')
def on_change_with_has_shipping_service(self, name=None):
return bool(
@@ -34,15 +34,6 @@ class ProductLocation(sequence_ordered(), ModelSQL, ModelView, MatchMixin):
[Eval('warehouse')], [])),
])
@classmethod
def __register__(cls, module_name):
table = cls.__table_handler__(module_name)
super().__register__(module_name)
# Migration from 5.6: Add template on locations
table.not_null_action('product', 'remove')
@fields.depends('product', '_parent_product.template')
def on_change_product(self):
if self.product:
+1 -24
View File
@@ -3,8 +3,7 @@
import datetime
from trytond.model import ModelSQL, fields
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
from trytond.pool import PoolMeta
class ProductSupplier(metaclass=PoolMeta):
@@ -47,25 +46,3 @@ class ProductSupplierDay(ModelSQL):
'purchase.product_supplier', 'Supplier',
required=True, ondelete='CASCADE')
day = fields.Many2One('ir.calendar.day', "Day", required=True)
@classmethod
def __register__(cls, module_name):
pool = Pool()
Day = pool.get('ir.calendar.day')
day = Day.__table__()
transaction = Transaction()
table = cls.__table__()
super().__register__(module_name)
table_h = cls.__table_handler__(module_name)
# Migration from 5.0: replace weekday by day
if table_h.column_exist('weekday'):
cursor = transaction.connection.cursor()
update = transaction.connection.cursor()
cursor.execute(*day.select(day.id, day.index))
for day_id, index in cursor:
update.execute(*table.update(
[table.day], [day_id],
where=table.weekday == str(index)))
table_h.drop_column('weekday')
-18
View File
@@ -1022,15 +1022,6 @@ class ActionActWindowView(
super().__setup__()
cls.__access__.add('act_window')
@classmethod
def __register__(cls, module_name):
super().__register__(module_name)
table = cls.__table_handler__(module_name)
# Migration from 5.0: remove required on sequence
table.not_null_action('sequence', 'remove')
@fields.depends('act_window', '_parent_act_window.res_model')
def on_change_with_model(self, name=None):
if self.act_window:
@@ -1070,15 +1061,6 @@ class ActionActWindowDomain(
super().__setup__()
cls.__access__.add('act_window')
@classmethod
def __register__(cls, module_name):
super().__register__(module_name)
table = cls.__table_handler__(module_name)
# Migration from 5.0: remove required on sequence
table.not_null_action('sequence', 'remove')
@classmethod
def default_count(cls):
return False
-14
View File
@@ -114,20 +114,6 @@ class Cron(DeactivableMixin, ModelSQL, ModelView):
})
cls._sql_indexes.add(Index(table, (table.next_call, Index.Range())))
@classmethod
def __register__(cls, module_name):
super().__register__(module_name)
table_h = cls.__table_handler__(module_name)
# Migration from 5.0: remove fields
for column in ['name', 'user', 'request_user', 'number_calls',
'repeat_missed', 'model', 'function', 'args']:
table_h.drop_column(column)
# Migration from 5.0: remove required on next_call
table_h.not_null_action('next_call', 'remove')
@classmethod
def default_timezone(cls):
return tz.SERVER.tzname(datetime.datetime.now())
-3
View File
@@ -1416,9 +1416,6 @@ class ModelData(
table_h = cls.__table_handler__(module_name)
# Migration from 5.0: remove required on db_id
table_h.not_null_action('db_id', action='remove')
# Migration from 7.4: replace fs_id_module_model_uniq
table_h.drop_constraint('fs_id_module_model_uniq')
-9
View File
@@ -317,15 +317,6 @@ class ModuleConfigWizardItem(sequence_ordered(), ModelSQL, ModelView):
('done', 'Done'),
], string="State", required=True, sort=False)
@classmethod
def __register__(cls, module_name):
super().__register__(module_name)
table = cls.__table_handler__(module_name)
# Migration from 5.0: remove required on sequence
table.not_null_action('sequence', 'remove')
@staticmethod
def default_state():
return 'open'
-30
View File
@@ -39,15 +39,6 @@ class SequenceType(ModelSQL, ModelView):
'ir.sequence.type-res.group', 'sequence_type', 'group', "Groups",
help="Groups allowed to edit the sequences of this type.")
@classmethod
def __register__(cls, module):
super().__register__(module)
table_h = cls.__table_handler__(module)
# Migration from 5.8: remove code
# We keep the column until ir.sequence has been migrated
table_h.not_null_action('code', action='remove')
class SequenceTypeGroup(ModelSQL):
__name__ = 'ir.sequence.type-res.group'
@@ -132,27 +123,6 @@ class Sequence(DeactivableMixin, ModelSQL, ModelView):
'Timestamp rounding should be greater than 0'),
]
@classmethod
def __register__(cls, module):
pool = Pool()
SequenceType = pool.get('ir.sequence.type')
cursor = Transaction().connection.cursor()
table = cls.__table__()
sequence_type = SequenceType.__table__()
super().__register__(module)
table_h = cls.__table_handler__(module)
# Migration from 5.8: replace code by sequence_type
if table_h.column_exist('code'):
cursor.execute(*table.update(
[table.sequence_type],
sequence_type.select(
sequence_type.id,
where=sequence_type.code == table.code)))
table_h.drop_column('code')
@staticmethod
def default_type():
return 'incremental'
-17
View File
@@ -133,17 +133,6 @@ class Translation(
(table.type, Index.Equality(cardinality='low'))),
})
@classmethod
def __register__(cls, module_name):
table = cls.__table_handler__(module_name)
# Migration from 5.0: remove src_md5
if table.column_exist('src_md5'):
table.drop_constraint('translation_md5_uniq')
table.drop_column('src_md5')
super().__register__(module_name)
@classmethod
def register_model(cls, model, module_name):
cursor = Transaction().connection.cursor()
@@ -841,9 +830,6 @@ class Translation(
('module', '=', module),
], order=[])
for translation in module_translations:
# Migration from 5.0: ignore error type
if translation.type == 'error':
continue
key = translation.unique_key
if not key:
raise ValueError('Unknow translation type: %s' %
@@ -906,9 +892,6 @@ class Translation(
if entry.obsolete:
continue
translation, res_id = cls.from_poentry(entry)
# Migration from 5.0: ignore error type
if translation.type == 'error':
continue
translation.lang = lang
translation.module = module
noupdate = False
-24
View File
@@ -6,7 +6,6 @@ import time
from sql import Literal, Select
from sql.aggregate import Count, Max
from sql.functions import CurrentTimestamp
from sql.operators import Concat
from trytond.cache import Cache
from trytond.i18n import gettext
@@ -90,29 +89,6 @@ class Trigger(DeactivableMixin, ModelSQL, ModelView):
]
cls._order.insert(0, ('name', 'ASC'))
@classmethod
def __register__(cls, module_name):
super().__register__(module_name)
cursor = Transaction().connection.cursor()
table_h = cls.__table_handler__(module_name)
sql_table = cls.__table__()
# Migration from 5.4: merge action
if (table_h.column_exist('action_model')
and table_h.column_exist('action_function')):
pool = Pool()
Model = pool.get('ir.model')
model = Model.__table__()
action_model = model.select(
model.name, where=model.id == sql_table.action_model)
cursor.execute(*sql_table.update(
[sql_table.action],
[Concat(action_model, Concat(
'|', sql_table.action_function))]))
table_h.drop_column('action_model')
table_h.drop_column('action_function')
@classmethod
def validate_fields(cls, triggers, field_names):
super().validate_fields(triggers, field_names)
-9
View File
@@ -30,15 +30,6 @@ class Icon(
'list_icons': RPC(),
})
@classmethod
def __register__(cls, module_name):
super().__register__(module_name)
table = cls.__table_handler__(module_name)
# Migration from 5.0: remove required on sequence
table.not_null_action('sequence', 'remove')
@staticmethod
def default_module():
return Transaction().context.get('module') or ''
-8
View File
@@ -753,14 +753,6 @@ class ViewSearch(
'unset': RPC(check_access=False, readonly=False),
})
@classmethod
def __register__(cls, module):
super().__register__(module)
table_h = cls.__table_handler__(module)
# Migration from 5.6: remove user required
table_h.not_null_action('user', 'remove')
@staticmethod
def default_user():
return Transaction().user
+1 -8
View File
@@ -484,10 +484,6 @@ class ModelSQL(ModelStorage):
if cls._history:
history_table.add_column(field_name, field._sql_type)
if isinstance(field, (fields.Integer, fields.Float)):
# migration from tryton 2.2
table.db_default(field_name, None)
if isinstance(field, (fields.Boolean)):
table.db_default(field_name, False)
@@ -505,10 +501,7 @@ class ModelSQL(ModelStorage):
backend.TableHandler(ref_model)
else:
ref = None
if field_name in ['create_uid', 'write_uid']:
# migration from 3.6
table.drop_fk(field_name)
elif ref:
if ref and field_name not in ['create_uid', 'write_uid']:
table.add_fk(field_name, ref, on_delete=field.ondelete)
required = field.required
-11
View File
@@ -193,20 +193,9 @@ class User(avatar_mixin(100, 'login'), DeactivableMixin, ModelSQL, ModelView):
@classmethod
def __register__(cls, module_name):
pool = Pool()
ModelData = pool.get('ir.model.data')
model_data = ModelData.__table__()
table_h = cls.__table_handler__(module_name)
cursor = Transaction().connection.cursor()
super().__register__(module_name)
# Migration from 5.6: Set noupdate to admin
cursor.execute(*model_data.update(
[model_data.noupdate], [True],
where=(model_data.model == cls.__name__)
& (model_data.module == 'res')
& (model_data.fs_id == 'user_admin')))
# Migration from 7.4: remove required on menu
table_h.not_null_action('menu', 'remove')