diff --git a/CHANGELOG b/CHANGELOG index b1a1f9af3d..f76e843106 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Rename landed cost state from cancel to cancelled + Version 5.6.0 - 2020-05-04 * Bug fixes (see mercurial logs for details) diff --git a/account.py b/account.py index cb027812f5..fb6eb9f798 100644 --- a/account.py +++ b/account.py @@ -115,7 +115,7 @@ class LandedCost(Workflow, ModelSQL, ModelView): state = fields.Selection([ ('draft', 'Draft'), ('posted', 'Posted'), - ('cancel', 'Canceled'), + ('cancelled', 'Cancelled'), ], 'State', readonly=True) @classmethod @@ -128,8 +128,8 @@ class LandedCost(Workflow, ModelSQL, ModelView): ] cls._transitions |= set(( ('draft', 'posted'), - ('draft', 'cancel'), - ('cancel', 'draft'), + ('draft', 'cancelled'), + ('cancelled', 'draft'), )) cls._buttons.update({ 'cancel': { @@ -137,7 +137,7 @@ class LandedCost(Workflow, ModelSQL, ModelView): 'depends': ['state'], }, 'draft': { - 'invisible': Eval('state') != 'cancel', + 'invisible': Eval('state') != 'cancelled', 'depends': ['state'], }, 'post': { @@ -148,7 +148,9 @@ class LandedCost(Workflow, ModelSQL, ModelView): @classmethod def __register__(cls, module_name): + cursor = Transaction().connection.cursor() table_h = cls.__table_handler__(module_name) + sql_table = cls.__table__() # Migration from 3.8: rename code into number if table_h.column_exist('code'): @@ -156,6 +158,11 @@ class LandedCost(Workflow, ModelSQL, ModelView): super(LandedCost, cls).__register__(module_name) + # Migration from 5.6: rename state cancel to cancelled + cursor.execute(*sql_table.update( + [sql_table.state], ['cancelled'], + where=sql_table.state == 'cancel')) + @staticmethod def default_company(): return Transaction().context.get('company') @@ -170,7 +177,7 @@ class LandedCost(Workflow, ModelSQL, ModelView): @classmethod @ModelView.button - @Workflow.transition('cancel') + @Workflow.transition('cancelled') def cancel(cls, landed_costs): pass