Cédric Krier pushed to branch branch/default at Tryton / Tryton


Commits:
299ba047 by Cédric Krier at 2023-07-28T01:03:10+02:00
Drop notification email log table after migration

And use the configured table name if set.

Closes #12438
- - - - -


1 changed file:

- modules/notification_email/ir.py


Changes:

=====================================
modules/notification_email/ir.py
=====================================
@@ -4,6 +4,7 @@
 from sql import Table
 
 from trytond import backend
+from trytond.config import config
 from trytond.model import fields
 from trytond.pool import Pool, PoolMeta
 from trytond.pyson import Eval
@@ -67,10 +68,13 @@
     @classmethod
     def __register__(cls, module):
         table = cls.__table__()
-        log = Table('notification_email_log')
+        log_name = 'notification.email.log'
+        log_table_name = config.get(
+            'table', log_name, default=log_name.replace('.', '_'))
+        log = Table(log_table_name)
 
         cursor = Transaction().connection.cursor()
 
         super().__register__(module)
 
         # Migration from 6.6: merge notification email log with email
@@ -71,10 +75,10 @@
 
         cursor = Transaction().connection.cursor()
 
         super().__register__(module)
 
         # Migration from 6.6: merge notification email log with email
-        if backend.TableHandler.table_exist('notification_email_log'):
+        if backend.TableHandler.table_exist(log_table_name):
             query = table.insert(
                 [table.create_uid, table.create_date,
                     table.write_uid, table.write_date,
@@ -90,6 +94,7 @@
                     log.resource,
                     log.notification, log.trigger))
             cursor.execute(*query)
+            backend.TableHandler.drop_table(log_name, log_table_name)
 
     def get_user(self, name):
         user = super().get_user(name)



View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/299ba0473de71a631d5f57d3d9c65096d395e89d

-- 
View it on Heptapod: 
https://foss.heptapod.net/tryton/tryton/-/commit/299ba0473de71a631d5f57d3d9c65096d395e89d
You're receiving this email because of your account on foss.heptapod.net.


Reply via email to