changeset c7fa35e52f0d in modules/account_payment_clearing:6.4
details:
https://hg.tryton.org/modules/account_payment_clearing?cmd=changeset&node=c7fa35e52f0d
description:
Add missing migration of payment and group to related_to
issue11462
review413091003
(grafted from 74efe2c7777d2f218ca25ef1e9a1d6475a1ef456)
diffstat:
statement.py | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
diffs (45 lines):
diff -r c676d92b6245 -r c7fa35e52f0d statement.py
--- a/statement.py Mon May 02 17:23:26 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']