Add version checking to actions.

This commit is contained in:
Albert Cervera i Areny 2017-01-21 01:30:25 +01:00
parent 98e4c125dd
commit 37fc694a22
2 changed files with 17 additions and 0 deletions

View File

@ -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
View File

@ -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