From 54c79dddc5c45ee3e2d2c918753591892942a8a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 25 Aug 2009 13:59:31 +0200 Subject: [PATCH] Rename osv into model on workflow --- CHANGELOG | 1 + trytond/backend/postgresql/init.sql | 2 +- trytond/backend/sqlite/init.sql | 2 +- trytond/model/modelworkflow.py | 2 +- trytond/workflow/workflow.py | 17 ++++++++++++++--- trytond/workflow/workflow.xml | 6 +++--- 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1a2f42dc32..fc3e12949d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Rename osv into model on workflow * Add logout method * Move BrowseRecord cache onto the cursor * Don't order search result if order value is [] diff --git a/trytond/backend/postgresql/init.sql b/trytond/backend/postgresql/init.sql index e99f96abfe..f7ab72fa5b 100644 --- a/trytond/backend/postgresql/init.sql +++ b/trytond/backend/postgresql/init.sql @@ -116,7 +116,7 @@ create table wkf ( id serial, name varchar, - osv varchar, + model varchar, on_create bool, primary key(id) ); diff --git a/trytond/backend/sqlite/init.sql b/trytond/backend/sqlite/init.sql index 6d99e805aa..b647b34732 100644 --- a/trytond/backend/sqlite/init.sql +++ b/trytond/backend/sqlite/init.sql @@ -108,7 +108,7 @@ create table wkf ( id INTEGER PRIMARY KEY, name VARCHAR, - osv VARCHAR, + model VARCHAR, on_create BOOLEAN ); diff --git a/trytond/model/modelworkflow.py b/trytond/model/modelworkflow.py index eb43dfd616..2b860d5d75 100644 --- a/trytond/model/modelworkflow.py +++ b/trytond/model/modelworkflow.py @@ -61,7 +61,7 @@ class ModelWorkflow(ModelStorage): ids = [ids] workflow_ids = workflow_obj.search(cursor, 0, [ - ('osv', '=', self._name), + ('model', '=', self._name), ('on_create', '=', True), ], context=context) for res_id in ids: diff --git a/trytond/workflow/workflow.py b/trytond/workflow/workflow.py index bf3dc63d97..7c0cf50296 100644 --- a/trytond/workflow/workflow.py +++ b/trytond/workflow/workflow.py @@ -1,4 +1,5 @@ -#This file is part of Tryton. The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. +#This file is part of Tryton. The COPYRIGHT file at the top level of +#this repository contains the full copyright notices and license terms. "Workflow" import os from trytond.model import ModelView, ModelSQL, fields @@ -15,7 +16,7 @@ class Workflow(ModelSQL, ModelView): _table = "wkf" _description = __doc__ name = fields.Char('Name', required=True, translate=True) - osv = fields.Char('Resource Model', required=True, select=1) + model = fields.Char('Resource Model', required=True, select=1) on_create = fields.Boolean('On Create', select=2) activities = fields.One2Many('workflow.activity', 'workflow', 'Activities') @@ -26,6 +27,16 @@ class Workflow(ModelSQL, ModelView): 'no_workflow_defined': 'No workflow defined!', }) + def init(self, cursor, module_name): + super(Workflow, self).init(cursor, module_name) + table = TableHandler(cursor, self, module_name) + + # Migration from 1.2 rename osv into model + if table.column_exist('osv'): + cursor.execute('UPDATE "' + self._table + '" ' \ + 'SET model = osv') + table.drop_column('osv', exception=True) + def default_on_create(self, cursor, user, context=None): return 1 @@ -524,7 +535,7 @@ class InstanceGraph(Report): lang = lang_obj.browse(cursor, user, lang_id, context=context) workflow_id = workflow_obj.search(cursor, user, [ - ('osv', '=', datas['model']), + ('model', '=', datas['model']), ], limit=1, context=context) if not workflow_id: workflow_obj.raise_user_error(cursor, 'no_workflow_defined', diff --git a/trytond/workflow/workflow.xml b/trytond/workflow/workflow.xml index 3925118614..3484c3d8d7 100644 --- a/trytond/workflow/workflow.xml +++ b/trytond/workflow/workflow.xml @@ -12,8 +12,8 @@