[merge] fix-shebang from 5.0 to trunk

bzr revid: hmo@tinyerp.com-20091202091102-r509b0bgogyul6yx
bzr revid: xmo@tinyerp.com-20091202101458-6a1mo240grkld6do
This commit is contained in:
Xavier Morel 2009-12-02 11:14:58 +01:00
commit cf13b6c36e
10 changed files with 39 additions and 15 deletions

View File

@ -87,7 +87,7 @@ class Graph(dict):
## and we update the default values with values from the database ## and we update the default values with values from the database
additional_data.update(dict([(x.pop('name'), x) for x in cr.dictfetchall()])) additional_data.update(dict([(x.pop('name'), x) for x in cr.dictfetchall()]))
for package in self.values(): for package in self.values():
for k, v in additional_data[package.name].items(): for k, v in additional_data[package.name].items():
setattr(package, k, v) setattr(package, k, v)
@ -613,6 +613,16 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, **kwargs):
if hasattr(package, 'init') or hasattr(package, 'update') or package.state in ('to install', 'to upgrade'): if hasattr(package, 'init') or hasattr(package, 'update') or package.state in ('to install', 'to upgrade'):
has_updates = True has_updates = True
for kind in ('init', 'update'): for kind in ('init', 'update'):
if package.state=='to upgrade':
# upgrading the module information
modobj.write(cr, 1, [mid], {
'description': package.data.get('description', ''),
'shortdesc': package.data.get('name', ''),
'author': package.data.get('author', 'Unknown'),
'website': package.data.get('website', ''),
'license': package.data.get('license', 'GPL-2'),
'certificate': package.data.get('certificate') or None,
})
for filename in package.data.get('%s_xml' % kind, []): for filename in package.data.get('%s_xml' % kind, []):
logger.notifyChannel('init', netsvc.LOG_INFO, 'module %s: loading %s' % (m, filename)) logger.notifyChannel('init', netsvc.LOG_INFO, 'module %s: loading %s' % (m, filename))
name, ext = os.path.splitext(filename) name, ext = os.path.splitext(filename)

View File

@ -1,3 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #

View File

@ -734,7 +734,7 @@ class related(function):
t_id=t_data['id'] t_id=t_data['id']
t_data = t_data[self.arg[i]] t_data = t_data[self.arg[i]]
if t_id: if t_id:
obj.pool.get(field_detail['object']).write(cr,uid,[t_id],{args[-1]:values}) obj.pool.get(field_detail['object']).write(cr,uid,[t_id],{args[-1]:values}, context=context)
def _fnct_read(self, obj, cr, uid, ids, field_name, args, context=None): def _fnct_read(self, obj, cr, uid, ids, field_name, args, context=None):
self._field_get2(cr, uid, obj, context) self._field_get2(cr, uid, obj, context)
@ -757,7 +757,7 @@ class related(function):
except: except:
t_data = False t_data = False
break break
if field_detail['type'] in ('one2many', 'many2many'): if field_detail['type'] in ('one2many', 'many2many') and i != len(self.arg) - 1:
t_data = t_data[self.arg[i]][0] t_data = t_data[self.arg[i]][0]
else: else:
t_data = t_data[self.arg[i]] t_data = t_data[self.arg[i]]
@ -773,6 +773,12 @@ class related(function):
for r in res: for r in res:
if res[r]: if res[r]:
res[r] = (res[r], ng[res[r]]) res[r] = (res[r], ng[res[r]])
elif self._type in ('one2many', 'many2many'):
for r in res:
if res[r]:
res[r] = [x.id for x in res[r]]
return res return res
def __init__(self, *arg, **args): def __init__(self, *arg, **args):

View File

@ -89,14 +89,14 @@ class report_rml(report_int):
def create(self, cr, uid, ids, datas, context): def create(self, cr, uid, ids, datas, context):
xml = self.create_xml(cr, uid, ids, datas, context) xml = self.create_xml(cr, uid, ids, datas, context)
xml = tools.ustr(xml).encode('utf8') xml = tools.ustr(xml).encode('utf8')
if datas.get('report_type', 'pdf') == 'raw': report_type = datas.get('report_type', 'pdf')
return xml if report_type == 'raw':
return (xml,report_type)
rml = self.create_rml(cr, xml, uid, context) rml = self.create_rml(cr, xml, uid, context)
pool = pooler.get_pool(cr.dbname) pool = pooler.get_pool(cr.dbname)
ir_actions_report_xml_obj = pool.get('ir.actions.report.xml') ir_actions_report_xml_obj = pool.get('ir.actions.report.xml')
report_xml_ids = ir_actions_report_xml_obj.search(cr, uid, [('report_name', '=', self.name[7:])], context=context) report_xml_ids = ir_actions_report_xml_obj.search(cr, uid, [('report_name', '=', self.name[7:])], context=context)
self.title = report_xml_ids and ir_actions_report_xml_obj.browse(cr,uid,report_xml_ids)[0].name or 'OpenERP Report' self.title = report_xml_ids and ir_actions_report_xml_obj.browse(cr,uid,report_xml_ids)[0].name or 'OpenERP Report'
report_type = datas.get('report_type', 'pdf')
create_doc = self.generators[report_type] create_doc = self.generators[report_type]
pdf = create_doc(rml, title=self.title) pdf = create_doc(rml, title=self.title)
return (pdf, report_type) return (pdf, report_type)

View File

@ -457,4 +457,4 @@ if __name__=="__main__":
print 'Usage: rml2html input.rml >output.html' print 'Usage: rml2html input.rml >output.html'
print 'Try \'rml2html --help\' for more information.' print 'Try \'rml2html --help\' for more information.'
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -287,11 +287,8 @@ class db(netsvc.ExportService):
return True return True
def exp_db_exist(self, db_name): def exp_db_exist(self, db_name):
try: ## Not True: in fact, check if connection to database is possible. The database may exists
db = sql_db.db_connect(db_name) return bool(sql_db.db_connect(db_name))
return True
except:
return False
def exp_list(self): def exp_list(self):
db = sql_db.db_connect('template1') db = sql_db.db_connect('template1')

View File

@ -170,6 +170,7 @@ class Cursor(object):
sqllogs[type].clear() sqllogs[type].clear()
sum = timedelta(microseconds=sum) sum = timedelta(microseconds=sum)
log("SUM %s:%s/%d [%d]" % (type, str(sum), self.sql_log_count, sql_counter)) log("SUM %s:%s/%d [%d]" % (type, str(sum), self.sql_log_count, sql_counter))
sqllogs[type].clear()
process('from') process('from')
process('into') process('into')
self.sql_log_count = 0 self.sql_log_count = 0
@ -315,6 +316,15 @@ class Connection(object):
def serialized_cursor(self): def serialized_cursor(self):
return self.cursor(True) return self.cursor(True)
def __nonzero__(self):
"""Check if connection is possible"""
try:
cr = self.cursor()
cr.close()
return True
except:
return False
_dsn = '' _dsn = ''
for p in ('host', 'port', 'user', 'password'): for p in ('host', 'port', 'user', 'password'):

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################################## ##############################################################################
# #