SERVER: add migration scripts
bzr revid: ced-246ec05ac16ab72ed9f17d92a55e464e4e7c8114
This commit is contained in:
parent
7d8a32ea21
commit
5898a33f79
|
@ -40,8 +40,15 @@ class ir_default(osv.osv):
|
||||||
'ref_id': fields.integer('ID Ref.',size=64),
|
'ref_id': fields.integer('ID Ref.',size=64),
|
||||||
'company_id': fields.many2one('res.company','Company')
|
'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 = {
|
_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()
|
ir_default()
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import osv,ir,pooler
|
||||||
import csv
|
import csv
|
||||||
import os.path
|
import os.path
|
||||||
import misc
|
import misc
|
||||||
|
import netsvc
|
||||||
|
|
||||||
from config import config
|
from config import config
|
||||||
|
|
||||||
|
@ -58,7 +59,6 @@ def _eval_xml(self,node, pool, cr, uid, idref):
|
||||||
try:
|
try:
|
||||||
import pytz
|
import pytz
|
||||||
except:
|
except:
|
||||||
import netsvc
|
|
||||||
logger = netsvc.Logger()
|
logger = netsvc.Logger()
|
||||||
logger.notifyChannel("init", netsvc.LOG_INFO, 'could not find pytz library')
|
logger.notifyChannel("init", netsvc.LOG_INFO, 'could not find pytz library')
|
||||||
class pytzclass(object):
|
class pytzclass(object):
|
||||||
|
@ -150,6 +150,8 @@ class xml_import(object):
|
||||||
res['header'] = eval(rec.getAttribute('header'))
|
res['header'] = eval(rec.getAttribute('header'))
|
||||||
res['multi'] = rec.hasAttribute('multi') and eval(rec.getAttribute('multi'))
|
res['multi'] = rec.hasAttribute('multi') and eval(rec.getAttribute('multi'))
|
||||||
xml_id = rec.getAttribute('id').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)
|
||||||
id = self.pool.get('ir.model.data')._update(cr, self.uid, "ir.actions.report.xml", self.module, res, xml_id, mode=self.mode)
|
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
|
self.idref[xml_id] = id
|
||||||
if not rec.hasAttribute('menu') or eval(rec.getAttribute('menu')):
|
if not rec.hasAttribute('menu') or eval(rec.getAttribute('menu')):
|
||||||
|
@ -169,6 +171,8 @@ class xml_import(object):
|
||||||
model = rec.getAttribute("model").encode('utf8')
|
model = rec.getAttribute("model").encode('utf8')
|
||||||
name = rec.getAttribute("name").encode('utf8')
|
name = rec.getAttribute("name").encode('utf8')
|
||||||
xml_id = rec.getAttribute('id').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'))
|
multi = rec.hasAttribute('multi') and eval(rec.getAttribute('multi'))
|
||||||
res = {'name': string, 'wiz_name': name, 'multi':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):
|
def _tag_act_window(self, cr, rec, data_node=None):
|
||||||
name = rec.hasAttribute('name') and rec.getAttribute('name').encode('utf-8')
|
name = rec.hasAttribute('name') and rec.getAttribute('name').encode('utf-8')
|
||||||
xml_id = rec.getAttribute('id').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)
|
||||||
type = rec.hasAttribute('type') and rec.getAttribute('type').encode('utf-8') or 'ir.actions.act_window'
|
type = rec.hasAttribute('type') and rec.getAttribute('type').encode('utf-8') or 'ir.actions.act_window'
|
||||||
view_id = False
|
view_id = False
|
||||||
if rec.hasAttribute('view'):
|
if rec.hasAttribute('view'):
|
||||||
|
@ -223,7 +229,6 @@ class xml_import(object):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _tag_workflow(self, cr, rec, data_node=None):
|
def _tag_workflow(self, cr, rec, data_node=None):
|
||||||
import netsvc
|
|
||||||
model = str(rec.getAttribute('model'))
|
model = str(rec.getAttribute('model'))
|
||||||
wf_service = netsvc.LocalService("workflow")
|
wf_service = netsvc.LocalService("workflow")
|
||||||
wf_service.trg_validate(self.uid, model,
|
wf_service.trg_validate(self.uid, model,
|
||||||
|
@ -233,6 +238,8 @@ class xml_import(object):
|
||||||
|
|
||||||
def _tag_menuitem(self, cr, rec, data_node=None):
|
def _tag_menuitem(self, cr, rec, data_node=None):
|
||||||
rec_id = rec.getAttribute("id").encode('ascii')
|
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')))
|
m_l = map(escape, escape_re.split(rec.getAttribute("name").encode('utf8')))
|
||||||
pid = False
|
pid = False
|
||||||
for idx, menu_elem in enumerate(m_l):
|
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)]))
|
g_ids.extend(self.pool.get('res.groups').search(cr, self.uid, [('name', '=', group)]))
|
||||||
values['groups_id'] = [(6, 0, g_ids)]
|
values['groups_id'] = [(6, 0, g_ids)]
|
||||||
xml_id = rec.getAttribute('id').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)
|
||||||
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)
|
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:
|
elif res:
|
||||||
# the menuitem already exists
|
# the menuitem already exists
|
||||||
|
@ -311,6 +320,8 @@ class xml_import(object):
|
||||||
model = self.pool.get(rec_model)
|
model = self.pool.get(rec_model)
|
||||||
assert model, "The model %s does not exist !" % (rec_model,)
|
assert model, "The model %s does not exist !" % (rec_model,)
|
||||||
rec_id = rec.getAttribute("id").encode('ascii')
|
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'):
|
# if not rec_id and not data_node.getAttribute('noupdate'):
|
||||||
# print "Warning", rec_model
|
# print "Warning", rec_model
|
||||||
|
@ -400,15 +411,14 @@ class xml_import(object):
|
||||||
try:
|
try:
|
||||||
self._tags[rec.nodeName](self.cr, rec, n)
|
self._tags[rec.nodeName](self.cr, rec, n)
|
||||||
except:
|
except:
|
||||||
import netsvc
|
self.logger.notifyChannel("init", netsvc.LOG_INFO, '\n'+rec.toxml())
|
||||||
logger = netsvc.Logger()
|
|
||||||
logger.notifyChannel("init", netsvc.LOG_INFO, '\n'+rec.toxml())
|
|
||||||
self.cr.rollback()
|
self.cr.rollback()
|
||||||
raise
|
raise
|
||||||
self.cr.commit()
|
self.cr.commit()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def __init__(self, cr, module, idref, mode):
|
def __init__(self, cr, module, idref, mode):
|
||||||
|
self.logger = netsvc.Logger()
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
self.module = module
|
self.module = module
|
||||||
self.cr = cr
|
self.cr = cr
|
||||||
|
|
Loading…
Reference in New Issue