summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorced <>2007-06-28 10:41:28 +0000
committerced <>2007-06-28 10:41:28 +0000
commit5898a33f790f2dc0b1577f2db3a6f530d57ebfb3 (patch)
tree34b4f789eb2e2faa7a27c1bc594f5b7e30f66fdc
parent7d8a32ea21ca01c1f4a6b205d3cabb07ddd43de3 (diff)
SERVER: add migration scripts
bzr revid: ced-246ec05ac16ab72ed9f17d92a55e464e4e7c8114
-rw-r--r--bin/addons/base/ir/ir_default.py9
-rw-r--r--bin/tools/convert.py20
-rw-r--r--doc/migrate/4.0.0-4.2.0/pre-tiny.py (renamed from doc/migrate/4.0.0-4.1.0/post.py)0
-rw-r--r--doc/migrate/4.0.0-4.2.0/pre.py (renamed from doc/migrate/4.0.0-4.1.0/pre.py)0
4 files changed, 23 insertions, 6 deletions
diff --git a/bin/addons/base/ir/ir_default.py b/bin/addons/base/ir/ir_default.py
index 5d313d28ab6..08dc68bebe6 100644
--- a/bin/addons/base/ir/ir_default.py
+++ b/bin/addons/base/ir/ir_default.py
@@ -40,8 +40,15 @@ class ir_default(osv.osv):
'ref_id': fields.integer('ID Ref.',size=64),
'company_id': fields.many2one('res.company','Company')
}
+
+ def _get_company_id(self, cr, uid, context={}):
+ res = self.pool.get('res.users').read(cr, uid, [uid], ['company_id'], context=context)
+ if res:
+ return res[0]['company_id'][0]
+ return False
+
_defaults = {
- 'company_id': lambda self, cr, uid, context: self.pool.get('res.users').read(cr, uid, uid, ['company_id'], context=context)['company_id'],
+ 'company_id': _get_company_id,
}
ir_default()
diff --git a/bin/tools/convert.py b/bin/tools/convert.py
index bb7e8ef66a6..6295ff99513 100644
--- a/bin/tools/convert.py
+++ b/bin/tools/convert.py
@@ -8,6 +8,7 @@ import osv,ir,pooler
import csv
import os.path
import misc
+import netsvc
from config import config
@@ -58,7 +59,6 @@ def _eval_xml(self,node, pool, cr, uid, idref):
try:
import pytz
except:
- import netsvc
logger = netsvc.Logger()
logger.notifyChannel("init", netsvc.LOG_INFO, 'could not find pytz library')
class pytzclass(object):
@@ -150,6 +150,8 @@ class xml_import(object):
res['header'] = eval(rec.getAttribute('header'))
res['multi'] = rec.hasAttribute('multi') and eval(rec.getAttribute('multi'))
xml_id = rec.getAttribute('id').encode('utf8')
+ if len(xml_id) > 64:
+ self.logger.notifyChannel('init', netsvc.LOG_ERROR, 'id: %s is to long (max: 64)'%xml_id)
id = self.pool.get('ir.model.data')._update(cr, self.uid, "ir.actions.report.xml", self.module, res, xml_id, mode=self.mode)
self.idref[xml_id] = id
if not rec.hasAttribute('menu') or eval(rec.getAttribute('menu')):
@@ -169,6 +171,8 @@ class xml_import(object):
model = rec.getAttribute("model").encode('utf8')
name = rec.getAttribute("name").encode('utf8')
xml_id = rec.getAttribute('id').encode('utf8')
+ if len(xml_id) > 64:
+ self.logger.notifyChannel('init', netsvc.LOG_ERROR, 'id: %s is to long (max: 64)'%xml_id)
multi = rec.hasAttribute('multi') and eval(rec.getAttribute('multi'))
res = {'name': string, 'wiz_name': name, 'multi':multi}
@@ -186,6 +190,8 @@ class xml_import(object):
def _tag_act_window(self, cr, rec, data_node=None):
name = rec.hasAttribute('name') and rec.getAttribute('name').encode('utf-8')
xml_id = rec.getAttribute('id').encode('utf8')
+ if len(xml_id) > 64:
+ self.logger.notifyChannel('init', netsvc.LOG_ERROR, 'id: %s is to long (max: 64)'%xml_id)
type = rec.hasAttribute('type') and rec.getAttribute('type').encode('utf-8') or 'ir.actions.act_window'
view_id = False
if rec.hasAttribute('view'):
@@ -223,7 +229,6 @@ class xml_import(object):
return False
def _tag_workflow(self, cr, rec, data_node=None):
- import netsvc
model = str(rec.getAttribute('model'))
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(self.uid, model,
@@ -233,6 +238,8 @@ class xml_import(object):
def _tag_menuitem(self, cr, rec, data_node=None):
rec_id = rec.getAttribute("id").encode('ascii')
+ if len(rec_id) > 64:
+ self.logger.notifyChannel('init', netsvc.LOG_ERROR, 'id: %s is to long (max: 64)'%rec_id)
m_l = map(escape, escape_re.split(rec.getAttribute("name").encode('utf8')))
pid = False
for idx, menu_elem in enumerate(m_l):
@@ -283,6 +290,8 @@ class xml_import(object):
g_ids.extend(self.pool.get('res.groups').search(cr, self.uid, [('name', '=', group)]))
values['groups_id'] = [(6, 0, g_ids)]
xml_id = rec.getAttribute('id').encode('utf8')
+ if len(xml_id) > 64:
+ self.logger.notifyChannel('init', netsvc.LOG_ERROR, 'id: %s is to long (max: 64)'%xml_id)
pid = self.pool.get('ir.model.data')._update(cr, self.uid, 'ir.ui.menu', self.module, values, xml_id, idx==len(m_l)-1, mode=self.mode, res_id=res and res[0] or False)
elif res:
# the menuitem already exists
@@ -311,6 +320,8 @@ class xml_import(object):
model = self.pool.get(rec_model)
assert model, "The model %s does not exist !" % (rec_model,)
rec_id = rec.getAttribute("id").encode('ascii')
+ if len(rec_id) > 64:
+ self.logger.notifyChannel('init', netsvc.LOG_ERROR, 'id: %s is to long (max: 64)'%rec_id)
# if not rec_id and not data_node.getAttribute('noupdate'):
# print "Warning", rec_model
@@ -400,15 +411,14 @@ class xml_import(object):
try:
self._tags[rec.nodeName](self.cr, rec, n)
except:
- import netsvc
- logger = netsvc.Logger()
- logger.notifyChannel("init", netsvc.LOG_INFO, '\n'+rec.toxml())
+ self.logger.notifyChannel("init", netsvc.LOG_INFO, '\n'+rec.toxml())
self.cr.rollback()
raise
self.cr.commit()
return True
def __init__(self, cr, module, idref, mode):
+ self.logger = netsvc.Logger()
self.mode = mode
self.module = module
self.cr = cr
diff --git a/doc/migrate/4.0.0-4.1.0/post.py b/doc/migrate/4.0.0-4.2.0/pre-tiny.py
index 6623bace8cb..6623bace8cb 100644
--- a/doc/migrate/4.0.0-4.1.0/post.py
+++ b/doc/migrate/4.0.0-4.2.0/pre-tiny.py
diff --git a/doc/migrate/4.0.0-4.1.0/pre.py b/doc/migrate/4.0.0-4.2.0/pre.py
index a73a152a171..a73a152a171 100644
--- a/doc/migrate/4.0.0-4.1.0/pre.py
+++ b/doc/migrate/4.0.0-4.2.0/pre.py