changeset 74efe2c7777d in modules/account_payment_clearing:default details: https://hg.tryton.org/modules/account_payment_clearing?cmd=changeset&node=74efe2c7777d description: Add missing migration of payment and group to related_to
issue11462 review413091003 diffstat: statement.py | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-) diffs (45 lines): diff -r d4110b42611b -r 74efe2c7777d statement.py --- a/statement.py Mon May 02 17:23:27 2022 +0200 +++ b/statement.py Sat May 07 11:12:45 2022 +0200 @@ -2,6 +2,9 @@ # this repository contains the full copyright notices and license terms. from collections import defaultdict +from sql import Null +from sql.operators import Concat + from trytond.model import fields from trytond.pool import Pool, PoolMeta from trytond.pyson import Eval, If @@ -113,6 +116,31 @@ ] @classmethod + def __register__(cls, module): + table = cls.__table__() + + super().__register__(module) + + table_h = cls.__table_handler__(module) + cursor = Transaction().connection.cursor() + + # Migration from 6.2: replace payment by related_to + if table_h.column_exist('payment'): + cursor.execute(*table.update( + [table.related_to], + [Concat('account.payment,', table.payment)], + where=table.payment != Null)) + table_h.drop_column('payment') + + # Migration from 6.2: replace payment_group by related_to + if table_h.column_exist('payment_group'): + cursor.execute(*table.update( + [table.related_to], + [Concat('account.payment.group,', table.payment_group)], + where=table.payment_group != Null)) + table_h.drop_column('payment_group') + + @classmethod def _get_relations(cls): return super()._get_relations() + ['account.payment.group']