changeset 1908ed00325e in modules/sale_subscription:default details: https://hg.tryton.org/modules/sale_subscription?cmd=changeset;node=1908ed00325e description: Rename subscription state from canceled to cancelled
issue8927 review301701002 diffstat: CHANGELOG | 2 ++ doc/index.rst | 2 +- party.py | 2 +- subscription.py | 31 ++++++++++++++++++++++--------- 4 files changed, 26 insertions(+), 11 deletions(-) diffs (117 lines): diff -r 2976b87c16a4 -r 1908ed00325e CHANGELOG --- a/CHANGELOG Mon Jun 01 10:08:02 2020 +0100 +++ b/CHANGELOG Sat Jun 06 09:58:15 2020 +0100 @@ -1,3 +1,5 @@ +* Rename subscription state from canceled to cancelled + Version 5.6.0 - 2020-05-04 * Bug fixes (see mercurial logs for details) * Add employee on subscriptions for some states diff -r 2976b87c16a4 -r 1908ed00325e doc/index.rst --- a/doc/index.rst Mon Jun 01 10:08:02 2020 +0100 +++ b/doc/index.rst Sat Jun 06 09:58:15 2020 +0100 @@ -39,7 +39,7 @@ - End Date: An optional earlier end date than the subscription. - States: The state of the subscription. May take one of the following values: - Draft, Quotation, Running, Closed, Canceled. + Draft, Quotation, Running, Closed, Cancelled. - Company: The company which issue the sale order. A running subscription can be modified by going back to draft and edit. Some diff -r 2976b87c16a4 -r 1908ed00325e party.py --- a/party.py Mon Jun 01 10:08:02 2020 +0100 +++ b/party.py Sat Jun 06 09:58:15 2020 +0100 @@ -27,7 +27,7 @@ subscriptions = Subscription.search([ ('party', '=', party.id), ('company', '=', company.id), - ('state', 'not in', ['closed', 'canceled']), + ('state', 'not in', ['closed', 'cancelled']), ]) if subscriptions: raise EraseError( diff -r 2976b87c16a4 -r 1908ed00325e subscription.py --- a/subscription.py Mon Jun 01 10:08:02 2020 +0100 +++ b/subscription.py Sat Jun 06 09:58:15 2020 +0100 @@ -146,15 +146,15 @@ depends=['state']) quoted_by = employee_field( - "Quoted By", states=['quotation', 'running', 'closed', 'canceled']) + "Quoted By", states=['quotation', 'running', 'closed', 'cancelled']) run_by = employee_field( - "Run By", states=['running', 'closed', 'canceled']) + "Run By", states=['running', 'closed', 'cancelled']) state = fields.Selection([ ('draft', "Draft"), ('quotation', "Quotation"), ('running', "Running"), ('closed', "Closed"), - ('canceled', "Canceled"), + ('cancelled', "Cancelled"), ], "State", readonly=True, required=True, help="The current state of the subscription.") @@ -166,14 +166,14 @@ ('id', 'DESC'), ] cls._transitions |= set(( - ('draft', 'canceled'), + ('draft', 'cancelled'), ('draft', 'quotation'), - ('quotation', 'canceled'), + ('quotation', 'cancelled'), ('quotation', 'draft'), ('quotation', 'running'), ('running', 'draft'), ('running', 'closed'), - ('canceled', 'draft'), + ('cancelled', 'draft'), )) cls._buttons.update({ 'cancel': { @@ -183,7 +183,7 @@ }, 'draft': { 'invisible': Eval('state').in_(['draft', 'closed']), - 'icon': If(Eval('state') == 'canceled', + 'icon': If(Eval('state') == 'cancelled', 'tryton-undo', 'tryton-back'), 'depends': ['state'], }, @@ -201,6 +201,18 @@ }) @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 default_company(cls): return Transaction().context.get('company') @@ -269,12 +281,13 @@ @classmethod def view_attributes(cls): return [ - ('/tree', 'visual', If(Eval('state') == 'canceled', 'muted', '')), + ('/tree', 'visual', + If(Eval('state') == 'cancelled', 'muted', '')), ] @classmethod @ModelView.button - @Workflow.transition('canceled') + @Workflow.transition('cancelled') def cancel(cls, subscriptions): pass