Remove staticmethod, fix an improve BrowseRecord, remove company_id, fix

translation path
This commit is contained in:
ced@b2ck.com
2007-12-13 21:09:14 +01:00
parent e6c1c627cb
commit 8f9ffdf6ef
10 changed files with 28 additions and 67 deletions
+2 -2
View File
@@ -9,7 +9,7 @@
<form string="Property">
<separator string="Property" colspan="4"/>
<field name="name" select="1"/>
<field name="company_id" select="1"/>
<!--field name="company_id" select="1"/-->
<field name="fields_id" colspan="4" select="1"/>
<field name="value" colspan="4"/>
<field name="res_id" colspan="4"/>
@@ -23,7 +23,7 @@
<field name="arch" type="xml">
<tree string="Properties">
<field name="name"/>
<field name="company_id"/>
<!--field name="company_id"/-->
<field name="fields_id"/>
</tree>
</field>
+2 -4
View File
@@ -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'),
+1 -1
View File
@@ -101,7 +101,7 @@
<field name="view_id" ref="sequence_type_view_form"/>
<field name="act_window_id" ref="act_sequence_type_form"/>
</record>
<menuitem name="Administration/Sequences/"
<menuitem name="Administration/IR/Sequences/"
action="act_sequence_type_form" id="menu_ir_sequence_type"/>
</data>
</terp>
+1 -1
View File
@@ -72,7 +72,7 @@
<field name="view_id" ref="menu_view_form"/>
<field name="act_window_id" ref="act_menu_form"/>
</record>
<menuitem name="Administration/IR/"
<menuitem name="Administration/IR/UI/"
action="act_menu_form" id="menu_menu_form"/>
</data>
</terp>
-3
View File
@@ -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
+1 -2
View File
@@ -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)
+13 -40
View File
@@ -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
+1 -2
View File
@@ -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):
+2 -2
View File
@@ -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]
+5 -10
View File
@@ -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