Add version checking to actions.
This commit is contained in:
parent
98e4c125dd
commit
37fc694a22
|
@ -84,10 +84,12 @@ after:
|
|||
- DELETE FROM ir_translation WHERE module = 'account_es';
|
||||
- DELETE FROM ir_translation WHERE module = 'account_es_pyme';
|
||||
- comment: -> 4.0
|
||||
version: 4.0
|
||||
query: UPDATE account_move_reconciliation SET date=create_date::DATE WHERE date IS NULL;
|
||||
- comment: # Change login's length
|
||||
query: ALTER TABLE res_user_login_attempt ALTER COLUMN login TYPE character varying(512);
|
||||
- comment: # Mark all categories as accounting type
|
||||
version: 4.0
|
||||
tables: product_category
|
||||
query: UPDATE product_category SET accounting = True;
|
||||
- comment: # Set reconciliation date
|
||||
|
|
15
upgrade
15
upgrade
|
@ -10,6 +10,11 @@ import ConfigParser
|
|||
|
||||
from blessings import Terminal
|
||||
|
||||
import trytond
|
||||
|
||||
trytond_version = '.'.join(trytond.__version__.split('.')[:2])
|
||||
|
||||
|
||||
t = Terminal()
|
||||
|
||||
def get_url():
|
||||
|
@ -112,8 +117,16 @@ def process_actions(actions):
|
|||
if isinstance(action, dict):
|
||||
tables = action.get('tables', '')
|
||||
fields = action.get('fields', '')
|
||||
version = action.get('version', '')
|
||||
query = action.get('query')
|
||||
script = action.get('script')
|
||||
|
||||
# Check version
|
||||
if version != trytond_version:
|
||||
# Unfortunately we can only check for exact version
|
||||
continue
|
||||
|
||||
# Check tables
|
||||
found = True
|
||||
tables = tables.split()
|
||||
for table in tables:
|
||||
|
@ -124,6 +137,7 @@ def process_actions(actions):
|
|||
if not found:
|
||||
continue
|
||||
|
||||
# Check fields
|
||||
found = True
|
||||
fields = fields.split()
|
||||
for field in fields:
|
||||
|
@ -133,6 +147,7 @@ def process_actions(actions):
|
|||
break
|
||||
if not found:
|
||||
continue
|
||||
|
||||
else:
|
||||
query = action
|
||||
script = None
|
||||
|
|
Loading…
Reference in New Issue