diff --git a/bin/addons/base/__terp__.py b/bin/addons/base/__terp__.py
index 2e42b5a08e3..d273c55a8d4 100644
--- a/bin/addons/base/__terp__.py
+++ b/bin/addons/base/__terp__.py
@@ -42,6 +42,7 @@
'ir/workflow/workflow_view.xml',
'module/module_wizard.xml',
'module/module_view.xml',
+ 'module/module_web_view.xml',
'module/module_data.xml',
'module/module_report.xml',
'res/res_request_view.xml',
diff --git a/bin/addons/base/module/__init__.py b/bin/addons/base/module/__init__.py
index b07332b81d4..aa775e29c1c 100644
--- a/bin/addons/base/module/__init__.py
+++ b/bin/addons/base/module/__init__.py
@@ -20,6 +20,7 @@
##############################################################################
import module
+import module_web
import wizard
import report
diff --git a/bin/addons/base/module/module_web.py b/bin/addons/base/module/module_web.py
new file mode 100644
index 00000000000..ca4463f620e
--- /dev/null
+++ b/bin/addons/base/module/module_web.py
@@ -0,0 +1,45 @@
+from osv import fields, osv, orm
+
+class module_web(osv.osv):
+ _name = "ir.module.web"
+ _description = "Web Module"
+
+ _columns = {
+ 'name': fields.char("Name", size=128, readonly=True, required=True),
+ 'description': fields.text("Description", readonly=True, translate=True),
+ 'author': fields.char("Author", size=128, readonly=True),
+ 'website': fields.char("Website", size=256, readonly=True),
+ 'state': fields.selection([
+ ('uninstallable','Uninstallable'),
+ ('uninstalled','Not Installed'),
+ ('installed','Installed')
+ ], string='State', readonly=True)
+ }
+
+ _defaults = {
+ 'state': lambda *a: 'uninstalled',
+ }
+ _order = 'name'
+
+ _sql_constraints = [
+ ('name_uniq', 'unique (name)', 'The name of the module must be unique !'),
+ ]
+
+ def update_module_list(self, cr, uid, modules, context={}):
+
+ for module in modules:
+ mod_name = module['name']
+ ids = self.search(cr, uid, [('name','=',mod_name)])
+ if ids:
+ self.write(cr, uid, ids, module)
+ else:
+ self.create(cr, uid, module)
+
+ def button_install(self, cr, uid, ids, context={}):
+ return self.write(cr, uid, ids, {'state': 'installed'}, context)
+
+ def button_uninstall(self, cr, uid, ids, context={}):
+ return self.write(cr, uid, ids, {'state': 'uninstalled'}, context)
+
+module_web()
+
diff --git a/bin/addons/base/module/module_web_view.xml b/bin/addons/base/module/module_web_view.xml
new file mode 100644
index 00000000000..d1348aa89e2
--- /dev/null
+++ b/bin/addons/base/module/module_web_view.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+ ir.module.web.tree
+ ir.module.web
+ tree
+
+
+
+
+
+
+
+
+
+
+
+
+
+ web_module_list
+ /modules
+
+
+
+
+
diff --git a/bin/netsvc.py b/bin/netsvc.py
index 5c2143535ef..36de1682eb1 100644
--- a/bin/netsvc.py
+++ b/bin/netsvc.py
@@ -365,10 +365,7 @@ class OpenERPDispatcher:
self.log('service', service_name)
self.log('method', method)
self.log('params', params)
- if hasattr(self,'auth_provider'):
- auth = self.auth_provider
- else:
- auth = None
+ auth = getattr(self, 'auth_provider', None)
result = ExportService.getService(service_name).dispatch(method, auth, params)
self.log('result', result)
# We shouldn't marshall None,
@@ -377,10 +374,7 @@ class OpenERPDispatcher:
return result
except Exception, e:
self.log('exception', tools.exception_to_unicode(e))
- if hasattr(e, 'traceback'):
- tb = e.traceback
- else:
- tb = sys.exc_info()
+ tb = getattr(e, 'traceback', sys.exc_info())
tb_s = "".join(traceback.format_exception(*tb))
if tools.config['debug_mode']:
import pdb
diff --git a/bin/osv/orm.py b/bin/osv/orm.py
index 2d2cf799c3f..f545c05f279 100644
--- a/bin/osv/orm.py
+++ b/bin/osv/orm.py
@@ -304,7 +304,7 @@ def get_pg_type(f):
elif isinstance(f.selection, list) and isinstance(f.selection[0][0], int):
f_size = -1
else:
- f_size = (hasattr(f, 'size') and f.size) or 16
+ f_size = getattr(f, 'size', 16)
if f_size == -1:
f_type = ('int4', 'INTEGER')
@@ -976,8 +976,7 @@ class orm_template(object):
res[f]['readonly'] = True
res[f]['states'] = {}
for arg in ('digits', 'invisible','filters'):
- if hasattr(self._columns[f], arg) \
- and getattr(self._columns[f], arg):
+ if getattr(self._columns[f], arg, None):
res[f][arg] = getattr(self._columns[f], arg)
#TODO: optimize
@@ -1427,7 +1426,7 @@ class orm_template(object):
act_id = int(data_menu.split(',')[1])
if act_id:
data_action = self.pool.get('ir.actions.act_window').browse(cr, user, [act_id], context)[0]
- result['submenu'] = hasattr(data_action,'menus') and data_action.menus or False
+ result['submenu'] = getattr(data_action,'menus', False)
if toolbar:
def clean(x):
x = x[2]
@@ -1866,7 +1865,7 @@ class orm(orm_template):
create = False
todo_end = []
self._field_create(cr, context=context)
- if not hasattr(self, "_auto") or self._auto:
+ if getattr(self, '_auto', True):
cr.execute("SELECT relname FROM pg_class WHERE relkind in ('r','v') AND relname='%s'" % self._table)
if not cr.rowcount:
cr.execute("CREATE TABLE \"%s\" (id SERIAL NOT NULL, PRIMARY KEY(id)) WITHOUT OIDS" % self._table)
@@ -2009,7 +2008,8 @@ class orm(orm_template):
f_pg_type = f_pg_def['typname']
f_pg_size = f_pg_def['size']
f_pg_notnull = f_pg_def['attnotnull']
- if isinstance(f, fields.function) and not f.store and (not hasattr(f,'nodrop') or not f.nodrop):
+ if isinstance(f, fields.function) and not f.store and\
+ not getattr(f, 'nodrop', False):
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.commit()
@@ -2162,7 +2162,7 @@ class orm(orm_template):
if not hasattr(self, '_log_access'):
# if not access is not specify, it is the same value as _auto
- self._log_access = not hasattr(self, "_auto") or self._auto
+ self._log_access = getattr(self, "_auto", True)
self._columns = self._columns.copy()
for store_field in self._columns:
diff --git a/bin/osv/osv.py b/bin/osv/osv.py
index 5b2e4ee8da8..8fb5afae8b1 100644
--- a/bin/osv/osv.py
+++ b/bin/osv/osv.py
@@ -195,8 +195,8 @@ class osv_memory(osv_base, orm.orm_memory):
# put objects in the pool var
#
def createInstance(cls, pool, module, cr):
- name = hasattr(cls, '_name') and cls._name or cls._inherit
- parent_names = hasattr(cls, '_inherit') and cls._inherit
+ name = getattr(cls, '_name', cls._inherit)
+ parent_names = getattr(cls, '_inherit', None)
if parent_names:
for parent_name in ((type(parent_names)==list) and parent_names or [parent_names]):
parent_class = pool.get(parent_name).__class__
@@ -209,7 +209,7 @@ class osv_memory(osv_base, orm.orm_memory):
else:
new.extend(cls.__dict__.get(s, []))
nattr[s] = new
- name = hasattr(cls, '_name') and cls._name or cls._inherit
+ name = getattr(cls, '_name', cls._inherit)
cls = type(name, (cls, parent_class), nattr)
obj = object.__new__(cls)
@@ -223,7 +223,7 @@ class osv(osv_base, orm.orm):
# put objects in the pool var
#
def createInstance(cls, pool, module, cr):
- parent_names = hasattr(cls, '_inherit') and cls._inherit
+ parent_names = getattr(cls, '_inherit', None)
if parent_names:
for parent_name in ((type(parent_names)==list) and parent_names or [parent_names]):
parent_class = pool.get(parent_name).__class__
@@ -247,7 +247,7 @@ class osv(osv_base, orm.orm):
else:
new.extend(cls.__dict__.get(s, []))
nattr[s] = new
- name = hasattr(cls, '_name') and cls._name or cls._inherit
+ name = getattr(cls, '_name', cls._inherit)
cls = type(name, (cls, parent_class), nattr)
obj = object.__new__(cls)
obj.__init__(pool, cr)
diff --git a/bin/report/report_sxw.py b/bin/report/report_sxw.py
index 0cd4b229595..5dc842806a0 100644
--- a/bin/report/report_sxw.py
+++ b/bin/report/report_sxw.py
@@ -85,7 +85,7 @@ class _float_format(float, _format):
def __str__(self):
digits = 2
- if hasattr(self,'_field') and hasattr(self._field, 'digits') and self._field.digits:
+ if hasattr(self,'_field') and getattr(self._field, 'digits', None):
digits = self._field.digits[1]
if hasattr(self, 'lang_obj'):
return self.lang_obj.format('%.' + str(digits) + 'f', self.name, True)
@@ -108,7 +108,7 @@ class _date_format(str, _format):
def __str__(self):
if self.val:
- if hasattr(self,'name') and (self.name):
+ if getattr(self,'name', None):
date = mx.DateTime.strptime(self.name,DT_FORMAT)
return date.strftime(self.lang_obj.date_format)
return self.val
@@ -120,7 +120,7 @@ class _dttime_format(str, _format):
def __str__(self):
if self.val:
- if hasattr(self,'name') and self.name:
+ if getattr(self,'name', None):
datetime = mx.DateTime.strptime(self.name,DHM_FORMAT)
return datetime.strftime(self.lang_obj.date_format+ " " + self.lang_obj.time_format)
return self.val
diff --git a/bin/service/http_server.py b/bin/service/http_server.py
index 72dd787533c..9cbb49571dc 100644
--- a/bin/service/http_server.py
+++ b/bin/service/http_server.py
@@ -137,7 +137,7 @@ class BaseHttpDaemon(threading.Thread, netsvc.Server):
if os.name != 'nt':
try:
self.server.socket.shutdown(
- hasattr(socket, 'SHUT_RDWR') and socket.SHUT_RDWR or 2)
+ getattr(socket, 'SHUT_RDWR', 2))
except socket.error, e:
if e.errno != 57: raise
# OSX, socket shutdowns both sides if any side closes it
diff --git a/bin/service/netrpc_server.py b/bin/service/netrpc_server.py
index 50e9b5e7a9b..6260ec3d0e5 100644
--- a/bin/service/netrpc_server.py
+++ b/bin/service/netrpc_server.py
@@ -42,10 +42,8 @@ class TinySocketClientThread(threading.Thread, netsvc.OpenERPDispatcher):
def __del__(self):
if self.sock:
try:
- if hasattr(socket, 'SHUT_RDWR'):
- self.socket.shutdown(socket.SHUT_RDWR)
- else:
- self.socket.shutdown(2)
+ self.socket.shutdown(
+ getattr(socket, 'SHUT_RDWR', 2))
except: pass
# That should garbage-collect and close it, too
self.sock = None
@@ -131,10 +129,8 @@ class TinySocketServerThread(threading.Thread,netsvc.Server):
for t in self.threads:
t.stop()
try:
- if hasattr(socket, 'SHUT_RDWR'):
- self.socket.shutdown(socket.SHUT_RDWR)
- else:
- self.socket.shutdown(2)
+ self.socket.shutdown(
+ getattr(socket, 'SHUT_RDWR', 2))
self.socket.close()
except:
return False
diff --git a/setup.py b/setup.py
index 7ebf8ce5a76..88d23886f0e 100755
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@
##############################################################################
#
# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL ().
+# Copyright (C) 2004-2010 Tiny SPRL ().
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
diff --git a/win32/setup.py b/win32/setup.py
index 0abf94a9a50..b06f94bcc2a 100644
--- a/win32/setup.py
+++ b/win32/setup.py
@@ -2,7 +2,7 @@
##############################################################################
#
# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2009 Tiny SPRL ().
+# Copyright (C) 2004-2010 Tiny SPRL ().
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as