[MERGE]
bzr revid: christophe@tinyerp.com-20081208084816-n4ju99d7nz21gun5
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -137,7 +137,7 @@ msgstr "Vous ne pouvez pas créer ce type de document! (%s)"
|
||||
#. module: base
|
||||
#: wizard_field:module.lang.import,init,code:0
|
||||
msgid "Code (eg:en__US)"
|
||||
msgstr "Code (ex:fr_FR)"
|
||||
msgstr "Code (ex:fr__FR)"
|
||||
|
||||
#. module: base
|
||||
#: field:res.roles,parent_id:0
|
||||
|
||||
@@ -37,6 +37,7 @@ import netsvc
|
||||
|
||||
from tools.parse_version import parse_version
|
||||
|
||||
|
||||
class module_repository(osv.osv):
|
||||
_name = "ir.module.repository"
|
||||
_description = "Module Repository"
|
||||
@@ -208,7 +209,7 @@ class module(osv.osv):
|
||||
_('You try to remove a module that is installed or will be installed'))
|
||||
return super(module, self).unlink(cr, uid, ids, context=context)
|
||||
|
||||
def state_update(self, cr, uid, ids, newstate, states_to_update, context={}, level=50):
|
||||
def state_update(self, cr, uid, ids, newstate, states_to_update, context={}, level=100):
|
||||
if level<1:
|
||||
raise orm.except_orm(_('Error'), _('Recursion error in modules dependencies !'))
|
||||
demo = False
|
||||
|
||||
@@ -39,7 +39,8 @@
|
||||
"access_ir_ui_view_custom_group_user","ir_ui_view_custom_group_user","model_ir_ui_view_custom",,1,0,0,0
|
||||
"access_ir_ui_view_custom_group_system","ir_ui_view_custom_group_system","model_ir_ui_view_custom","group_system",1,1,1,1
|
||||
"access_ir_ui_view_sc_group_user","ir_ui_view_sc group_user","model_ir_ui_view_sc",,1,1,1,1
|
||||
"access_ir_values_group_erp_manager","ir_values group_erp_manager","model_ir_values",,1,1,1,1
|
||||
"access_ir_values_group_erp_manager","ir_values group_erp_manager","model_ir_values",group_erp_manager,1,1,1,1
|
||||
"access_ir_values_group_all","ir_values group_all","model_ir_values",,1,0,0,0
|
||||
"access_wizard_ir_model_menu_create_group_system","wizard_ir_model_menu_create group_system","model_wizard_ir_model_menu_create","group_system",1,1,1,1
|
||||
"access_wizard_ir_model_menu_create_line_group_system","wizard_ir_model_menu_create_line group_system","model_wizard_ir_model_menu_create_line","group_system",1,1,1,1
|
||||
"access_wizard_module_lang_export_group_system","wizard_module_lang_export group_system","model_wizard_module_lang_export","group_system",1,1,1,1
|
||||
|
||||
|
@@ -597,6 +597,9 @@ class function(_column):
|
||||
self._type = type
|
||||
self._fnct_search = fnct_search
|
||||
self.store = store
|
||||
if store:
|
||||
self._classic_read = True
|
||||
self._classic_write = True
|
||||
if type == 'float':
|
||||
self._symbol_c = '%f'
|
||||
self._symbol_f = lambda x: __builtin__.float(x or 0.0)
|
||||
|
||||
+85
-107
@@ -1433,6 +1433,7 @@ class orm(orm_template):
|
||||
cr.execute("ALTER TABLE \"%s\" ALTER COLUMN \"%s\" DROP NOT NULL" % (self._table, column['attname']))
|
||||
|
||||
# iterate on the "object columns"
|
||||
todo_update_store = []
|
||||
for k in self._columns:
|
||||
if k in ('id', 'write_uid', 'write_date', 'create_uid', 'create_date'):
|
||||
continue
|
||||
@@ -1474,20 +1475,9 @@ class orm(orm_template):
|
||||
cr.execute("UPDATE \"%s\" SET \"%s\"=NULL" % (self._table, k))
|
||||
else:
|
||||
cr.execute("UPDATE \"%s\" SET \"%s\"='%s'" % (self._table, k, default))
|
||||
|
||||
if isinstance(f, fields.function):
|
||||
cr.execute('select id from '+self._table)
|
||||
ids_lst = map(lambda x: x[0], cr.fetchall())
|
||||
while ids_lst:
|
||||
iids = ids_lst[:40]
|
||||
ids_lst = ids_lst[40:]
|
||||
res = f.get(cr, self, iids, k, 1, {})
|
||||
for key,val in res.items():
|
||||
if f._multi:
|
||||
val = val[k]
|
||||
if (val<>False) or (type(val)<>bool):
|
||||
cr.execute("UPDATE \"%s\" SET \"%s\"='%s' where id=%d"% (self._table, k, val, key))
|
||||
#else:
|
||||
# cr.execute("UPDATE \"%s\" SET \"%s\"=NULL where id=%d"% (self._table, k, key))
|
||||
todo_update_store.append((f,k))
|
||||
|
||||
# and add constraints if needed
|
||||
if isinstance(f, fields.many2one):
|
||||
@@ -1601,6 +1591,21 @@ class orm(orm_template):
|
||||
cr.commit()
|
||||
else:
|
||||
print "ERROR"
|
||||
for f,k in todo_update_store:
|
||||
cr.execute('select id from '+self._table)
|
||||
ids_lst = map(lambda x: x[0], cr.fetchall())
|
||||
while ids_lst:
|
||||
iids = ids_lst[:40]
|
||||
ids_lst = ids_lst[40:]
|
||||
res = f.get(cr, self, iids, k, 1, {})
|
||||
for key,val in res.items():
|
||||
if f._multi:
|
||||
val = val[k]
|
||||
if (val<>False) or (type(val)<>bool):
|
||||
cr.execute("UPDATE \"%s\" SET \"%s\"='%s' where id=%d"% (self._table, k, val, key))
|
||||
#else:
|
||||
# cr.execute("UPDATE \"%s\" SET \"%s\"=NULL where id=%d"% (self._table, k, key))
|
||||
|
||||
else:
|
||||
cr.execute("SELECT relname FROM pg_class WHERE relkind in ('r','v') AND relname='%s'" % self._table)
|
||||
create = not bool(cr.fetchone())
|
||||
@@ -1627,29 +1632,33 @@ class orm(orm_template):
|
||||
def __init__(self, cr):
|
||||
super(orm, self).__init__(cr)
|
||||
self._columns = self._columns.copy()
|
||||
f = filter(lambda a: isinstance(self._columns[a], fields.function) and self._columns[a].store, self._columns)
|
||||
if f:
|
||||
list_store = []
|
||||
tuple_store = ()
|
||||
tuple_fn = ()
|
||||
for store_field in f:
|
||||
if not self._columns[store_field].store == True:
|
||||
dict_store = self._columns[store_field].store
|
||||
key = dict_store.keys()
|
||||
list_data = []
|
||||
for i in key:
|
||||
tuple_store = self._name, store_field, self._columns[store_field]._fnct.__name__, tuple(dict_store[i][0]), dict_store[i][1], i
|
||||
list_data.append(tuple_store)
|
||||
#tuple_store=self._name,store_field,self._columns[store_field]._fnct.__name__,tuple(dict_store[key[0]][0]),dict_store[key[0]][1]
|
||||
for l in list_data:
|
||||
list_store = []
|
||||
if l[5] in self.pool._store_function.keys():
|
||||
self.pool._store_function[l[5]].append(l)
|
||||
temp_list = list(set(self.pool._store_function[l[5]]))
|
||||
self.pool._store_function[l[5]] = temp_list
|
||||
else:
|
||||
list_store.append(l)
|
||||
self.pool._store_function[l[5]] = list_store
|
||||
for store_field in self._columns:
|
||||
f = self._columns[store_field]
|
||||
if not isinstance(f, fields.function):
|
||||
continue
|
||||
if not f.store:
|
||||
continue
|
||||
if self._columns[store_field].store is True:
|
||||
sm = {self._name:(lambda self,cr, uid, ids, c={}: ids, None)}
|
||||
else:
|
||||
sm = self._columns[store_field].store
|
||||
for object, aa in sm.items():
|
||||
if len(aa)==2:
|
||||
(fnct,fields2)=aa
|
||||
order = 1
|
||||
elif len(aa)==3:
|
||||
(fnct,fields2,order)=aa
|
||||
else:
|
||||
raise except_orm(_('Error'),
|
||||
_('Invalid function definition %s in object %s !' % (store_field, self._name)))
|
||||
self.pool._store_function.setdefault(object, [])
|
||||
ok = True
|
||||
for x,y,z,e,f in self.pool._store_function[object]:
|
||||
if (x==self._name) and (y==store_field) and (e==fields2):
|
||||
ok = False
|
||||
if ok:
|
||||
self.pool._store_function[object].append( (self._name, store_field, fnct, fields2, order))
|
||||
self.pool._store_function[object].sort(lambda x,y: cmp(x[4],y[4]))
|
||||
|
||||
for (key, _, msg) in self._sql_constraints:
|
||||
self.pool._sql_error[self._table+'_'+key] = msg
|
||||
@@ -1978,15 +1987,10 @@ class orm(orm_template):
|
||||
ids = [ids]
|
||||
|
||||
fn_list = []
|
||||
if self._name in self.pool._store_function.keys():
|
||||
list_store = self.pool._store_function[self._name]
|
||||
fn_data = ()
|
||||
id_change = []
|
||||
for tuple_fn in list_store:
|
||||
for id in ids:
|
||||
id_change.append(self._store_get_ids(cr, uid, id, tuple_fn, context)[0])
|
||||
fn_data = id_change, tuple_fn
|
||||
fn_list.append(fn_data)
|
||||
for fnct in self.pool._store_function.get(self._name, []):
|
||||
ids2 = filter(None, fnct[2](self,cr, uid, ids, context))
|
||||
if ids2:
|
||||
fn_list.append( (fnct[0], fnct[1], ids2) )
|
||||
|
||||
delta = context.get('read_delta', False)
|
||||
if delta and self._log_access:
|
||||
@@ -2033,10 +2037,11 @@ class orm(orm_template):
|
||||
else:
|
||||
cr.execute('delete from "'+self._table+'" ' \
|
||||
'where id in ('+str_d+')', sub_ids)
|
||||
if fn_list:
|
||||
for ids, tuple_fn in fn_list:
|
||||
self._store_set_values(cr, uid, ids, tuple_fn, id_change, context)
|
||||
|
||||
for object,field,ids in fn_list:
|
||||
ids = self.pool.get(object).search(cr, uid, [('id','in', ids)], context=context)
|
||||
if ids:
|
||||
self.pool.get(object)._store_set_values(cr, uid, ids, field, context)
|
||||
return True
|
||||
|
||||
#
|
||||
@@ -2247,22 +2252,17 @@ class orm(orm_template):
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for id in ids:
|
||||
wf_service.trg_write(user, self._name, id, cr)
|
||||
self._update_function_stored(cr, user, ids, context=context)
|
||||
|
||||
if self._name in self.pool._store_function.keys():
|
||||
list_store = self.pool._store_function[self._name]
|
||||
for tuple_fn in list_store:
|
||||
flag = False
|
||||
if not tuple_fn[3]:
|
||||
flag = True
|
||||
for field in tuple_fn[3]:
|
||||
if field in vals.keys():
|
||||
flag = True
|
||||
break
|
||||
if flag:
|
||||
id_change = self._store_get_ids(cr, user, ids[0], tuple_fn, context)
|
||||
self._store_set_values(cr, user, ids[0], tuple_fn, id_change, context)
|
||||
|
||||
for fnct in self.pool._store_function.get(self._name, []):
|
||||
ok = False
|
||||
for key in vals.keys():
|
||||
if (not fnct[3]) or (key in fnct[3]):
|
||||
ok = True
|
||||
if ok:
|
||||
ids2 = fnct[2](self,cr, user, ids, context)
|
||||
ids2 = filter(None, ids2)
|
||||
if ids2:
|
||||
self.pool.get(fnct[0])._store_set_values(cr, user, ids2, fnct[1], context)
|
||||
return True
|
||||
|
||||
#
|
||||
@@ -2369,54 +2369,32 @@ class orm(orm_template):
|
||||
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_create(user, self._name, id_new, cr)
|
||||
self._update_function_stored(cr, user, [id_new], context=context)
|
||||
if self._name in self.pool._store_function.keys():
|
||||
list_store = self.pool._store_function[self._name]
|
||||
for tuple_fn in list_store:
|
||||
id_change = self._store_get_ids(cr, user, id_new, tuple_fn, context)
|
||||
self._store_set_values(cr, user, id_new, tuple_fn, id_change, context)
|
||||
|
||||
for fnct in self.pool._store_function.get(self._name, []):
|
||||
ids2 = fnct[2](self,cr, user, [id_new], context)
|
||||
ids2 = filter(None, ids2)
|
||||
if ids2:
|
||||
self.pool.get(fnct[0])._store_set_values(cr, user, ids2, fnct[1], context)
|
||||
return id_new
|
||||
|
||||
def _store_get_ids(self, cr, uid, ids, tuple_fn, context):
|
||||
parent_id = getattr(self.pool.get(tuple_fn[0]), tuple_fn[4].func_name)(cr, uid, [ids])
|
||||
return parent_id
|
||||
|
||||
def _store_set_values(self, cr, uid, ids, tuple_fn, parent_id, context):
|
||||
name = tuple_fn[1]
|
||||
table = tuple_fn[0]
|
||||
def _store_set_values(self, cr, uid, ids, field, context):
|
||||
args = {}
|
||||
vals_tot = getattr(self.pool.get(table), tuple_fn[2])(cr, uid, parent_id, name, args, context)
|
||||
write_dict = {}
|
||||
for id in vals_tot.keys():
|
||||
write_dict[name] = vals_tot[id]
|
||||
self.pool.get(table).write(cr, uid, [id], write_dict)
|
||||
return True
|
||||
|
||||
def _update_function_stored(self, cr, user, ids, context=None):
|
||||
if not context:
|
||||
context = {}
|
||||
f = filter(lambda a: isinstance(self._columns[a], fields.function) \
|
||||
and self._columns[a].store, self._columns)
|
||||
if f:
|
||||
result = self.read(cr, user, ids, fields=f, context=context)
|
||||
for res in result:
|
||||
upd0 = []
|
||||
upd1 = []
|
||||
for field in res:
|
||||
if field not in f:
|
||||
continue
|
||||
value = res[field]
|
||||
if self._columns[field]._type in ('many2one', 'one2one'):
|
||||
try:
|
||||
value = res[field][0]
|
||||
except:
|
||||
value = res[field]
|
||||
upd0.append('"'+field+'"='+self._columns[field]._symbol_set[0])
|
||||
upd1.append(self._columns[field]._symbol_set[1](value))
|
||||
upd1.append(res['id'])
|
||||
cr.execute('update "' + self._table + '" set ' + \
|
||||
string.join(upd0, ',') + ' where id = %d', upd1)
|
||||
result = self._columns[field].get(cr, self, ids, field, uid, context=context)
|
||||
for id,value in result.items():
|
||||
upd0 = []
|
||||
upd1 = []
|
||||
if self._columns[field]._multi:
|
||||
value = value[field]
|
||||
if self._columns[field]._type in ('many2one', 'one2one'):
|
||||
try:
|
||||
value = value[0]
|
||||
except:
|
||||
pass
|
||||
upd0.append('"'+field+'"='+self._columns[field]._symbol_set[0])
|
||||
upd1.append(self._columns[field]._symbol_set[1](value))
|
||||
upd1.append(id)
|
||||
cr.execute('update "' + self._table + '" set ' + \
|
||||
string.join(upd0, ',') + ' where id = %d', upd1)
|
||||
return True
|
||||
|
||||
#
|
||||
|
||||
@@ -67,6 +67,7 @@ class db(netsvc.Service):
|
||||
db = sql_db.db_connect('template1', serialize=1)
|
||||
db.truedb.autocommit()
|
||||
cr = db.cursor()
|
||||
time.sleep(0.2)
|
||||
cr.execute('CREATE DATABASE ' + db_name + ' ENCODING \'unicode\'')
|
||||
cr.close()
|
||||
class DBInitialize(object):
|
||||
|
||||
Reference in New Issue
Block a user