changeset f47885505714 in modules/account_payment_sepa:default
details: 
https://hg.tryton.org/modules/account_payment_sepa?cmd=changeset;node=f47885505714
description:
        Rename canceled states to cancelled

        issue8927
        review317461003
diffstat:

 CHANGELOG     |   2 ++
 doc/index.rst |   4 ++--
 message.xml   |   2 +-
 payment.py    |  53 +++++++++++++++++++++++++++++++++++------------------
 payment.xml   |   6 +++---
 5 files changed, 43 insertions(+), 24 deletions(-)

diffs (226 lines):

diff -r 7140231ac33e -r f47885505714 CHANGELOG
--- a/CHANGELOG Mon May 04 12:10:44 2020 +0200
+++ b/CHANGELOG Thu Jun 04 11:13:25 2020 +0100
@@ -1,3 +1,5 @@
+* Rename mandate and message states from canceled to cancelled
+
 Version 5.6.0 - 2020-05-04
 * Bug fixes (see mercurial logs for details)
 * Merge sepa identifier into eu_at_02
diff -r 7140231ac33e -r f47885505714 doc/index.rst
--- a/doc/index.rst     Mon May 04 12:10:44 2020 +0200
+++ b/doc/index.rst     Thu Jun 04 11:13:25 2020 +0100
@@ -56,7 +56,7 @@
 * Draft
 * Requested
 * Validated
-* Canceled
+* Cancelled
 
 Message
 *******
@@ -68,7 +68,7 @@
 * Draft
 * Waiting
 * Done
-* Canceled
+* Cancelled
 
 Bank to Customer Debit Credit Notification (camt.054)
 -----------------------------------------------------
diff -r 7140231ac33e -r f47885505714 message.xml
--- a/message.xml       Mon May 04 12:10:44 2020 +0200
+++ b/message.xml       Thu Jun 04 11:13:25 2020 +0100
@@ -12,7 +12,7 @@
         <record model="ir.message" id="msg_mandate_unique_id">
             <field name="text">SEPA mandate identification must be unique by 
company.</field>
         </record>
-        <record model="ir.message" id="msg_mandate_delete_draft_canceled">
+        <record model="ir.message" id="msg_mandate_delete_draft_cancelled">
             <field name="text">To delete mandate "%(mandate)s" you must cancel 
it or reset its state to draft.</field>
         </record>
         <record model="ir.message" id="msg_party_no_id">
diff -r 7140231ac33e -r f47885505714 payment.py
--- a/payment.py        Mon May 04 12:10:44 2020 +0200
+++ b/payment.py        Thu Jun 04 11:13:25 2020 +0100
@@ -403,13 +403,13 @@
     party = fields.Many2One('party.party', 'Party', required=True, select=True,
         states={
             'readonly': Eval('state').in_(
-                ['requested', 'validated', 'canceled']),
+                ['requested', 'validated', 'cancelled']),
             },
         depends=['state'])
     account_number = fields.Many2One('bank.account.number', 'Account Number',
         ondelete='RESTRICT',
         states={
-            'readonly': Eval('state').in_(['validated', 'canceled']),
+            'readonly': Eval('state').in_(['validated', 'cancelled']),
             'required': Eval('state') == 'validated',
             },
         domain=[
@@ -440,7 +440,7 @@
             ('one-off', 'One-off'),
             ], 'Type',
         states={
-            'readonly': Eval('state').in_(['validated', 'canceled']),
+            'readonly': Eval('state').in_(['validated', 'cancelled']),
             },
         depends=['state'])
     sequence_type_rcur = fields.Boolean(
@@ -454,13 +454,13 @@
             ('B2B', 'Business to Business'),
             ], 'Scheme', required=True,
         states={
-            'readonly': Eval('state').in_(['validated', 'canceled']),
+            'readonly': Eval('state').in_(['validated', 'cancelled']),
             },
         depends=['state'])
     scheme_string = scheme.translated('scheme')
     signature_date = fields.Date('Signature Date',
         states={
-            'readonly': Eval('state').in_(['validated', 'canceled']),
+            'readonly': Eval('state').in_(['validated', 'cancelled']),
             'required': Eval('state') == 'validated',
             },
         depends=['state'])
@@ -468,7 +468,7 @@
             ('draft', 'Draft'),
             ('requested', 'Requested'),
             ('validated', 'Validated'),
-            ('canceled', 'Canceled'),
+            ('cancelled', 'Cancelled'),
             ], 'State', readonly=True)
     payments = fields.One2Many('account.payment', 'sepa_mandate', 'Payments')
     has_payments = fields.Function(fields.Boolean('Has Payments'),
@@ -480,8 +480,8 @@
         cls._transitions |= set((
                 ('draft', 'requested'),
                 ('requested', 'validated'),
-                ('validated', 'canceled'),
-                ('requested', 'canceled'),
+                ('validated', 'cancelled'),
+                ('requested', 'cancelled'),
                 ('requested', 'draft'),
                 ))
         cls._buttons.update({
@@ -509,6 +509,18 @@
                 'account_payment_sepa.msg_mandate_unique_id'),
             ]
 
+    @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')
@@ -658,18 +670,18 @@
 
     @classmethod
     @ModelView.button
-    @Workflow.transition('canceled')
+    @Workflow.transition('cancelled')
     def cancel(cls, mandates):
-        # TODO must be automaticaly canceled 13 months after last collection
+        # TODO must be automaticaly cancelled 13 months after last collection
         pass
 
     @classmethod
     def delete(cls, mandates):
         for mandate in mandates:
-            if mandate.state not in ('draft', 'canceled'):
+            if mandate.state not in ('draft', 'cancelled'):
                 raise AccessError(
                     gettext('account_payment_sepa'
-                        '.msg_mandate_delete_draft_canceled',
+                        '.msg_mandate_delete_draft_cancelled',
                         mandate=mandate.rec_name))
         super(Mandate, cls).delete(mandates)
 
@@ -710,7 +722,7 @@
             ('draft', 'Draft'),
             ('waiting', 'Waiting'),
             ('done', 'Done'),
-            ('canceled', 'Canceled'),
+            ('cancelled', 'Cancelled'),
             ], 'State', readonly=True, select=True)
 
     @classmethod
@@ -720,8 +732,8 @@
             ('draft', 'waiting'),
             ('waiting', 'done'),
             ('waiting', 'draft'),
-            ('draft', 'canceled'),
-            ('waiting', 'canceled'),
+            ('draft', 'cancelled'),
+            ('waiting', 'cancelled'),
             }
         cls._buttons.update({
                 'cancel': {
@@ -744,9 +756,10 @@
 
     @classmethod
     def __register__(cls, module_name):
-        cursor = Transaction().connection.cursor()
         pool = Pool()
         Group = pool.get('account.payment.group')
+        cursor = Transaction().connection.cursor()
+        table = cls.__table__()
 
         super(Message, cls).__register__(module_name)
 
@@ -755,7 +768,6 @@
             group_table = Group.__table_handler__(module_name)
             if group_table.column_exist('sepa_message'):
                 group = Group.__table__()
-                table = cls.__table__()
                 cursor.execute(*group.select(
                         group.id, group.sepa_message, group.company))
                 for group_id, message, company_id in cursor.fetchall():
@@ -768,6 +780,11 @@
                                     'done']]))
                 group_table.drop_column('sepa_message')
 
+        # 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'
@@ -824,7 +841,7 @@
 
     @classmethod
     @ModelView.button
-    @Workflow.transition('canceled')
+    @Workflow.transition('cancelled')
     def cancel(cls, messages):
         pass
 
diff -r 7140231ac33e -r f47885505714 payment.xml
--- a/payment.xml       Mon May 04 12:10:44 2020 +0200
+++ b/payment.xml       Thu Jun 04 11:13:25 2020 +0100
@@ -209,10 +209,10 @@
             <field name="domain" eval="[('state', '=', 'done')]" pyson="1"/>
             <field name="act_window" ref="act_message_form"/>
         </record>
-        <record model="ir.action.act_window.domain" 
id="act_message_form_domain_canceled">
-            <field name="name">Canceled</field>
+        <record model="ir.action.act_window.domain" 
id="act_message_form_domain_cancelled">
+            <field name="name">Cancelled</field>
             <field name="sequence" eval="40"/>
-            <field name="domain" eval="[('state', '=', 'canceled')]" 
pyson="1"/>
+            <field name="domain" eval="[('state', '=', 'cancelled')]" 
pyson="1"/>
             <field name="act_window" ref="act_message_form"/>
         </record>
         <record model="ir.action.act_window.domain" 
id="act_message_form_domain_all">

Reply via email to