diff --git a/trytond/ir/property.xml b/trytond/ir/property.xml index f4e1b4a66e..caa1754da0 100644 --- a/trytond/ir/property.xml +++ b/trytond/ir/property.xml @@ -9,7 +9,7 @@
- + @@ -23,7 +23,7 @@ - + diff --git a/trytond/ir/sequence.py b/trytond/ir/sequence.py index 997853649f..f4c0ac0a60 100644 --- a/trytond/ir/sequence.py +++ b/trytond/ir/sequence.py @@ -19,8 +19,7 @@ class Sequence(OSV): _name = 'ir.sequence' _description = __doc__ - @staticmethod - def _code_get(obj, cursor, user, context=None): + def _code_get(self, cursor, user, context=None): cursor.execute('select code, name from ir_sequence_type') return cursor.fetchall() @@ -42,8 +41,7 @@ class Sequence(OSV): 'padding' : lambda *a : 0, } - @staticmethod - def _process(string): + def _process(self, string): return (string or '') % { 'year':time.strftime('%Y'), 'month': time.strftime('%m'), diff --git a/trytond/ir/sequence.xml b/trytond/ir/sequence.xml index a59387aa9d..ac6705e2a5 100644 --- a/trytond/ir/sequence.xml +++ b/trytond/ir/sequence.xml @@ -101,7 +101,7 @@ - diff --git a/trytond/ir/ui/menu.xml b/trytond/ir/ui/menu.xml index d22d3aba81..7e5f5cdfa8 100644 --- a/trytond/ir/ui/menu.xml +++ b/trytond/ir/ui/menu.xml @@ -72,7 +72,7 @@ - diff --git a/trytond/netsvc.py b/trytond/netsvc.py index a7af3d658f..4118dbd873 100644 --- a/trytond/netsvc.py +++ b/trytond/netsvc.py @@ -120,15 +120,12 @@ class Service(object): def create(self, cursor, user, ids, datas, context): return - @staticmethod def trg_validate(user, res_type, res_id, signal, cursor): pass - @staticmethod def trg_delete(user, res_type, res_id, cursor): pass - @staticmethod def trg_write(user, res_type, res_id, cursor): pass diff --git a/trytond/osv/fields.py b/trytond/osv/fields.py index 731b40b7cb..d3a2d5908d 100644 --- a/trytond/osv/fields.py +++ b/trytond/osv/fields.py @@ -111,8 +111,7 @@ class Char(_column): _column.__init__(self, string=string, size=size, **args) self._symbol_set = (self._symbol_c, self._symbol_set_char) - @staticmethod - def _symbol_set_char(symb): + def _symbol_set_char(self, symb): """ takes a string (encoded in utf8) and returns a string (encoded in utf8) diff --git a/trytond/osv/orm.py b/trytond/osv/orm.py index 1541e8118e..a3c1746c60 100644 --- a/trytond/osv/orm.py +++ b/trytond/osv/orm.py @@ -19,31 +19,6 @@ class ExceptORM(Exception): except_orm = ExceptORM -class BrowseNull(object): - "Readonly python database object browser" - - def __init__(self): - self._id = False - - @staticmethod - def __getitem__(name): - return False - - @staticmethod - def __int__(): - return False - - @staticmethod - def __str__(): - return '' - - @staticmethod - def __nonzero__(): - return False - -browse_null = BrowseNull - - # TODO: execute an object method on BrowseRecordList class BrowseRecordList(list): @@ -62,8 +37,6 @@ class BrowseRecord(object): table : the object (inherited from orm) context : a dictionnary with an optionnal context ''' - assert object_id, 'Wrong ID for the browse record, got ' + \ - str(object_id) + ', expected an integer.' self._list_class = list_class or BrowseRecordList self._cursor = cursor self._user = user @@ -74,14 +47,14 @@ class BrowseRecord(object): cache.setdefault(table._name, {}) self._data = cache[table._name] - if not id in self._data: + if not object_id in self._data: self._data[object_id] = {'id': object_id} self._cache = cache def __getitem__(self, name): if name == 'id': return self._id - if not self._data[self._id].has_key(name): + if not self._data[self._id].has_key(name) and self._id: # build the list of fields we will fetch # fetch the definition of the field which was asked for @@ -126,18 +99,15 @@ class BrowseRecord(object): for data in datas: for i, j in ffields: if j._type in ('many2one', 'one2one'): - if data[i]: - obj = self._table.pool.get(j._obj) - if not j._classic_write: - ids2 = data[i][0] - else: - ids2 = data[i] - data[i] = BrowseRecord(self._cursor, self._user, - ids2, obj, self._cache, - context=self._context, - list_class=self._list_class) + obj = self._table.pool.get(j._obj) + if not j._classic_write and data[i]: + ids2 = data[i][0] else: - data[i] = BrowseNull() + ids2 = data[i] + data[i] = BrowseRecord(self._cursor, self._user, + ids2, obj, self._cache, + context=self._context, + list_class=self._list_class) elif j._type in ('one2many', 'many2many') and len(data[i]): data[i] = self._list_class([BrowseRecord(self._cursor, self._user, x, self._table.pool.get(j._obj), @@ -179,6 +149,9 @@ class BrowseRecord(object): def __hash__(self): return hash((self._table_name, self._id)) + def __nonzero__(self): + return bool(self._id) + __repr__ = __str__ browse_record = BrowseRecord diff --git a/trytond/tools/convert.py b/trytond/tools/convert.py index ad22132d6b..e2bf42d0d6 100644 --- a/trytond/tools/convert.py +++ b/trytond/tools/convert.py @@ -505,8 +505,7 @@ class XMLImport(object): action, True, True, xml_id=rec_id) return ('ir.ui.menu', pid) - @staticmethod - def _assert_equals(i, j, prec=4): + def _assert_equals(self, i, j, prec=4): return not round(i - j, prec) def _tag_assert(self, cursor, rec, data_node=None): diff --git a/trytond/tools/misc.py b/trytond/tools/misc.py index db01ac8c91..24b9693798 100644 --- a/trytond/tools/misc.py +++ b/trytond/tools/misc.py @@ -393,8 +393,8 @@ def get_languages(): def scan_languages(): import glob file_list = [os.path.splitext(os.path.basename(f))[0] \ - for f in glob.glob(os.path.join(CONFIG['root_path'], - 'i18n', '*.csv'))] + for f in glob.glob(os.path.join(os.path.dirname( + os.path.dirname(__file__)), 'i18n', '*.csv'))] lang_dict = get_languages() return [(lang, lang_dict.get(lang, lang)) for lang in file_list] diff --git a/trytond/wkf_service/wkf_service.py b/trytond/wkf_service/wkf_service.py index 3dd09c8513..a38413d6ce 100644 --- a/trytond/wkf_service/wkf_service.py +++ b/trytond/wkf_service/wkf_service.py @@ -21,8 +21,7 @@ class WorkflowService(Service): "Clear workflow cache" self.wkf_on_create_cache[cursor.dbname] = {} - @staticmethod - def trg_write(user, res_type, res_id, cursor): + def trg_write(self, user, res_type, res_id, cursor): "Trigger write" ident = (user, res_type, res_id) cursor.execute('SELECT id FROM wkf_instance ' \ @@ -31,8 +30,7 @@ class WorkflowService(Service): for (instance_id,) in cursor.fetchall(): instance.update(cursor, instance_id, ident) - @staticmethod - def trg_trigger(user, res_type, res_id, cursor): + def trg_trigger(self, user, res_type, res_id, cursor): "Trigger trigger" cursor.execute('SELECT instance_id FROM wkf_triggers ' \ 'WHERE res_id = %d AND model = %s', (res_id, res_type)) @@ -43,8 +41,7 @@ class WorkflowService(Service): ident = cursor.fetchone() instance.update(cursor, instance_id, ident) - @staticmethod - def trg_delete(user, res_type, res_id, cursor): + def trg_delete(self, user, res_type, res_id, cursor): "Trigger delete" ident = (user, res_type, res_id) instance.delete(cursor, ident) @@ -63,8 +60,7 @@ class WorkflowService(Service): for (wkf_id,) in wkf_ids: instance.create(cursor, ident, wkf_id) - @staticmethod - def trg_validate(user, res_type, res_id, signal, cursor): + def trg_validate(self, user, res_type, res_id, signal, cursor): "Trigger validate" ident = (user, res_type, res_id) # ids of all active workflow instances @@ -75,8 +71,7 @@ class WorkflowService(Service): for (instance_id,) in cursor.fetchall(): instance.validate(cursor, instance_id, ident, signal) - @staticmethod - def trg_redirect(user, res_type, res_id, new_rid, cursor): + def trg_redirect(self, user, res_type, res_id, new_rid, cursor): """ Trigger redirect make all workitems which are waiting for a (subflow) workflow instance