diff --git a/bin/addons/__init__.py b/bin/addons/__init__.py index 395cf573c0a..96d23ea171a 100644 --- a/bin/addons/__init__.py +++ b/bin/addons/__init__.py @@ -87,7 +87,7 @@ class Graph(dict): ## and we update the default values with values from the database additional_data.update(dict([(x.pop('name'), x) for x in cr.dictfetchall()])) - + for package in self.values(): for k, v in additional_data[package.name].items(): 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'): has_updates = True 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, []): logger.notifyChannel('init', netsvc.LOG_INFO, 'module %s: loading %s' % (m, filename)) name, ext = os.path.splitext(filename) diff --git a/bin/addons/module_graph.py b/bin/addons/module_graph.py index 42fe6118d2a..74d4115a086 100755 --- a/bin/addons/module_graph.py +++ b/bin/addons/module_graph.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python # -*- coding: utf-8 -*- ############################################################################## # diff --git a/bin/openerp-server.py b/bin/openerp-server.py index dbf1caa7532..33b5fef9aeb 100755 --- a/bin/openerp-server.py +++ b/bin/openerp-server.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # -*- coding: utf-8 -*- ############################################################################## # diff --git a/bin/osv/fields.py b/bin/osv/fields.py index 17185c4e334..b51cdcfd0bf 100644 --- a/bin/osv/fields.py +++ b/bin/osv/fields.py @@ -734,7 +734,7 @@ class related(function): t_id=t_data['id'] t_data = t_data[self.arg[i]] 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): self._field_get2(cr, uid, obj, context) @@ -757,7 +757,7 @@ class related(function): except: t_data = False 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] else: t_data = t_data[self.arg[i]] @@ -773,6 +773,12 @@ class related(function): for r in res: if 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 def __init__(self, *arg, **args): diff --git a/bin/report/interface.py b/bin/report/interface.py index d50107f507b..e1dd37dbe2e 100644 --- a/bin/report/interface.py +++ b/bin/report/interface.py @@ -89,14 +89,14 @@ class report_rml(report_int): def create(self, cr, uid, ids, datas, context): xml = self.create_xml(cr, uid, ids, datas, context) xml = tools.ustr(xml).encode('utf8') - if datas.get('report_type', 'pdf') == 'raw': - return xml + report_type = datas.get('report_type', 'pdf') + if report_type == 'raw': + return (xml,report_type) rml = self.create_rml(cr, xml, uid, context) pool = pooler.get_pool(cr.dbname) 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) 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] pdf = create_doc(rml, title=self.title) return (pdf, report_type) diff --git a/bin/report/render/rml2html/rml2html.py b/bin/report/render/rml2html/rml2html.py index c197dae7675..9e419c652c1 100644 --- a/bin/report/render/rml2html/rml2html.py +++ b/bin/report/render/rml2html/rml2html.py @@ -457,4 +457,4 @@ if __name__=="__main__": print 'Usage: rml2html input.rml >output.html' print 'Try \'rml2html --help\' for more information.' -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/bin/service/web_services.py b/bin/service/web_services.py index c9113cc097e..ec554ac0325 100644 --- a/bin/service/web_services.py +++ b/bin/service/web_services.py @@ -287,11 +287,8 @@ class db(netsvc.ExportService): return True def exp_db_exist(self, db_name): - try: - db = sql_db.db_connect(db_name) - return True - except: - return False + ## Not True: in fact, check if connection to database is possible. The database may exists + return bool(sql_db.db_connect(db_name)) def exp_list(self): db = sql_db.db_connect('template1') diff --git a/bin/sql_db.py b/bin/sql_db.py index 93b031e0673..a84547b0b7c 100644 --- a/bin/sql_db.py +++ b/bin/sql_db.py @@ -170,6 +170,7 @@ class Cursor(object): sqllogs[type].clear() sum = timedelta(microseconds=sum) log("SUM %s:%s/%d [%d]" % (type, str(sum), self.sql_log_count, sql_counter)) + sqllogs[type].clear() process('from') process('into') self.sql_log_count = 0 @@ -315,6 +316,15 @@ class Connection(object): def serialized_cursor(self): return self.cursor(True) + def __nonzero__(self): + """Check if connection is possible""" + try: + cr = self.cursor() + cr.close() + return True + except: + return False + _dsn = '' for p in ('host', 'port', 'user', 'password'): diff --git a/bin/tools/graph.py b/bin/tools/graph.py index 148b30d396b..923fb39af51 100644 --- a/bin/tools/graph.py +++ b/bin/tools/graph.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # -*- coding: utf-8 -*- ############################################################################## # diff --git a/doc/tests/check_profile_l10n_all.py b/doc/tests/check_profile_l10n_all.py index ffde262bf58..f558a2a5b56 100644 --- a/doc/tests/check_profile_l10n_all.py +++ b/doc/tests/check_profile_l10n_all.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # -*- coding: utf-8 -*- ############################################################################## #