From c8c58aaefb96d4a584a8eb27afffbc49d3ea143e Mon Sep 17 00:00:00 2001 From: David Harper Date: Thu, 4 Jun 2020 11:05:27 +0100 Subject: [PATCH] Rename drop shipment state from cancel to cancelled issue8927 review321401002 --- CHANGELOG | 2 ++ doc/index.rst | 2 +- party.py | 2 +- stock.py | 28 +++++++++++++++++----------- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e5acc74985..5d845a6ad7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Rename drop shipment state from cancel to cancelled + Version 5.6.0 - 2020-05-04 * Bug fixes (see mercurial logs for details) diff --git a/doc/index.rst b/doc/index.rst index 0fad8fe2ef..702cfe1f6a 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -33,6 +33,6 @@ The drop shipment can be in one of this states: All moves are in state Done. -* Cancel +* Cancelled All moves are cancelled. diff --git a/party.py b/party.py index f5fec85903..b4cef5efce 100644 --- a/party.py +++ b/party.py @@ -33,7 +33,7 @@ class Erase(metaclass=PoolMeta): ('customer', '=', party.id), ], ('company', '=', company.id), - ('state', 'not in', ['done', 'cancel']), + ('state', 'not in', ['done', 'cancelled']), ]) if shipments: raise EraseError( diff --git a/stock.py b/stock.py index 891753a890..75619ab2ad 100644 --- a/stock.py +++ b/stock.py @@ -152,7 +152,7 @@ class ShipmentDrop(Workflow, ModelSQL, ModelView): 'Supplier Moves', filter=[('to_location.type', '=', 'drop')], states={ - 'readonly': Eval('state').in_(['shipped', 'done', 'cancel']), + 'readonly': Eval('state').in_(['shipped', 'done', 'cancelled']), }, depends=['state', 'supplier']) customer_moves = fields.One2Many('stock.move', 'shipment', @@ -168,7 +168,7 @@ class ShipmentDrop(Workflow, ModelSQL, ModelView): ('waiting', 'Waiting'), ('shipped', 'Shipped'), ('done', 'Done'), - ('cancel', 'Canceled'), + ('cancelled', 'Cancelled'), ], 'State', readonly=True) @classmethod @@ -179,6 +179,7 @@ class ShipmentDrop(Workflow, ModelSQL, ModelView): PurchaseRequest = pool.get('purchase.request') SaleLine = pool.get('sale.line') Location = pool.get('stock.location') + table = cls.__table__() move = Move.__table__() purchase_line = PurchaseLine.__table__() purchase_request = PurchaseRequest.__table__() @@ -238,28 +239,33 @@ class ShipmentDrop(Workflow, ModelSQL, ModelView): drop_shipment_location, customer_location], where=(move.id == move_id))) + # Migration from 5.6: rename state cancel to cancelled + cursor.execute(*table.update( + [table.state], ['cancelled'], + where=table.state == 'cancel')) + @classmethod def __setup__(cls): super(ShipmentDrop, cls).__setup__() cls._transitions |= set(( ('draft', 'waiting'), ('waiting', 'shipped'), - ('draft', 'cancel'), - ('waiting', 'cancel'), + ('draft', 'cancelled'), + ('waiting', 'cancelled'), ('waiting', 'draft'), - ('cancel', 'draft'), + ('cancelled', 'draft'), ('shipped', 'done'), - ('shipped', 'cancel'), + ('shipped', 'cancelled'), )) cls._buttons.update({ 'cancel': { - 'invisible': Eval('state').in_(['cancel', 'done']), + 'invisible': Eval('state').in_(['cancelled', 'done']), 'depends': ['state'], }, 'draft': { - 'invisible': ~Eval('state').in_(['cancel', 'draft', + 'invisible': ~Eval('state').in_(['cancelled', 'draft', 'waiting']), - 'icon': If(Eval('state') == 'cancel', + 'icon': If(Eval('state') == 'cancelled', 'tryton-undo', 'tryton-back'), 'depends': ['state'], }, @@ -356,7 +362,7 @@ class ShipmentDrop(Workflow, ModelSQL, ModelView): cls.cancel(shipments) for shipment in shipments: - if shipment.state != 'cancel': + if shipment.state != 'cancelled': raise AccessError( gettext('sale_supply_drop_shipment' '.msg_drop_shipment_delete_cancel') % { @@ -367,7 +373,7 @@ class ShipmentDrop(Workflow, ModelSQL, ModelView): @classmethod @ModelView.button - @Workflow.transition('cancel') + @Workflow.transition('cancelled') @process_sale('customer_moves') @process_purchase('supplier_moves') def cancel(cls, shipments):