Merge remote branch 'origin/master' into xrg

Conflicts:
	bin/addons/base/ir/ir_cron.py

bzr revid: p_christ@hol.gr-20091008195028-eth801qgzj78zrm1
This commit is contained in:
P. Christeas 2009-10-08 22:50:28 +03:00
commit ffb287777c
6 changed files with 179 additions and 142 deletions

View File

@ -25,7 +25,10 @@ import time
import netsvc
import tools
import pooler
from osv import fields,osv
from osv import fields, osv
def str2tuple(s):
return eval('tuple(%s)' % s)
_intervalTypes = {
'work_days': lambda interval: DateTime.RelativeDateTime(days=interval),
@ -65,25 +68,39 @@ class ir_cron(osv.osv, netsvc.Agent):
'doall' : lambda *a: 1
}
def _check_args(self, cr, uid, ids, context=None):
try:
for this in self.browse(cr, uid, ids, context):
str2tuple(this.args)
except:
return False
return True
_constraints = [
(_check_args, 'Invalid arguments', ['args']),
]
def _callback(self, cr, uid, model, func, args):
args = (args or []) and eval(args)
m=self.pool.get(model)
args = str2tuple(args)
m = self.pool.get(model)
if m and hasattr(m, func):
f = getattr(m, func)
f(cr, uid, *args)
try:
f(cr, uid, *args)
except Exception, e:
self._logger.notifyChannel('timers', netsvc.LOG_ERROR, "Job call of self.pool.get('%s').%s(cr, uid, *%r) failed" % (model, func, args))
self._logger.notifyChannel('timers', netsvc.LOG_ERROR, tools.exception_to_unicode(e))
def _poolJobs(self, db_name, check=False):
def _poolJobs(self, db_name, check=False):
try:
db, pool = pooler.get_db_and_pool(db_name)
except:
return False
if pool._init:
# retry in a few minutes
next_call = 600
else:
now = DateTime.now()
try:
cr = db.cursor()
return False
try:
cr = db.cursor()
if not pool._init:
now = DateTime.now()
cr.execute('select * from ir_cron where numbercall<>0 and active and nextcall<=now() order by priority')
for job in cr.dictfetchall():
nextcall = DateTime.strptime(job['nextcall'], '%Y-%m-%d %H:%M:%S')
@ -98,33 +115,32 @@ class ir_cron(osv.osv, netsvc.Agent):
if numbercall:
nextcall += _intervalTypes[job['interval_type']](job['interval_number'])
ok = True
addsql=''
addsql = ''
if not numbercall:
addsql = ', active=False'
cr.execute("update ir_cron set nextcall=%s, numbercall=%s"+addsql+" where id=%s", (nextcall.strftime('%Y-%m-%d %H:%M:%S'), numbercall, job['id']))
cr.commit()
except Exception,ex:
logger=netsvc.Logger()
logger.notifyChannel('cron', netsvc.LOG_WARNING,
'Exception in cron:'+str(ex))
finally:
cr.commit()
cr.close()
#
# Can be improved to do at the min(min(nextcalls), time()+next_call)
# But is this an improvement ?
#
cr = db.cursor()
cr.execute('select min(nextcall) as min_next_call from ir_cron where numbercall<>0 and active and nextcall>=now()')
next_call = cr.dictfetchone()['min_next_call']
cr.close()
if next_call:
next_call = time.mktime(time.strptime(next_call, '%Y-%m-%d %H:%M:%S'))
else:
next_call = int(time.time()) + 3600 # if do not find active cron job from database, it will run again after 1 day
if not check:
self.setAlarm(self._poolJobs, next_call, db_name, db_name)
cr.execute('select min(nextcall) as min_next_call from ir_cron where numbercall<>0 and active and nextcall>=now()')
next_call = cr.dictfetchone()['min_next_call']
if next_call:
next_call = time.mktime(time.strptime(next_call, '%Y-%m-%d %H:%M:%S'))
else:
next_call = int(time.time()) + 3600 # if do not find active cron job from database, it will run again after 1 day
if not check:
self.setAlarm(self._poolJobs, next_call, db_name, db_name)
except Exception, ex:
logger = netsvc.Logger()
logger.notifyChannel('cron', netsvc.LOG_WARNING,
'Exception in cron:'+str(ex))
finally:
cr.commit()
cr.close()
def create(self, cr, uid, vals, context=None):
res = super(ir_cron, self).create(cr, uid, vals, context=context)

View File

@ -445,10 +445,11 @@ class ir_model_data(osv.osv):
id = False
return id
def _update(self,cr, uid, model, module, values, xml_id=False, store=True, noupdate=False, mode='init', res_id=False):
def _update(self,cr, uid, model, module, values, xml_id=False, store=True, noupdate=False, mode='init', res_id=False, context=None):
warning = True
model_obj = self.pool.get(model)
context = {}
if not context:
context = {}
if xml_id and ('.' in xml_id):
assert len(xml_id.split('.'))==2, _('"%s" contains too many dots. XML ids should not contain dots ! These are used to refer to other modules data, as in module.reference_id') % (xml_id)
warning = False
@ -471,12 +472,12 @@ class ir_model_data(osv.osv):
res_id,action_id = res_id2,action_id2
if action_id and res_id:
model_obj.write(cr, uid, [res_id], values)
model_obj.write(cr, uid, [res_id], values, context=context)
self.write(cr, uid, [action_id], {
'date_update': time.strftime('%Y-%m-%d %H:%M:%S'),
})
},context=context)
elif res_id:
model_obj.write(cr, uid, [res_id], values)
model_obj.write(cr, uid, [res_id], values, context=context)
if xml_id:
self.create(cr, uid, {
'name': xml_id,
@ -484,21 +485,21 @@ class ir_model_data(osv.osv):
'module':module,
'res_id':res_id,
'noupdate': noupdate,
})
},context=context)
if model_obj._inherits:
for table in model_obj._inherits:
inherit_id = model_obj.browse(cr, uid,
res_id)[model_obj._inherits[table]]
res_id,context=context)[model_obj._inherits[table]]
self.create(cr, uid, {
'name': xml_id + '_' + table.replace('.', '_'),
'model': table,
'module': module,
'res_id': inherit_id,
'noupdate': noupdate,
})
},context=context)
else:
if mode=='init' or (mode=='update' and xml_id):
res_id = model_obj.create(cr, uid, values)
res_id = model_obj.create(cr, uid, values, context=context)
if xml_id:
self.create(cr, uid, {
'name': xml_id,
@ -506,18 +507,18 @@ class ir_model_data(osv.osv):
'module': module,
'res_id': res_id,
'noupdate': noupdate
})
},context=context)
if model_obj._inherits:
for table in model_obj._inherits:
inherit_id = model_obj.browse(cr, uid,
res_id)[model_obj._inherits[table]]
res_id,context=context)[model_obj._inherits[table]]
self.create(cr, uid, {
'name': xml_id + '_' + table.replace('.', '_'),
'model': table,
'module': module,
'res_id': inherit_id,
'noupdate': noupdate,
})
},context=context)
if xml_id:
if res_id:
self.loads[(module, xml_id)] = (model, res_id)

View File

@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
@ -37,24 +37,36 @@ waittime = 10
wait_count = 0
wait_limit = 12
def start_server(root_path, port, addons_path):
os.system('python2.5 %sopenerp-server.py --pidfile=openerp.pid --port=%s --no-netrpc --addons-path=%s' %(root_path, str(port), addons_path))
def to_decode(s):
try:
return s.encode('utf-8')
except UnicodeError:
try:
return s.encode('latin')
except UnicodeError:
try:
return s.decode('ascii')
except UnicodeError:
return s
def start_server(root_path, port, addons_path):
os.system('python2.5 %sopenerp-server.py --pidfile=openerp.pid --port=%s --no-netrpc --addons-path=%s' %(root_path, str(port), addons_path))
def clean():
if os.path.isfile('openerp.pid'):
ps = open('openerp.pid')
ps = open('openerp.pid')
if ps:
pid = int(ps.read())
ps.close()
if pid:
ps.close()
if pid:
os.kill(pid,9)
def execute(connector, method, *args):
global wait_count
global wait_count
res = False
try:
try:
res = getattr(connector,method)(*args)
except socket.error,e:
if e.args[0] == 111:
except socket.error,e:
if e.args[0] == 111:
if wait_count > wait_limit:
print "Server is taking too long to start, it has exceeded the maximum limit of %d seconds."%(wait_limit)
clean()
@ -66,23 +78,23 @@ def execute(connector, method, *args):
else:
raise e
wait_count = 0
return res
return res
def login(uri, dbname, user, pwd):
conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/common')
uid = execute(conn,'login',dbname, user, pwd)
uid = execute(conn,'login',dbname, user, pwd)
return uid
def import_translate(uri, user, pwd, dbname, translate_in):
uid = login(uri, dbname, user, pwd)
if uid:
def import_translate(uri, user, pwd, dbname, translate_in):
uid = login(uri, dbname, user, pwd)
if uid:
conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/wizard')
wiz_id = execute(conn,'create',dbname, uid, pwd, 'module.lang.import')
for trans_in in translate_in:
lang,ext = os.path.splitext(trans_in.split('/')[-1])
state = 'init'
lang,ext = os.path.splitext(trans_in.split('/')[-1])
state = 'init'
datas = {'form':{}}
while state!='end':
while state!='end':
res = execute(conn,'execute',dbname, uid, pwd, wiz_id, datas, state, {})
if 'datas' in res:
datas['form'].update( res['datas'].get('form',{}) )
@ -98,34 +110,31 @@ def import_translate(uri, user, pwd, dbname, translate_in):
})
trans_obj.close()
elif res['type']=='action':
state = res['state']
def check_quality(uri, user, pwd, dbname, modules, quality_logs):
state = res['state']
def check_quality(uri, user, pwd, dbname, modules, quality_logs):
uid = login(uri, dbname, user, pwd)
quality_logs += 'quality-logs'
if uid:
conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/object')
final = {}
for module in modules:
final = {}
for module in modules:
qualityresult = {}
test_detail = {}
test_detail = {}
quality_result = execute(conn,'execute', dbname, uid, pwd,'module.quality.check','check_quality',module)
detail_html = ''
html = '''<html><body><a name="TOP"></a>'''
html +="<h1> Module : %s </h1>"%(quality_result['name'])
html += "<h2> Final score : %s</h2>"%(quality_result['final_score'])
html +="<h1> Module: %s </h1>"%(quality_result['name'])
html += "<h2> Final score: %s</h2>"%(quality_result['final_score'])
html += "<div id='tabs'>"
html += "<ul>"
for x,y,detail in quality_result['check_detail_ids']:
for x,y,detail in quality_result['check_detail_ids']:
test = detail.get('name')
msg = detail.get('message','')
score = round(float(detail.get('score',0)),2)
html += "<li><a href=\"#%s\">%s</a></li>"%(test.replace(' ','-'),test)
if test == 'Unit Test':
if not detail.get('detail',''):
detail['detail'] = '''<html><body><b>%s</b></body></html>'''%(detail.get('summary',''))
detail_html +="<div id=\"%s\"><h3>%s (Score : %s)</h3>%s</div>"%(test.replace(' ','-'),test,score,detail.get('detail',''))
detail_html +='''<div id=\"%s\"><h3>%s (Score : %s)</h3><font color=red><h5>%s</h5></font>%s</div>'''%(test.replace(' ', '-'), test, score, msg, detail.get('detail', ''))
test_detail[test] = (score,msg,detail.get('detail',''))
html += "</ul>"
html += "%s"%(detail_html)
@ -133,7 +142,7 @@ def check_quality(uri, user, pwd, dbname, modules, quality_logs):
if not os.path.isdir(quality_logs):
os.mkdir(quality_logs)
fp = open('%s/%s.html'%(quality_logs,module),'wb')
fp.write(str(html))
fp.write(to_decode(html))
fp.close()
#final[quality_result['name']] = (quality_result['final_score'],html,test_detail)
@ -143,9 +152,9 @@ def check_quality(uri, user, pwd, dbname, modules, quality_logs):
#print "LOG PATH%s"%(os.path.realpath('quality_log.pck'))
return True
else:
print 'Login Failed...'
print 'Login Failed...'
clean()
sys.exit(1)
sys.exit(1)
@ -164,25 +173,25 @@ def create_db(uri, dbname, user='admin', pwd='admin', lang='en_US'):
login_conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/common')
db_list = execute(conn, 'list')
if dbname not in db_list:
id = execute(conn,'create',admin_passwd, dbname, True, lang)
id = execute(conn,'create',admin_passwd, dbname, True, lang)
wait(id,uri)
uid = login_conn.login(dbname, user, pwd)
uid = login_conn.login(dbname, user, pwd)
wiz_id = execute(wiz_conn,'create', dbname, uid, user, 'base_setup.base_setup')
state = 'init'
datas = {'form':{}}
while state!='config':
while state!='config':
res = execute(wiz_conn, 'execute', dbname, uid, pwd, wiz_id, datas, state, {})
if state=='init':
datas['form'].update( res['datas'] )
if res['type']=='form':
for field in res['fields'].keys():
for field in res['fields'].keys():
datas['form'][field] = datas['form'].get(field,False)
state = res['state'][-1][0]
datas['form'].update({
'profile': -1
'profile': -1
})
elif res['type']=='state':
state = res['state']
@ -194,71 +203,71 @@ def drop_db(uri, dbname):
conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/db')
db_list = execute(conn,'list')
if dbname in db_list:
execute(conn, 'drop', admin_passwd, dbname)
execute(conn, 'drop', admin_passwd, dbname)
return True
def make_links(uri, uid, dbname, source, destination, module, user, pwd):
if module in ('base','quality_integration_server'):
return True
if not os.path.islink(destination + '/' + module):
if not os.path.isdir(destination + '/' + module):
return True
if not os.path.islink(destination + '/' + module):
if not os.path.isdir(destination + '/' + module):
for path in source:
if os.path.isdir(path + '/' + module):
os.symlink(path + '/' + module, destination + '/' + module)
obj_conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/object')
execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', 'update_list')
module_ids = execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', 'search', [('name','=',module)])
if len(module_ids):
if len(module_ids):
data = execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', 'read', module_ids[0],['name','dependencies_id'])
dep_datas = execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module.dependency', 'read', data['dependencies_id'],['name'])
for dep_data in dep_datas:
for dep_data in dep_datas:
make_links(uri, uid, dbname, source, destination, dep_data['name'], user, pwd)
return True
return False
return True
return False
def install_module(uri, dbname, modules, addons='', extra_addons='', user='admin', pwd='admin'):
uid = login(uri, dbname, user, pwd)
if extra_addons:
extra_addons = extra_addons.split(',')
if uid:
if uid:
if addons and extra_addons:
for module in modules:
make_links(uri, uid, dbname, extra_addons, addons, module, user, pwd)
for module in modules:
make_links(uri, uid, dbname, extra_addons, addons, module, user, pwd)
obj_conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/object')
wizard_conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/wizard')
module_ids = execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', 'search', [('name','in',modules)])
execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', 'button_install', module_ids)
execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', 'button_install', module_ids)
wiz_id = execute(wizard_conn, 'create', dbname, uid, pwd, 'module.upgrade.simple')
state = 'init'
datas = {}
#while state!='menu':
while state!='end':
res = execute(wizard_conn, 'execute', dbname, uid, pwd, wiz_id, datas, state, {})
while state!='end':
res = execute(wizard_conn, 'execute', dbname, uid, pwd, wiz_id, datas, state, {})
if state == 'init':
state = 'start'
elif state == 'start':
state = 'end'
state = 'end'
return True
def upgrade_module(uri, dbname, modules, user='admin', pwd='admin'):
uid = login(uri, dbname, user, pwd)
if uid:
if uid:
obj_conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/object')
wizard_conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/wizard')
module_ids = execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', 'search', [('name','in',modules)])
execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', 'button_upgrade', module_ids)
wizard_conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/wizard')
module_ids = execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', 'search', [('name','in',modules)])
execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', 'button_upgrade', module_ids)
wiz_id = execute(wizard_conn, 'create', dbname, uid, pwd, 'module.upgrade.simple')
state = 'init'
datas = {}
#while state!='menu':
while state!='end':
res = execute(wizard_conn, 'execute', dbname, uid, pwd, wiz_id, datas, state, {})
while state!='end':
res = execute(wizard_conn, 'execute', dbname, uid, pwd, wiz_id, datas, state, {})
if state == 'init':
state = 'start'
elif state == 'start':
state = 'end'
state = 'end'
return True
@ -271,21 +280,21 @@ Basic Commands:
start-server Start Server
create-db Create new database
drop-db Drop database
install-module Install module
install-module Install module
upgrade-module Upgrade module
install-translation Install translation file
check-quality Calculate quality and dump quality result into quality_log.pck using pickle
"""
parser = optparse.OptionParser(usage)
parser = optparse.OptionParser(usage)
parser.add_option("--modules", dest="modules",
help="specify modules to install or check quality")
parser.add_option("--addons-path", dest="addons_path", help="specify the addons path")
parser.add_option("--quality-logs", dest="quality_logs", help="specify the path of quality logs files which has to stores")
parser.add_option("--root-path", dest="root_path", help="specify the root path")
parser.add_option("-p", "--port", dest="port", help="specify the TCP port", type="int")
parser.add_option("-d", "--database", dest="db_name", help="specify the database name")
parser.add_option("--login", dest="login", help="specify the User Login")
parser.add_option("--password", dest="pwd", help="specify the User Password")
parser.add_option("-d", "--database", dest="db_name", help="specify the database name")
parser.add_option("--login", dest="login", help="specify the User Login")
parser.add_option("--password", dest="pwd", help="specify the User Password")
parser.add_option("--translate-in", dest="translate_in",
help="specify .po files to import translation terms")
parser.add_option("--extra-addons", dest="extra_addons",
@ -296,7 +305,7 @@ if len(args) != 1:
parser.error("incorrect number of arguments")
command = args[0]
if command not in ('start-server','create-db','drop-db','install-module','upgrade-module','check-quality','install-translation'):
parser.error("incorrect command")
parser.error("incorrect command")
def die(cond, msg):
if cond:
@ -314,7 +323,7 @@ options = {
'quality-logs' : opt.quality_logs or '',
'root-path' : opt.root_path or '',
'translate-in': [],
'port' : opt.port or 8069,
'port' : opt.port or 8069,
'database': opt.db_name or 'terp',
'modules' : opt.modules or [],
'login' : opt.login or 'admin',
@ -325,33 +334,33 @@ options = {
options['modules'] = opt.modules and map(lambda m: m.strip(), opt.modules.split(',')) or []
# Hint:i18n-import=purchase:ar_AR.po+sale:fr_FR.po,nl_BE.po
if opt.translate_in:
translate = opt.translate_in
for module_name,po_files in map(lambda x:tuple(x.split(':')),translate.split('+')):
for po_file in po_files.split(','):
translate = opt.translate_in
for module_name,po_files in map(lambda x:tuple(x.split(':')),translate.split('+')):
for po_file in po_files.split(','):
po_link = '%s/%s/i18n/%s'%(options['addons-path'], module_name, po_file)
options['translate-in'].append(po_link)
options['translate-in'].append(po_link)
uri = 'http://localhost:' + str(options['port'])
server_thread = threading.Thread(target=start_server,
args=(options['root-path'], options['port'], options['addons-path']))
try:
server_thread.start()
if command == 'create-db':
try:
server_thread.start()
if command == 'create-db':
create_db(uri, options['database'], options['login'], options['pwd'])
if command == 'drop-db':
if command == 'drop-db':
drop_db(uri, options['database'])
if command == 'install-module':
if command == 'install-module':
install_module(uri, options['database'], options['modules'],options['addons-path'],options['extra-addons'],options['login'], options['pwd'])
if command == 'upgrade-module':
if command == 'upgrade-module':
upgrade_module(uri, options['database'], options['modules'], options['login'], options['pwd'])
if command == 'check-quality':
check_quality(uri, options['login'], options['pwd'], options['database'], options['modules'], options['quality-logs'])
if command == 'install-translation':
if command == 'install-translation':
import_translate(uri, options['login'], options['pwd'], options['database'], options['translate-in'])
clean()
sys.exit(0)
except xmlrpclib.Fault, e:
print e.faultString
clean()
@ -360,7 +369,7 @@ except Exception, e:
print e
clean()
sys.exit(1)

View File

@ -586,6 +586,7 @@ class orm_template(object):
raise Exception(_('Please check that all your lines have %d columns.') % (len(fields),))
if not line[i]:
continue
field = fields[i]
if (len(field)==len(prefix)+1) and field[len(prefix)].endswith(':db_id'):
# Database ID
@ -822,7 +823,7 @@ class orm_template(object):
try:
id = ir_model_data_obj._update(cr, uid, self._name,
current_module, res, xml_id=data_id, mode=mode,
noupdate=noupdate, res_id=res_id)
noupdate=noupdate, res_id=res_id, context=context)
except Exception, e:
import psycopg2
if isinstance(e,psycopg2.IntegrityError):
@ -1349,7 +1350,7 @@ class orm_template(object):
def name_get(self, cr, user, ids, context=None):
raise _('The name_get method is not implemented on this object !')
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=None):
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=80):
raise _('The name_search method is not implemented on this object !')
def copy(self, cr, uid, id, default=None, context=None):
@ -1790,7 +1791,7 @@ class orm(orm_template):
f_pg_notnull = f_pg_def['attnotnull']
if isinstance(f, fields.function) and not f.store:
logger.notifyChannel('orm', netsvc.LOG_INFO, 'column %s (%s) in table %s removed: converted to a function !\n' % (k, f.string, self._table))
cr.execute('ALTER TABLE %s DROP COLUMN %s'% (self._table, k))
cr.execute('ALTER TABLE "%s" DROP COLUMN "%s"'% (self._table, k))
cr.commit()
f_obj_type = None
else:
@ -1838,7 +1839,7 @@ class orm(orm_template):
default = self._defaults[k](self, cr, 1, {})
if (default is not None):
ss = self._columns[k]._symbol_set
query = 'UPDATE "%s" SET "%s"=%s WHERE %s is NULL' % (self._table, k, ss[0], k)
query = 'UPDATE "%s" SET "%s"=%s WHERE "%s" is NULL' % (self._table, k, ss[0], k)
cr.execute(query, (ss[1](default),))
# add the NOT NULL constraint
cr.commit()
@ -2897,7 +2898,7 @@ class orm(orm_template):
return [(r['id'], tools.ustr(r[self._rec_name])) for r in self.read(cr, user, ids,
[self._rec_name], context, load='_classic_write')]
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=None):
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=80):
if not args:
args = []
if not context:

View File

@ -42,6 +42,7 @@ import reportlab
from lxml import etree
import copy
import tools
import locale
_regex = re.compile('\[\[(.+?)\]\]')
@ -133,6 +134,15 @@ units = [
def unit_get(size):
global units
if size:
if size.find('.') == -1:
decimal_point = '.'
try:
decimal_point = locale.RADIXCHAR
except:
decimal_point = locale.localeconv()['decimal_point']
size = size.replace(decimal_point, '.')
for unit in units:
res = unit[0].search(size, 0)
if res:

View File

@ -458,14 +458,14 @@ def trans_generate(lang, modules, dbname=None):
xml_name = "%s.%s" % (module, encode(xml_name))
if not pool.get(model):
logger.notifyChannel("db", netsvc.LOG_ERROR, "unable to find object %r" % (model,))
logger.notifyChannel("db", netsvc.LOG_ERROR, "Unable to find object %r" % (model,))
continue
try:
obj = pool.get(model).browse(cr, uid, res_id)
except BrowseRecordError:
logger.notifyChannel("db", netsvc.LOG_ERROR, "unable to find object %r with id %d" % (model, res_id))
exists = pool.get(model).exists(cr, uid, res_id)
if not exists:
logger.notifyChannel("db", netsvc.LOG_WARNING, "Unable to find object %r with id %d" % (model, res_id))
continue
obj = pool.get(model).browse(cr, uid, res_id)
if model=='ir.ui.view':
d = xml.dom.minidom.parseString(encode(obj.arch))