diff --git a/addons/audittrail/audittrail.py b/addons/audittrail/audittrail.py
index 22ddcafd7f9..be7d3787815 100644
--- a/addons/audittrail/audittrail.py
+++ b/addons/audittrail/audittrail.py
@@ -19,35 +19,39 @@
#
##############################################################################
-
from osv import fields, osv
from osv.osv import osv_pool
from tools.translate import _
import ir
-import netsvc
import pooler
-import string
-import time, copy
+import time
class audittrail_rule(osv.osv):
+ """
+ For Auddittrail RUle
+ """
_name = 'audittrail.rule'
+ _description = "Audittrail Rule"
_columns = {
- "name": fields.char("Rule Name", size=32, required=True),
- "object_id": fields.many2one('ir.model', 'Object', required=True),
- "user_id": fields.many2many('res.users', 'audittail_rules_users', 'user_id', 'rule_id', 'Users'),
- "log_read": fields.boolean("Log reads"),
- "log_write": fields.boolean("Log writes"),
- "log_unlink": fields.boolean("Log deletes"),
- "log_create": fields.boolean("Log creates"),
- "state": fields.selection((("draft", "Draft"), ("subscribed", "Subscribed")), "State", required=True),
- "action_id":fields.many2one('ir.actions.act_window', "Action ID"),
+ "name": fields.char("Rule Name", size=32, required=True),
+ "object_id": fields.many2one('ir.model', 'Object', required=True),
+ "user_id": fields.many2many('res.users', 'audittail_rules_users',
+ 'user_id', 'rule_id', 'Users'),
+ "log_read": fields.boolean("Log reads"),
+ "log_write": fields.boolean("Log writes"),
+ "log_unlink": fields.boolean("Log deletes"),
+ "log_create": fields.boolean("Log creates"),
+ "state": fields.selection((("draft", "Draft"),
+ ("subscribed", "Subscribed")),
+ "State", required=True),
+ "action_id": fields.many2one('ir.actions.act_window', "Action ID"),
}
_defaults = {
- 'state': lambda *a: 'draft',
- 'log_create': lambda *a: 1,
- 'log_unlink': lambda *a: 1,
- 'log_write': lambda *a: 1,
+ 'state': lambda *a: 'draft',
+ 'log_create': lambda *a: 1,
+ 'log_unlink': lambda *a: 1,
+ 'log_write': lambda *a: 1,
}
_sql_constraints = [
@@ -56,58 +60,83 @@ class audittrail_rule(osv.osv):
__functions = {}
def subscribe(self, cr, uid, ids, *args):
+ """
+ subscriber Rule on object and apply action on that object.
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of Auddittrail RUle’s IDs.
+ @return: True
+ """
+ obj_action = self.pool.get('ir.actions.act_window')
+ obj_model = self.pool.get('ir.model.data')
+ #start Loop
for thisrule in self.browse(cr, uid, ids):
obj = self.pool.get(thisrule.object_id.model)
if not obj:
raise osv.except_osv(
- _('WARNING:audittrail is not part of the pool'),
+ _('WARNING: audittrail is not part of the pool'),
_('Change audittrail depends -- Setting rule as DRAFT'))
self.write(cr, uid, [thisrule.id], {"state": "draft"})
- val={
- "name":'View Log',
- "res_model":'audittrail.log',
- "src_model":thisrule.object_id.model,
- "domain":"[('object_id','=',"+str(thisrule.object_id.id)+"),('res_id', '=', active_id)]"
+ val = {
+ "name": 'View Log',
+ "res_model": 'audittrail.log',
+ "src_model": thisrule.object_id.model,
+ "domain": "[('object_id','=', " + str(thisrule.object_id.id) + "), ('res_id', '=', active_id)]"
}
- id=self.pool.get('ir.actions.act_window').create(cr, uid, val)
- self.write(cr, uid, [thisrule.id], {"state": "subscribed", "action_id":id})
+ id = obj_action.create(cr, uid, val)
+ self.write(cr, uid, [thisrule.id], {"state": "subscribed", "action_id": id})
keyword = 'client_action_relate'
- value = 'ir.actions.act_window,'+str(id)
- res=self.pool.get('ir.model.data').ir_set(cr, uid, 'action', keyword, 'View_log_'+thisrule.object_id.model, [thisrule.object_id.model], value, replace=True, isobject=True, xml_id=False)
+ value = 'ir.actions.act_window,' + str(id)
+ res = obj_model.ir_set(cr, uid, 'action', keyword, 'View_log_' + thisrule.object_id.model, [thisrule.object_id.model], value, replace=True, isobject=True, xml_id=False)
+ #End Loop
return True
-
-
def unsubscribe(self, cr, uid, ids, *args):
+ """
+ unsubscribe Rule on object
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of Auddittrail RUle’s IDs.
+ @return: True
+ """
+ obj_action = self.pool.get('ir.actions.act_window')
+ val_obj = self.pool.get('ir.values')
+ #start Loop
for thisrule in self.browse(cr, uid, ids):
- if thisrule.id in self.__functions :
+ if thisrule.id in self.__functions:
for function in self.__functions[thisrule.id]:
setattr(function[0], function[1], function[2])
- w_id=self.pool.get('ir.actions.act_window').search(cr, uid, [('name', '=', 'View Log'), ('res_model', '=', 'audittrail.log'), ('src_model', '=', thisrule.object_id.model)])
- self.pool.get('ir.actions.act_window').unlink(cr, uid, w_id)
- val_obj=self.pool.get('ir.values')
- value="ir.actions.act_window"+','+str(w_id[0])
- val_id=val_obj.search(cr, uid, [('model', '=', thisrule.object_id.model), ('value', '=', value)])
+ w_id = obj_action.search(cr, uid, [('name', '=', 'View Log'), ('res_model', '=', 'audittrail.log'), ('src_model', '=', thisrule.object_id.model)])
+ obj_action.unlink(cr, uid, w_id)
+ value = "ir.actions.act_window" + ',' + str(w_id[0])
+ val_id = val_obj.search(cr, uid, [('model', '=', thisrule.object_id.model), ('value', '=', value)])
if val_id:
res = ir.ir_del(cr, uid, val_id[0])
self.write(cr, uid, [thisrule.id], {"state": "draft"})
+ #End Loop
return True
audittrail_rule()
class audittrail_log(osv.osv):
+ """
+ For Audittrail Log
+ """
_name = 'audittrail.log'
-
+ _description = "Audittrail Log"
_columns = {
- "name": fields.char("Name", size=32),
- "object_id": fields.many2one('ir.model', 'Object'),
- "user_id": fields.many2one('res.users', 'User'),
- "method": fields.selection((('read', 'Read'), ('write', 'Write'), ('unlink', 'Delete'), ('create', 'Create')), "Method"),
- "timestamp": fields.datetime("Date"),
- "res_id":fields.integer('Resource Id'),
- "line_ids":fields.one2many('audittrail.log.line', 'log_id', 'Log lines'),
+ "name": fields.char("Name", size=32),
+ "object_id": fields.many2one('ir.model', 'Object'),
+ "user_id": fields.many2one('res.users', 'User'),
+ "method": fields.selection((('read', 'Read'),
+ ('write', 'Write'),
+ ('unlink', 'Delete'),
+ ('create', 'Create')), "Method"),
+ "timestamp": fields.datetime("Date"),
+ "res_id": fields.integer('Resource Id'),
+ "line_ids": fields.one2many('audittrail.log.line', 'log_id', 'Log lines'),
}
_defaults = {
"timestamp": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S")
@@ -116,235 +145,256 @@ class audittrail_log(osv.osv):
audittrail_log()
+
class audittrail_log_line(osv.osv):
- _name='audittrail.log.line'
- _columns={
- 'field_id': fields.many2one('ir.model.fields', 'Fields', required=True),
- 'log_id':fields.many2one('audittrail.log', 'Log'),
- 'log':fields.integer("Log ID"),
- 'old_value':fields.text("Old Value"),
- 'new_value':fields.text("New Value"),
- 'old_value_text':fields.text('Old value Text'),
- 'new_value_text':fields.text('New value Text'),
- 'field_description':fields.char('Field Description' , size=64),
- }
+ """
+ Audittrail Log Line.
+ """
+ _name = 'audittrail.log.line'
+ _description = "Log Line"
+ _columns = {
+ 'field_id': fields.many2one('ir.model.fields', 'Fields', required=True),
+ 'log_id': fields.many2one('audittrail.log', 'Log'),
+ 'log': fields.integer("Log ID"),
+ 'old_value': fields.text("Old Value"),
+ 'new_value': fields.text("New Value"),
+ 'old_value_text': fields.text('Old value Text'),
+ 'new_value_text': fields.text('New value Text'),
+ 'field_description': fields.char('Field Description', size=64),
+ }
audittrail_log_line()
+
+
class audittrail_objects_proxy(osv_pool):
- def get_value_text(self, cr, uid, field_name, values, object, context={}):
- pool = pooler.get_pool(cr.dbname)
- obj=pool.get(object.model)
- obj_ids= pool.get('ir.model').search(cr, uid, [('model', '=', object.model)])
- model_object=pool.get('ir.model').browse(cr, uid, obj_ids)[0]
- f_id= pool.get('ir.model.fields').search(cr, uid, [('name', '=', field_name), ('model_id', '=', object.id)])
- if f_id:
- field=pool.get('ir.model.fields').read(cr, uid, f_id)[0]
- model=field['relation']
+
+ def get_value_text(self, cr, uid, field_name, values, object, context=None):
+
+ if not context:
+ context = {}
+ pool = pooler.get_pool(cr.dbname)
+ f_id = pool.get('ir.model.fields').search(cr, uid, [('name', '=', field_name), ('model_id', '=', object.id)])
+ if f_id:
+ field = pool.get('ir.model.fields').read(cr, uid, f_id)[0]
+ model = field['relation']
- if field['ttype']=='many2one':
- if values:
- if type(values)==tuple:
- values=values[0]
- val=pool.get(model).read(cr, uid, [values], [pool.get(model)._rec_name])
- if len(val):
- return val[0][pool.get(model)._rec_name]
- elif field['ttype'] == 'many2many':
- value=[]
- if values:
- for id in values:
- val=pool.get(model).read(cr, uid, [id], [pool.get(model)._rec_name])
- if len(val):
- value.append(val[0][pool.get(model)._rec_name])
+ if field['ttype'] == 'many2one':
+ if values:
+ if type(values) == tuple:
+ values = values[0]
+ val = pool.get(model).read(cr, uid, [values], [pool.get(model)._rec_name])
+ if val:
+ return val[0][pool.get(model)._rec_name]
+ elif field['ttype'] == 'many2many':
+ value = []
+ if values:
+ for id in values:
+ val = pool.get(model).read(cr, uid, [id], [pool.get(model)._rec_name])
+ if val:
+ value.append(val[0][pool.get(model)._rec_name])
+ return value
+
+ elif field['ttype'] == 'one2many':
+ if values:
+ value = []
+ for id in values:
+ val = pool.get(model).read(cr, uid, [id], [pool.get(model)._rec_name])
+
+ if val:
+ value.append(val[0][pool.get(model)._rec_name])
return value
-
- elif field['ttype'] == 'one2many':
- if values:
- value=[]
- for id in values:
- val=pool.get(model).read(cr, uid, [id], [pool.get(model)._rec_name])
-
- if len(val):
- value.append(val[0][pool.get(model)._rec_name])
- return value
return values
def create_log_line(self, cr, uid, id, object, lines=[]):
pool = pooler.get_pool(cr.dbname)
- obj=pool.get(object.model)
- obj_ids= pool.get('ir.model').search(cr, uid, [('model', '=', object.model)])
- model_object=pool.get('ir.model').browse(cr, uid, obj_ids)[0]
+ obj = pool.get(object.model)
+ #start Loop
for line in lines:
if obj._inherits:
- inherits_ids= pool.get('ir.model').search(cr, uid, [('model', '=', obj._inherits.keys()[0])])
- f_id= pool.get('ir.model.fields').search(cr, uid, [('name', '=', line['name']), ('model_id', 'in', (object.id, inherits_ids[0]))])
+ inherits_ids = pool.get('ir.model').search(cr, uid, [('model', '=', obj._inherits.keys()[0])])
+ f_id = pool.get('ir.model.fields').search(cr, uid, [('name', '=', line['name']), ('model_id', 'in', (object.id, inherits_ids[0]))])
else:
- f_id= pool.get('ir.model.fields').search(cr, uid, [('name', '=', line['name']), ('model_id', '=', object.id)])
- if len(f_id):
- fields=pool.get('ir.model.fields').read(cr, uid, f_id)
- old_value='old_value' in line and line['old_value'] or ''
- new_value='new_value' in line and line['new_value'] or ''
- old_value_text='old_value_text' in line and line['old_value_text'] or ''
- new_value_text='new_value_text' in line and line['new_value_text'] or ''
+ f_id = pool.get('ir.model.fields').search(cr, uid, [('name', '=', line['name']), ('model_id', '=', object.id)])
+ if f_id:
+ fields = pool.get('ir.model.fields').read(cr, uid, f_id)
+ old_value = 'old_value' in line and line['old_value'] or ''
+ new_value = 'new_value' in line and line['new_value'] or ''
+ old_value_text = 'old_value_text' in line and line['old_value_text'] or ''
+ new_value_text = 'new_value_text' in line and line['new_value_text'] or ''
if old_value_text == new_value_text:
continue
- if fields[0]['ttype']== 'many2one':
- if type(old_value)==tuple:
- old_value=old_value[0]
- if type(new_value)==tuple:
- new_value=new_value[0]
- log_line_id = pool.get('audittrail.log.line').create(cr, uid, {"log_id": id, "field_id": f_id[0] , "old_value":old_value , "new_value":new_value, "old_value_text":old_value_text , "new_value_text":new_value_text, "field_description":fields[0]['field_description']})
+ if fields[0]['ttype'] == 'many2one':
+ if type(old_value) == tuple:
+ old_value = old_value[0]
+ if type(new_value) == tuple:
+ new_value = new_value[0]
+ vals = {
+ "log_id": id,
+ "field_id": f_id[0],
+ "old_value": old_value,
+ "new_value": new_value,
+ "old_value_text": old_value_text,
+ "new_value_text": new_value_text,
+ "field_description": fields[0]['field_description']
+ }
+ line_id = pool.get('audittrail.log.line').create(cr, uid, vals)
cr.commit()
+ #End Loop
return True
def log_fct(self, db, uid, object, method, fct_src, *args):
- logged_uids = []
- pool = pooler.get_pool(db)
- cr = pooler.get_db(db).cursor()
- obj=pool.get(object)
- obj_ids= pool.get('ir.model').search(cr, uid, [('model', '=', object)])
- model_object=pool.get('ir.model').browse(cr, uid, obj_ids)[0]
- if method in ('create'):
- res_id = fct_src(db, uid, object, method, *args)
+ logged_uids = []
+ pool = pooler.get_pool(db)
+ cr = pooler.get_db(db).cursor()
+ obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)])
+ model_object = pool.get('ir.model').browse(cr, uid, obj_ids)[0]
+ if method in ('create'):
+ res_id = fct_src(db, uid, object, method, *args)
+ cr.commit()
+ new_value = pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0]
+ if 'id' in new_value:
+ del new_value['id']
+ if not logged_uids or uid in logged_uids:
+ resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
+ resource_name = resource_name and resource_name[0][1] or ''
+ vals = {
+ "method": method,
+ "object_id": model_object.id,
+ "user_id": uid, "res_id": res_id,
+ "name": resource_name
+ }
+ id = pool.get('audittrail.log').create(cr, uid, vals)
+ lines = []
+ for field in new_value:
+ if new_value[field]:
+ line = {
+ 'name': field,
+ 'new_value': new_value[field],
+ 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object)
+ }
+ lines.append(line)
+ self.create_log_line(cr, uid, id, model_object, lines)
+ cr.commit()
+ cr.close()
+ return res_id
+
+ if method in ('write'):
+ res_ids = args[0]
+ for res_id in res_ids:
+ old_values = pool.get(model_object.model).read(cr, uid, res_id, args[1].keys())
+ old_values_text = {}
+ for field in args[1].keys():
+ old_values_text[field] = self.get_value_text(cr, uid, field, old_values[field], model_object)
+ res = fct_src(db, uid, object, method, *args)
cr.commit()
- new_value=pool.get(model_object.model).read(cr, uid, [res_id], args[0].keys())[0]
- if 'id' in new_value:
- del new_value['id']
- if not len(logged_uids) or uid in logged_uids:
- resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
- resource_name = resource_name and resource_name[0][1] or ''
- id=pool.get('audittrail.log').create(cr, uid, {"method": method , "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
- lines=[]
- for field in new_value:
- if new_value[field]:
- line={
- 'name':field,
- 'new_value':new_value[field],
- 'new_value_text': self.get_value_text(cr, uid, field, new_value[field], model_object)
- }
- lines.append(line)
- self.create_log_line(cr, uid, id, model_object, lines)
- cr.commit()
- cr.close()
- return res_id
-
- if method in ('write'):
- res_ids=args[0]
- for res_id in res_ids:
- old_values=pool.get(model_object.model).read(cr, uid, res_id, args[1].keys())
- old_values_text={}
- for field in args[1].keys():
- old_values_text[field] = self.get_value_text(cr, uid, field, old_values[field], model_object)
- res =fct_src(db, uid, object, method, *args)
- cr.commit()
- if res:
- new_values=pool.get(model_object.model).read(cr, uid, res_ids, args[1].keys())[0]
- if not len(logged_uids) or uid in logged_uids:
- resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
- resource_name = resource_name and resource_name[0][1] or ''
- id=pool.get('audittrail.log').create(cr, uid, {"method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
- lines=[]
- for field in args[1].keys():
- if args[1].keys():
- line={
- 'name':field,
- 'new_value':field in new_values and new_values[field] or '',
- 'old_value':field in old_values and old_values[field] or '',
- 'new_value_text': self.get_value_text(cr, uid, field, new_values[field], model_object),
- 'old_value_text':old_values_text[field]
- }
- lines.append(line)
- cr.commit()
- self.create_log_line(cr, uid, id, model_object, lines)
- cr.close()
- return res
-
- if method in ('read'):
- res_ids=args[0]
- old_values={}
- res =fct_src(db, uid, object, method, *args)
- if type(res)==list:
-
- for v in res:
- old_values[v['id']]=v
- else:
- old_values[res['id']]=res
- for res_id in old_values:
- if not len(logged_uids) or uid in logged_uids:
+ if res:
+ new_values = pool.get(model_object.model).read(cr, uid, res_ids, args[1].keys())[0]
+ if not logged_uids or uid in logged_uids:
resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
resource_name = resource_name and resource_name[0][1] or ''
- id=pool.get('audittrail.log').create(cr, uid, {"method": method , "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
- lines=[]
- for field in old_values[res_id]:
- if old_values[res_id][field]:
- line={
- 'name':field,
- 'old_value':old_values[res_id][field],
- 'old_value_text': self.get_value_text(cr, uid, field, old_values[res_id][field], model_object)
- }
- lines.append(line)
- cr.commit()
- self.create_log_line(cr, uid, id, model_object, lines)
- cr.close()
- return res
-
- if method in ('unlink'):
- res_ids=args[0]
- old_values={}
- for res_id in res_ids:
- old_values[res_id]=pool.get(model_object.model).read(cr, uid, res_id, [])
-
- for res_id in res_ids:
- if not len(logged_uids) or uid in logged_uids:
- resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
- resource_name = resource_name and resource_name[0][1] or ''
- id=pool.get('audittrail.log').create(cr, uid, {"method": method , "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
- lines=[]
- for field in old_values[res_id]:
- if old_values[res_id][field]:
- line={
- 'name':field,
- 'old_value':old_values[res_id][field],
- 'old_value_text': self.get_value_text(cr, uid, field, old_values[res_id][field], model_object)
+ id = pool.get('audittrail.log').create(cr, uid, {"method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
+ lines = []
+ for field in args[1].keys():
+ if args[1].keys():
+ line = {
+ 'name': field,
+ 'new_value': field in new_values and new_values[field] or '',
+ 'old_value': field in old_values and old_values[field] or '',
+ 'new_value_text': self.get_value_text(cr, uid, field, new_values[field], model_object),
+ 'old_value_text': old_values_text[field]
}
lines.append(line)
cr.commit()
self.create_log_line(cr, uid, id, model_object, lines)
- res =fct_src(db, uid, object, method, *args)
cr.close()
return res
+
+ if method in ('read'):
+ res_ids = args[0]
+ old_values = {}
+ res = fct_src(db, uid, object, method, *args)
+ if type(res) == list:
+
+ for v in res:
+ old_values[v['id']] = v
+ else:
+ old_values[res['id']] = res
+ for res_id in old_values:
+ if not logged_uids or uid in logged_uids:
+ resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
+ resource_name = resource_name and resource_name[0][1] or ''
+ id = pool.get('audittrail.log').create(cr, uid, {"method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
+ lines = []
+ for field in old_values[res_id]:
+ if old_values[res_id][field]:
+ line = {
+ 'name': field,
+ 'old_value': old_values[res_id][field],
+ 'old_value_text': self.get_value_text(cr, uid, field, old_values[res_id][field], model_object)
+ }
+ lines.append(line)
+ cr.commit()
+ self.create_log_line(cr, uid, id, model_object, lines)
cr.close()
+ return res
+
+ if method in ('unlink'):
+ res_ids = args[0]
+ old_values = {}
+ for res_id in res_ids:
+ old_values[res_id] = pool.get(model_object.model).read(cr, uid, res_id, [])
+
+ for res_id in res_ids:
+ if not logged_uids or uid in logged_uids:
+ resource_name = pool.get(model_object.model).name_get(cr, uid, [res_id])
+ resource_name = resource_name and resource_name[0][1] or ''
+ id = pool.get('audittrail.log').create(cr, uid, {"method": method, "object_id": model_object.id, "user_id": uid, "res_id": res_id, "name": resource_name})
+ lines = []
+ for field in old_values[res_id]:
+ if old_values[res_id][field]:
+ line = {
+ 'name': field,
+ 'old_value': old_values[res_id][field],
+ 'old_value_text': self.get_value_text(cr, uid, field, old_values[res_id][field], model_object)
+ }
+ lines.append(line)
+ cr.commit()
+ self.create_log_line(cr, uid, id, model_object, lines)
+ res = fct_src(db, uid, object, method, *args)
+ cr.close()
+ return res
+ cr.close()
def execute(self, db, uid, object, method, *args, **kw):
pool = pooler.get_pool(db)
cr = pooler.get_db(db).cursor()
cr.autocommit(True)
- obj=pool.get(object)
logged_uids = []
fct_src = super(audittrail_objects_proxy, self).execute
def my_fct(db, uid, object, method, *args):
field = method
rule = False
- obj_ids= pool.get('ir.model').search(cr, uid, [('model', '=', object)])
+ obj_ids = pool.get('ir.model').search(cr, uid, [('model', '=', object)])
for obj_name in pool.obj_list():
if obj_name == 'audittrail.rule':
rule = True
if not rule:
return fct_src(db, uid, object, method, *args)
- if not len(obj_ids):
+ if not obj_ids:
return fct_src(db, uid, object, method, *args)
- rule_ids=pool.get('audittrail.rule').search(cr, uid, [('object_id', '=', obj_ids[0]), ('state', '=', 'subscribed')])
- if not len(rule_ids):
+ rule_ids = pool.get('audittrail.rule').search(cr, uid, [('object_id', '=', obj_ids[0]), ('state', '=', 'subscribed')])
+ if not rule_ids:
return fct_src(db, uid, object, method, *args)
for thisrule in pool.get('audittrail.rule').browse(cr, uid, rule_ids):
for user in thisrule.user_id:
logged_uids.append(user.id)
- if not len(logged_uids) or uid in logged_uids:
+ if not logged_uids or uid in logged_uids:
if field in ('read', 'write', 'create', 'unlink'):
- if getattr(thisrule, 'log_'+field):
+ if getattr(thisrule, 'log_' + field):
return self.log_fct(db, uid, object, method, fct_src, *args)
return fct_src(db, uid, object, method, *args)
res = my_fct(db, uid, object, method, *args)
diff --git a/addons/audittrail/audittrail_view.xml b/addons/audittrail/audittrail_view.xml
index 536ca78741e..dec025b7e98 100644
--- a/addons/audittrail/audittrail_view.xml
+++ b/addons/audittrail/audittrail_view.xml
@@ -1,6 +1,9 @@
+
+
+
audittrail.rule.form
audittrail.rule
@@ -17,12 +20,15 @@
-
-
+
+
+
audittrail.rule.tree
audittrail.rule
@@ -40,6 +46,9 @@
+
+
+
Rules
audittrail.rule
@@ -48,8 +57,11 @@
tree,form
-
-
+
+
+
@@ -60,6 +72,8 @@
[('state','=','subscribed')]
+
+
audittrail.log.form
@@ -73,23 +87,34 @@
-
+
@@ -117,15 +142,19 @@
+
+
Logs
audittrail.log
form
-
+
-
+
-
+
diff --git a/addons/audittrail/security/ir.model.access.csv b/addons/audittrail/security/ir.model.access.csv
index ac367182f26..9aba9ddf598 100644
--- a/addons/audittrail/security/ir.model.access.csv
+++ b/addons/audittrail/security/ir.model.access.csv
@@ -5,3 +5,4 @@
"access_audittrail_rule_all_users","audittrail rule all","model_audittrail_rule","base.group_user",1,0,0,0
"access_audittrail_log_all_users","audittrail log all","model_audittrail_log","base.group_user",1,0,1,0
"access_audittrail_log_line_all_users","audittrail log line all","model_audittrail_log_line","base.group_user",1,0,1,0
+"access_audittrail_view_log","audittrail.view.log","model_audittrail_view_log","base.group_user",1,1,1,1
diff --git a/addons/audittrail/wizard/audittrail_view_log.py b/addons/audittrail/wizard/audittrail_view_log.py
index 2e170f27200..aa26c8cfd4c 100644
--- a/addons/audittrail/wizard/audittrail_view_log.py
+++ b/addons/audittrail/wizard/audittrail_view_log.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
-#
+#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL ().
#
@@ -15,31 +15,26 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
+# along with this program. If not, see .
#
##############################################################################
from osv import fields, osv
-from tools.translate import _
-import netsvc
-import pooler
import time
-import tools
-import wizard
class audittrail_view_log(osv.osv_memory):
_name = "audittrail.view.log"
_description = "View Log"
- _columns ={
- 'from':fields.datetime('Log From'),
- 'to':fields.datetime('Log To', required = True)
- }
- _defaults = {
- 'to': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
+ _columns = {
+ 'from':fields.datetime('Log From'),
+ 'to':fields.datetime('Log To', required = True)
}
+ _defaults = {
+ 'to': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
+ }
- def log_open_window(self, cr, uid, ids, context):
+ def log_open_window(self, cr, uid, ids, context=None):
"""
Open Log form from given date range..
@param cr: the current row, from the database cursor,
@@ -47,26 +42,28 @@ class audittrail_view_log(osv.osv_memory):
@param ids: List of audittrail view log’s IDs.
@return: Dictionary of audittrail log form on given date range.
"""
+ if not context:
+ context = {}
+
mod_obj = self.pool.get('ir.model.data')
act_obj = self.pool.get('ir.actions.act_window')
result = mod_obj._get_id(cr, uid, 'audittrail', 'action_audittrail_log_tree')
id = mod_obj.read(cr, uid, [result], ['res_id'])[0]['res_id']
result = act_obj.read(cr, uid, [id])[0]
- log_obj= self.pool.get(result['res_model'])
- log_id = log_obj.search(cr, uid, [])
- log_model=log_obj.read(cr, uid,log_id,['object_id'])
- for datas in self.read(cr, uid, ids):
- if not datas['from']:
- if datas['to'] <> time.strftime("%Y-%m-%d %H:%M:%S"):
- result['domain'] = str([('timestamp', '<',datas['to'])])
+ #log_obj = self.pool.get(result['res_model'])
+ #log_id = log_obj.search(cr, uid, [])
+ #log_model = log_obj.read(cr, uid, log_id, ['object_id'])
+
+ #start Loop
+ for datas in self.read(cr, uid, ids):
+ if not datas.get('from', None):
+ if datas.get('to') <> time.strftime("%Y-%m-%d %H:%M:%S"):
+ result['domain'] = str([('timestamp', '<', datas.get('to'))])
else:
- pass
+ pass
else:
- result['domain'] = str([('timestamp', '>',datas['from']),('timestamp', '<',datas['to'])])
+ result['domain'] = str([('timestamp', '>', datas.get('from', None)), ('timestamp', '<', datas.get('to'))])
+ #End Loop
return result
audittrail_view_log()
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/audittrail/wizard/audittrail_view_log_view.xml b/addons/audittrail/wizard/audittrail_view_log_view.xml
index 87648c7e136..e32bc65de40 100644
--- a/addons/audittrail/wizard/audittrail_view_log_view.xml
+++ b/addons/audittrail/wizard/audittrail_view_log_view.xml
@@ -1,6 +1,9 @@
+
+
+
audittrail.view.log.form
audittrail.view.log
@@ -14,12 +17,16 @@
-
-
-
+
+
+
+
+
View log
diff --git a/addons/base_calendar/base_calendar.py b/addons/base_calendar/base_calendar.py
index 9835217c0e3..479c65780ac 100644
--- a/addons/base_calendar/base_calendar.py
+++ b/addons/base_calendar/base_calendar.py
@@ -51,6 +51,7 @@ def get_recurrent_dates(rrulestring, exdate, startdate=None):
return re_dates
def base_calendar_id2real_id(base_calendar_id=None, with_date=False):
+
if base_calendar_id and isinstance(base_calendar_id, (str, unicode)):
res = base_calendar_id.split('-')
if len(res) >= 2:
@@ -220,10 +221,12 @@ class invite_attendee_wizard(osv.osv_memory):
res_obj = obj.browse(cr, uid, context['active_id'])
type = datas.get('type')
att_obj = self.pool.get('calendar.attendee')
- vals = {}
+ vals = []
mail_to = []
+ attendees = []
+
if not model == 'calendar.attendee':
- vals = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))}
+ ref = {'ref': '%s,%s' % (model, base_calendar_id2real_id(context['active_id']))}
if type == 'internal':
user_obj = self.pool.get('res.users')
@@ -231,20 +234,28 @@ class invite_attendee_wizard(osv.osv_memory):
raise osv.except_osv(_('Error!'), ("Please select any User"))
for user_id in datas.get('user_ids'):
user = user_obj.browse(cr, uid, user_id)
- vals.update({'user_id': user_id,
- 'email': user.address_id.email})
+ res = {
+ 'user_id': user_id,
+ 'email': user.address_id.email
+ }
+ res.update(ref)
+ vals.append(res)
if user.address_id.email:
mail_to.append(user.address_id.email)
elif type == 'external' and datas.get('email'):
- vals.update({'email': datas['email']})
+ vals.append({'email': datas['email']})
mail_to.append(datas['email'])
+
elif type == 'partner':
add_obj = self.pool.get('res.partner.address')
for contact in add_obj.browse(cr, uid, datas['contact_ids']):
- vals.update({
- 'partner_address_id': contact.id,
- 'email': contact.email})
+ res = {
+ 'partner_address_id': contact.id,
+ 'email': contact.email
+ }
+ res.update(ref)
+ vals.append(res)
if contact.email:
mail_to.append(contact.email)
@@ -254,17 +265,23 @@ class invite_attendee_wizard(osv.osv_memory):
'parent_ids' : [(4, att.id)],
'ref': att.ref
})
+
+ for att_val in vals:
+ attendees.append(int(att_obj.create(cr, uid, att_val, context=context)))
+
+ if model_field:
+ for attendee in attendees:
+ obj.write(cr, uid, res_obj.id, {model_field: [(4, attendee)]})
+
if datas.get('send_mail'):
if not mail_to:
name = map(lambda x: x[1], filter(lambda x: type==x[0], \
self._columns['type'].selection))
raise osv.except_osv(_('Error!'), ("%s must have an email \
Address to send mail") % (name[0]))
- att_obj._send_mail(cr, uid, [att_id], mail_to, \
+ att_obj._send_mail(cr, uid, attendees, mail_to, \
email_from=tools.config.get('email_from', False))
- att_id = att_obj.create(cr, uid, vals)
- if model_field:
- obj.write(cr, uid, res_obj.id, {model_field: [(4, att_id)]})
+
return {}
@@ -719,8 +736,11 @@ class calendar_event(osv.osv):
def onchange_dates(self, cr, uid, ids, start_date, duration=False, end_date=False, context={}):
if not start_date:
return {}
- start = datetime.strptime(start_date, "%Y-%m-%d %H:%M:%S")
value = {}
+ if not end_date and not duration:
+ duration = 8.00
+ value['duration'] = 8.00
+ start = datetime.strptime(start_date, "%Y-%m-%d %H:%M:%S")
if end_date and not duration:
end = datetime.strptime(end_date, "%Y-%m-%d %H:%M:%S")
diff = end - start
@@ -832,19 +852,22 @@ rule or repeating pattern for anexception to a recurrence set"),
new_id = self.copy(cr, uid, event_id, default=defaults, context=context)
return new_id
- def modify_all(self, cr, uid, event_id, defaults, context=None, *args):
- event_id = base_calendar_id2real_id(event_id)
- defaults.pop('id')
- defaults.update({'table': self._table})
-
- qry = "UPDATE %(table)s set name='%(name)s', \
- date='%(date)s', date_deadline='%(date_deadline)s'"
- if defaults.get('alarm_id'):
- qry += ", alarm_id=%(alarm_id)s"
- if defaults.get('location'):
- qry += ", location='%(location)s'"
- qry += "WHERE id=%s" % (event_id)
- cr.execute(qry % (defaults))
+ def modify_all(self, cr, uid, event_ids, defaults, context=None, *args):
+ #start Loop
+ for event_id in event_ids:
+ event_id = base_calendar_id2real_id(event_id)
+ defaults.pop('id')
+ defaults.update({'table': self._table})
+
+ qry = "UPDATE %(table)s set name='%(name)s', \
+ date='%(date)s', date_deadline='%(date_deadline)s'"
+ if defaults.get('alarm_id'):
+ qry += ", alarm_id=%(alarm_id)s"
+ if defaults.get('location'):
+ qry += ", location='%(location)s'"
+ qry += "WHERE id=%s" % (event_id)
+ cr.execute(qry % (defaults))
+ #End Loop
return True
def get_recurrent_ids(self, cr, uid, select, base_start_date, base_until_date, limit=100):
diff --git a/addons/base_report_creator/base_report_creator.py b/addons/base_report_creator/base_report_creator.py
index b9ddba5385c..95c2e8a76e6 100644
--- a/addons/base_report_creator/base_report_creator.py
+++ b/addons/base_report_creator/base_report_creator.py
@@ -25,29 +25,10 @@ import tools
from osv import fields,osv,orm
from tools.translate import _
-#class ir_model_fields(osv.osv):
-# _inherit = 'ir.model.fields'
-# def _get_models(self, cr, uid, model_name, level=1):
-# if not level:
-# return []
-# result = [model_name]
-# print model_name
-# for field,data in self.pool.get(model_name).fields_get(cr, uid).items():
-# if data.get('relation', False):
-# result += self._get_models(cr, uid, data['relation'], level-1)
-# return result
-# def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None):
-# if context and ('model_id' in context):
-# model_name = self.pool.get("ir.model").browse(cr, uid, context['model_id'], context).model
-# models = self._get_models(cr, uid, model_name, context.get('model_level',2))
-# models = map(lambda x: self.pool.get('ir.model').search(cr, uid, [('model','=',x)])[0], models)
-# args.append(('model_id','in',models))
-# print args
-# return super(ir_model_fields, self).search(cr, uid, args, offset, limit, order, context)
-#ir_model_fields()
-
-
class report_creator(osv.osv):
+ """
+ Report Creator
+ """
_name = "base_report_creator.report"
_description = "Report"
model_set_id = False
@@ -55,8 +36,11 @@ class report_creator(osv.osv):
# Should request only used fields
#
def export_data(self, cr, uid, ids, fields_to_export, context=None):
+ if not context:
+ context = {}
data_l = self.read(cr, uid, ids, ['sql_query'], context)
final_datas =[]
+ #start Loop
for i in data_l:
datas = []
for key,value in i.items():
@@ -67,6 +51,7 @@ class report_creator(osv.osv):
else:
datas.append(str(value))
final_datas += [datas]
+ #End Loop
return {'datas':final_datas}
def fields_get(self, cr, user, fields=None, context=None):
@@ -74,8 +59,10 @@ class report_creator(osv.osv):
return super(report_creator, self).fields_get(cr, user, fields, context)
report = self.browse(cr, user, context['report_id'])
models = {}
+ #Start Loop
for model in report.model_ids:
models[model.model] = self.pool.get(model.model).fields_get(cr, user, context=context)
+ #End Loop
fields = {}
i = 0
for f in report.field_ids:
@@ -173,7 +160,7 @@ class report_creator(osv.osv):
}
return result
- def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'):
+ def read(self, cr, user, ids, fields = None, context = None, load = '_classic_read'):
if (not context) or 'report_id' not in context:
return super(report_creator, self).read(cr, user, ids, fields, context, load)
ctx = context or {}
@@ -198,43 +185,39 @@ class report_creator(osv.osv):
return res
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None, count=False):
+ context_id = context and context.get('report_id', False) or False
+
if (not context) or 'report_id' not in context:
return super(report_creator, self).search(cr, user, args, offset, limit, order, context, count)
- report = self.browse(cr, user, context['report_id'])
- i = 0
- fields = {}
- for f in report.field_ids:
- if f.field_id.model:
- fields['field'+str(i)] = (f.field_id.model, f.field_id.name)
- i+=1
- else:
- fields['column_count'] = (False, 'Count')
- newargs = []
- newargs2 = []
- for a in args:
- if fields[a[0]][0]:
- res = self.pool.get(fields[a[0]][0])._where_calc(cr, user, [[fields[a[0]][1],a[1],a[2]]], active_test=False, context=context)
- newargs+=res[0]
- newargs2+=res[1]
- else:
- newargs += [("count(*) " + a[1] +" " + str(a[2]))]
- ctx = context or {}
- ctx['getid'] = True
- report = self._sql_query_get(cr, user, [context['report_id']], 'sql_query', None, ctx, where_plus=newargs, limit=limit, offset=offset)
- query = report[context['report_id']]
- cr.execute(query, newargs2)
- result = cr.fetchall()
- return map(lambda x: x[0], result)
+ if context_id:
+ report = self.browse(cr, user, context_id)
+ i = 0
+ fields = {}
+ for f in report.field_ids:
+ if f.field_id.model:
+ fields['field'+str(i)] = (f.field_id.model, f.field_id.name)
+ i+=1
+ else:
+ fields['column_count'] = (False, 'Count')
+ newargs = []
+ newargs2 = []
+ for a in args:
+ if fields[a[0]][0]:
+ res = self.pool.get(fields[a[0]][0])._where_calc(cr, user, [[fields[a[0]][1],a[1],a[2]]], active_test = False, context = context)
+ newargs+=res[0]
+ newargs2+=res[1]
+ else:
+ newargs += [("count(*) " + a[1] +" " + str(a[2]))]
+ ctx = context or {}
+ ctx['getid'] = True
+ report = self._sql_query_get(cr, user, [context_id], 'sql_query', None, ctx, where_plus = newargs, limit=limit, offset=offset)
+ query = report[context_id]
+ cr.execute(query, newargs2)
+ result = cr.fetchall()
+ return map(lambda x: x[0], result)
def _path_get(self,cr, uid, models, filter_ids=[]):
-# ret_str = """ sale_order_line
-# left join sale_order on (sale_order_line.order_id=sale_order.id)
-# left join res_partner on (res_partner.id=sale_order.partner_id)"""
-# where_list = []
-# for filter_id in filter_ids:
-# where_list.append(filter_id.expression)
-# if where_list:
-# ret_str+="\nwhere\n\t"+" and\n\t".join(where_list)
+
self.model_set_id = False
model_dict = {}
from_list = []
@@ -366,13 +349,26 @@ class report_creator(osv.osv):
_columns = {
'name': fields.char('Report Name',size=64, required=True),
- 'type': fields.selection([('list','Rows And Columns Report'),], 'Report Type',required=True),#('sum','Summation Report')
+ 'type': fields.selection([('list', 'Rows And Columns Report'), ], 'Report Type', required=True),#('sum','Summation Report')
'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the report without removing it."),
- 'view_type1': fields.selection([('form','Form'),('tree','Tree'),('graph','Graph'),('calendar','Calendar')], 'First View', required=True),
- 'view_type2': fields.selection([('','/'),('form','Form'),('tree','Tree'),('graph','Graph'),('calendar','Calendar')], 'Second View'),
- 'view_type3': fields.selection([('','/'),('form','Form'),('tree','Tree'),('graph','Graph'),('calendar','Calendar')], 'Third View'),
- 'view_graph_type': fields.selection([('pie','Pie Chart'),('bar','Bar Chart')], 'Graph Type', required=True),
- 'view_graph_orientation': fields.selection([('horz','Horizontal'),('vert','Vertical')], 'Graph Orientation', required=True),
+ 'view_type1': fields.selection([('form','Form'),
+ ('tree','Tree'),
+ ('graph','Graph'),
+ ('calendar','Calendar')], 'First View', required=True),
+ 'view_type2': fields.selection([('','/'),
+ ('form','Form'),
+ ('tree','Tree'),
+ ('graph','Graph'),
+ ('calendar','Calendar')], 'Second View'),
+ 'view_type3': fields.selection([('','/'),
+ ('form','Form'),
+ ('tree','Tree'),
+ ('graph','Graph'),
+ ('calendar','Calendar')], 'Third View'),
+ 'view_graph_type': fields.selection([('pie','Pie Chart'),
+ ('bar','Bar Chart')], 'Graph Type', required=True),
+ 'view_graph_orientation': fields.selection([('horz','Horizontal'),
+ ('vert','Vertical')], 'Graph Orientation', required=True),
'model_ids': fields.many2many('ir.model', 'base_report_creator_report_model_rel', 'report_id','model_id', 'Reported Objects'),
'field_ids': fields.one2many('base_report_creator.report.fields', 'report_id', 'Fields to Display'),
'filter_ids': fields.one2many('base_report_creator.report.filter', 'report_id', 'Filters'),
@@ -449,6 +445,9 @@ class report_creator(osv.osv):
report_creator()
class report_creator_field(osv.osv):
+ """
+ Report Creator Field
+ """
_name = "base_report_creator.report.fields"
_description = "Display Fields"
_rec_name = 'field_id'
@@ -457,9 +456,18 @@ class report_creator_field(osv.osv):
'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of fields."),
'field_id': fields.many2one('ir.model.fields', 'Field'),
'report_id': fields.many2one('base_report_creator.report','Report', on_delete='cascade'),
- 'group_method': fields.selection([('group','Grouped'),('sum','Sum'),('min','Minimum'),('count','Count'),('max','Maximum'),('avg','Average')], 'Grouping Method', required=True),
- 'graph_mode': fields.selection([('','/'),('x','X Axis'),('y','Y Axis')], 'Graph Mode'),
- 'calendar_mode': fields.selection([('','/'),('date_start','Starting Date'),('date_end','Ending Date'),('date_delay','Delay'),('date_stop','End Date'),('color','Unique Colors')], 'Calendar Mode'),
+ 'group_method': fields.selection([('group','Grouped'),
+ ('sum','Sum'),
+ ('min','Minimum'),
+ ('count','Count'),
+ ('max','Maximum'),
+ ('avg','Average')], 'Grouping Method', required=True),
+ 'graph_mode': fields.selection([('','/'),
+ ('x','X Axis'),
+ ('y','Y Axis')], 'Graph Mode'),
+ 'calendar_mode': fields.selection([('','/'),
+ ('date_start','Starting Date'),
+ ('date_end','Ending Date'),('date_delay','Delay'),('date_stop','End Date'),('color','Unique Colors')], 'Calendar Mode'),
}
_defaults = {
'group_method': lambda *args: 'group',
@@ -468,17 +476,20 @@ class report_creator_field(osv.osv):
report_creator_field()
class report_creator_filter(osv.osv):
+ """
+ Report Creator Filter
+ """
_name = "base_report_creator.report.filter"
_description = "Report Filters"
_columns = {
'name': fields.char('Filter Name',size=64, required=True),
- 'expression': fields.text('Value', required=True,help='Provide an expression for the field based on which you want to filter the records.\n e.g. res_partner.id=3'),
- 'report_id': fields.many2one('base_report_creator.report','Report', on_delete='cascade'),
- 'condition' : fields.selection([('and','AND'),('or','OR')], 'Condition')
+ 'expression': fields.text('Value', required=True, help='Provide an expression for the field based on which you want to filter the records.\n e.g. res_partner.id=3'),
+ 'report_id': fields.many2one('base_report_creator.report', 'Report', on_delete='cascade'),
+ 'condition' : fields.selection([('and','AND'),
+ ('or','OR')], 'Condition')
}
_defaults = {
'condition': lambda *args: 'and',
}
report_creator_filter()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/base_report_creator/base_report_creator_view.xml b/addons/base_report_creator/base_report_creator_view.xml
index 1d606b93ec4..a69aed42048 100644
--- a/addons/base_report_creator/base_report_creator_view.xml
+++ b/addons/base_report_creator/base_report_creator_view.xml
@@ -27,6 +27,9 @@
+
+
+
base_report_creator.report.form
base_report_creator.report
@@ -41,7 +44,9 @@
-
+
@@ -54,12 +59,13 @@
-
+
-
+
@@ -87,8 +97,10 @@
-
-
+
+
@@ -98,15 +110,20 @@
+
+
+
Custom Report
base_report_creator.report
form
tree,form
+
+
diff --git a/addons/base_report_creator/wizard/report_menu_create.py b/addons/base_report_creator/wizard/report_menu_create.py
index 38821a81797..4bf284e4d38 100644
--- a/addons/base_report_creator/wizard/report_menu_create.py
+++ b/addons/base_report_creator/wizard/report_menu_create.py
@@ -19,14 +19,7 @@
#
##############################################################################
-
from osv import fields, osv
-from tools.translate import _
-import netsvc
-import pooler
-import time
-import tools
-import wizard
class report_menu_create(osv.osv_memory):
"""
@@ -34,40 +27,47 @@ class report_menu_create(osv.osv_memory):
"""
_name = "report.menu.create"
_description = "Menu Create"
- _columns ={
+ _columns = {
'menu_name':fields.char('Menu Name', size=64, required=True),
'menu_parent_id':fields.many2one('ir.ui.menu', 'Parent Menu', required=True),
}
- def report_menu_create(self, cr, uid, ids, context):
+ def report_menu_create(self, cr, uid, ids, context=None):
"""
Create Menu.
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of Report Menu Create's IDs
+ @return : Dictionary {}.
"""
- board = self.pool.get('base_report_creator.report').browse(cr, uid, context['active_id'])
- view = board.view_type1
- if board.view_type2:
- view+=','+board.view_type2
- if board.view_type3:
- view+=','+board.view_type3
- action_id = self.pool.get('ir.actions.act_window').create(cr, uid, {
- 'name': board.name,
- 'view_type':'form',
- 'view_mode':view,
- 'context': "{'report_id':%d}" % (board.id,),
- 'res_model': 'base_report_creator.report'
- })
+ if not context:
+ context={}
+ context_id = context and context.get('active_id', False) or False
+ if context_id:
+ board = self.pool.get('base_report_creator.report').browse(cr, uid, context_id)
+ view = board.view_type1
+ if board.view_type2:
+ view+=','+board.view_type2
+ if board.view_type3:
+ view+=','+board.view_type3
+ action_id = self.pool.get('ir.actions.act_window').create(cr, uid, {
+ 'name': board.name,
+ 'view_type':'form',
+ 'view_mode':view,
+ 'context': "{'report_id':%d}" % (board.id,),
+ 'res_model': 'base_report_creator.report'
+ })
+ obj_menu = self.pool.get('ir.ui.menu')
+ #start Loop
for data in self.read(cr, uid, ids):
- self.pool.get('ir.ui.menu').create(cr, uid, {
- 'name': data['menu_name'],
- 'parent_id': data['menu_parent_id'],
+ obj_menu.create(cr, uid, {
+ 'name': data.get('menu_name'),
+ 'parent_id': data.get('menu_parent_id'),
'icon': 'STOCK_SELECT_COLOR',
'action': 'ir.actions.act_window,'+str(action_id)
- }, context)
+ }, context=context)
return {}
-
+ #End Loop
report_menu_create()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/base_report_creator/wizard/report_menu_create_view.xml b/addons/base_report_creator/wizard/report_menu_create_view.xml
index dd8ecb441c4..a484180ea06 100644
--- a/addons/base_report_creator/wizard/report_menu_create_view.xml
+++ b/addons/base_report_creator/wizard/report_menu_create_view.xml
@@ -1,6 +1,9 @@
+
+
+
diff --git a/addons/board/__init__.py b/addons/board/__init__.py
index 47e5ea7bd80..e169935ef84 100644
--- a/addons/board/__init__.py
+++ b/addons/board/__init__.py
@@ -23,4 +23,3 @@ import board
import wizard
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/board/__terp__.py b/addons/board/__terp__.py
index 8476be95f4e..bafb4be1602 100644
--- a/addons/board/__terp__.py
+++ b/addons/board/__terp__.py
@@ -19,7 +19,6 @@
#
##############################################################################
-
{
'name': 'Dashboard main module',
'version': '1.0',
diff --git a/addons/board/board.py b/addons/board/board.py
index 29e8a3310b4..4fcdad8c517 100644
--- a/addons/board/board.py
+++ b/addons/board/board.py
@@ -19,28 +19,42 @@
#
##############################################################################
+from osv import fields, osv
import time
-from osv import fields,osv
class board_board(osv.osv):
+ """
+ Board
+ """
_name = 'board.board'
-
- def create_view(self, cr, uid, ids, context):
-
- board = self.pool.get('board.board').browse(cr, uid, ids, context)
+ _description = "Board"
+
+ def create_view(self, cr, uid, ids, context=None):
+ """
+ Create view
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of Board's IDs
+ @return: arch of xml view.
+ """
+ if not context:
+ context = {}
+ board = self.pool.get('board.board').browse(cr, uid, ids, context=context)
left = []
right = []
+ #start Loop
for line in board.line_ids:
linestr = ''
- if line.position=='left':
+ if line.position == 'left':
left.append(linestr)
else:
right.append(linestr)
+ #End Loop
arch = """
""" % ('\n'.join(left), '\n'.join(right))
-
+
return arch
- def write(self, cr, uid, ids, vals, context={}):
+ def write(self, cr, uid, ids, vals, context = {}):
+
+ """
+ Writes values in one or several fields.
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of Board's IDs
+ @param vals: dictionary with values to update.
+ dictionary must be with the form: {‘name_of_the_field’: value, ...}.
+ @return: True
+ """
result = super(board_board, self).write(cr, uid, ids, vals, context)
cr.commit()
board = self.pool.get('board.board').browse(cr, uid, ids[0])
-
view = self.create_view(cr, uid, ids[0], context)
id = board.view_id.id
- cr.execute("update ir_ui_view set arch=%s where id=%s" , (view, id))
+ cr.execute("update ir_ui_view set arch=%s where id=%s", (view, id))
cr.commit()
-
return result
def create(self, cr, user, vals, context=None):
+ """
+ create new record.
+ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param vals: dictionary of values for every field.
+ dictionary must use this form: {‘name_of_the_field’: value, ...}
+ @return: id of new created record of board.board.
+ """
+
+ if not context:
+ context = {}
+
if not 'name' in vals:
return False
id = super(board_board, self).create(cr, user, vals, context)
view_id = self.pool.get('ir.ui.view').create(cr, user, {
'name': vals['name'],
- 'model':'board.board',
- 'priority':16,
+ 'model': 'board.board',
+ 'priority': 16,
'type': 'form',
'arch': self.create_view(cr, user, id, context),
})
super(board_board, self).write(cr, user, [id], {'view_id': view_id}, context)
-
+
return id
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
+ """
+ Overrides orm field_view_get.
+ @return: Dictionary of Fields, arch and toolbar.
+ """
+ if not context:
+ context = {}
+
res = {}
res = super(board_board, self).fields_view_get(cr, user, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
- vids = self.pool.get('ir.ui.view.custom').search(cr, user, [('user_id','=',user), ('ref_id','=',view_id)])
+ vids = self.pool.get('ir.ui.view.custom').search(cr, user, [('user_id', '=', user), ('ref_id' ,'=', view_id)])
if vids:
view_id = vids[0]
arch = self.pool.get('ir.ui.view.custom').browse(cr, user, view_id)
res['arch'] = arch.arch
- res['toolbar'] = {'print':[],'action':[],'relate':[]}
+ res['toolbar'] = {'print': [], 'action': [], 'relate': []}
return res
_columns = {
- 'name': fields.char('Dashboard', size=64, required=True),
- 'view_id': fields.many2one('ir.ui.view', 'Board View'),
+ 'name': fields.char('Dashboard', size=64, required=True),
+ 'view_id': fields.many2one('ir.ui.view', 'Board View'),
'line_ids': fields.one2many('board.board.line', 'board_id', 'Action Views')
}
# the following lines added to let the button on dashboard work.
_defaults = {
- 'name': lambda *args: 'Dashboard'
+ 'name': lambda *args: 'Dashboard'
}
board_board()
+
class board_line(osv.osv):
+ """
+ Board Line
+ """
_name = 'board.board.line'
+ _description = "Board Line"
_order = 'position,sequence'
_columns = {
'name': fields.char('Title', size=64, required=True),
@@ -120,29 +166,43 @@ class board_line(osv.osv):
'width': fields.integer('Width'),
'board_id': fields.many2one('board.board', 'Dashboard', required=True, ondelete='cascade'),
'action_id': fields.many2one('ir.actions.act_window', 'Action', required=True),
- 'position': fields.selection([('left','Left'),('right','Right')], 'Position', required=True)
+ 'position': fields.selection([('left','Left'),
+ ('right','Right')], 'Position', required=True)
}
_defaults = {
'position': lambda *args: 'left'
}
board_line()
+
class board_note_type(osv.osv):
+ """
+ Board note Type
+ """
_name = 'board.note.type'
+ _description = "NOte Type"
_columns = {
'name': fields.char('Note Type', size=64, required=True),
}
board_note_type()
def _type_get(self, cr, uid, context={}):
+ """
+ Get by default Note type.
+ """
obj = self.pool.get('board.note.type')
ids = obj.search(cr, uid, [])
res = obj.read(cr, uid, ids, ['name'], context)
res = [(r['name'], r['name']) for r in res]
return res
+
class board_note(osv.osv):
+ """
+ Board Note
+ """
_name = 'board.note'
+ _description = "Note"
_columns = {
'name': fields.char('Subject', size=128, required=True),
'note': fields.text('Note'),
@@ -151,10 +211,9 @@ class board_note(osv.osv):
'type': fields.selection(_type_get, 'Note type', size=64),
}
_defaults = {
- 'user_id': lambda object,cr,uid,context: uid,
- 'date': lambda object,cr,uid,context: time.strftime('%Y-%m-%d'),
+ 'user_id': lambda object, cr, uid, context: uid,
+ 'date': lambda object, cr, uid, context: time.strftime('%Y-%m-%d'),
}
board_note()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/board/board_view.xml b/addons/board/board_view.xml
index 981a5521818..6bfafa9cee7 100644
--- a/addons/board/board_view.xml
+++ b/addons/board/board_view.xml
@@ -1,8 +1,10 @@
-
-
+
+
+
board.note.tree
board.note
@@ -13,6 +15,9 @@
+
+
+
board.note.form
board.note
@@ -27,6 +32,9 @@
+
+
+
Publish a note
board.note
@@ -46,6 +54,9 @@
+
+
+
board.board.form
board.board
@@ -54,7 +65,10 @@
+
+
+
Dashboard Definition
board.board
form
tree,form
+
-
-
+
+
diff --git a/addons/board/security/ir.model.access.csv b/addons/board/security/ir.model.access.csv
index 9505a83ab36..a9c42feda41 100644
--- a/addons/board/security/ir.model.access.csv
+++ b/addons/board/security/ir.model.access.csv
@@ -1,5 +1,6 @@
-id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
-access_board_board,board.board,model_board_board,base.group_user,1,1,1,1
-access_board_board_line,board.board.line,model_board_board_line,base.group_user,1,1,1,1
-access_board_note_type,board.note.type,model_board_note_type,base.group_user,1,1,1,1
-access_board_note,board.note,model_board_note,base.group_user,1,1,1,1
+"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
+"access_board_board","board.board","model_board_board","base.group_user",1,1,1,1
+"access_board_board_line","board.board.line","model_board_board_line","base.group_user",1,1,1,1
+"access_board_note_type","board.note.type","model_board_note_type","base.group_user",1,1,1,1
+"access_board_note","board.note","model_board_note","base.group_user",1,1,1,1
+"access_board_menu_create","board.menu.create","model_board_menu_create","base.group_user",1,1,1,1
diff --git a/addons/board/wizard/board_menu_create.py b/addons/board/wizard/board_menu_create.py
index 5c5dc800ba1..107c00ba142 100644
--- a/addons/board/wizard/board_menu_create.py
+++ b/addons/board/wizard/board_menu_create.py
@@ -27,12 +27,19 @@ class board_menu_create(osv.osv_memory):
Create Menu
"""
def check_views(self, cr, uid, context):
- board = self.pool.get('board.board').browse(cr, uid, context['active_id'])
- if not board.line_ids:
- raise osv.except_osv(_('User Error!'), _('Please Insert Dashboard View(s) !'))
- return False
+ """
+ check dashboard view on menu name field.
+ @return: False
+ """
+ data = context and context.get('active_id', False) or False
+ if data:
+ board = self.pool.get('board.board').browse(cr, uid, data)
+ if not board.line_ids:
+ raise osv.except_osv(_('User Error!'),
+ _('Please Insert Dashboard View(s) !'))
+ return False
- def board_menu_create(self, cr, uid, ids, context):
+ def board_menu_create(self, cr, uid, ids, context=None):
"""
Create Menu.
@param cr: the current row, from the database cursor,
@@ -40,32 +47,39 @@ class board_menu_create(osv.osv_memory):
@param ids: List of Board Menu Create's IDs
@return : Dictionary {}.
"""
- board = self.pool.get('board.board').browse(cr, uid, context['active_id'])
- action_id = self.pool.get('ir.actions.act_window').create(cr, uid, {
- 'name': board.name,
- 'view_type':'form',
- 'view_mode':'form',
- 'res_model': 'board.board',
- 'view_id': board.view_id.id,
- })
+ if not context:
+ context = {}
+
+ context_id = context and context.get('active_id', False) or False
+ if context_id:
+ board = self.pool.get('board.board').browse(cr, uid, context_id)
+ action_id = self.pool.get('ir.actions.act_window').create(cr, uid, {
+ 'name': board.name,
+ 'view_type':'form',
+ 'view_mode':'form',
+ 'res_model': 'board.board',
+ 'view_id': board.view_id.id,
+ })
+ obj_menu = self.pool.get('ir.ui.menu')
+ #start Loop
for data in self.read(cr, uid, ids):
- self.pool.get('ir.ui.menu').create(cr, uid, {
- 'name': data['menu_name'],
- 'parent_id': data['menu_parent_id'],
+ obj_menu.create(cr, uid, {
+ 'name': data.get('menu_name'),
+ 'parent_id': data.get('menu_parent_id'),
'icon': 'STOCK_SELECT_COLOR',
- 'action': 'ir.actions.act_window,'+str(action_id)
- }, context)
-
+ 'action': 'ir.actions.act_window,' + str(action_id)
+ }, context=context)
+ #End Loop
return {}
_name = "board.menu.create"
_description = "Menu Create"
_columns = {
- 'menu_name':fields.char('Menu Name', size=64, required=True),
- 'menu_parent_id':fields.many2one('ir.ui.menu', 'Parent Menu', required=True),
+ 'menu_name': fields.char('Menu Name', size=64, required=True),
+ 'menu_parent_id': fields.many2one('ir.ui.menu', 'Parent Menu', required=True),
}
_defaults = {
- 'menu_name':check_views,
+ 'menu_name': check_views,
}
board_menu_create()
diff --git a/addons/board/wizard/board_menu_create_view.xml b/addons/board/wizard/board_menu_create_view.xml
index e33e6d1cd52..a4398d1a07d 100644
--- a/addons/board/wizard/board_menu_create_view.xml
+++ b/addons/board/wizard/board_menu_create_view.xml
@@ -1,6 +1,9 @@
+
+
+
+
+
@@ -418,12 +398,13 @@ Wizard view for the Auto Configuring the data
@@ -466,21 +447,6 @@ Wizard view for the Auto Configuring the data
-
-
-
@@ -489,7 +455,8 @@ Wizard view for the Auto Configuring the data
-
+
@@ -569,11 +536,7 @@ Wizard view for the Auto Configuring the data
action="action_olap_saved_query_form"
id="menu_action_olap_saved_query_form"/>
-
+
olap.query.logs
@@ -608,22 +571,14 @@ All Logs
olap.query.logs
form
+
-
-
-
-
-
-
-
+
olap.query.logs
@@ -649,6 +604,9 @@ All Logs / My logs
+
+
+
olap.query.logs.form
olap.query.logs
@@ -656,8 +614,6 @@ All Logs / My logs
-
+
My Logs
olap.query.logs
@@ -675,27 +631,12 @@ All Logs / My logs
tree,form,mdx
[('user_id','=',uid)]
+
-
-
-
-
-
-
-
-
diff --git a/addons/olap/data/olap_view.xml b/addons/olap/data/olap_view.xml
index 35aac4a20c0..cfd326cbce3 100755
--- a/addons/olap/data/olap_view.xml
+++ b/addons/olap/data/olap_view.xml
@@ -2,22 +2,19 @@
-
-
-
-
-
-
+
+
+
-
+
-
+
+
-
+
+
diff --git a/addons/olap/olap.py b/addons/olap/olap.py
index 349d204086f..08effb18ffd 100644
--- a/addons/olap/olap.py
+++ b/addons/olap/olap.py
@@ -18,7 +18,6 @@
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -36,14 +35,15 @@ from osv import fields,osv
import netsvc
import cube
from cube import levels
+import MySQLdb
+import cx_Oracle
class olap_fact_database(osv.osv):
+ """ Olap Fact Database """
_name = "olap.fact.database"
_description = "Olap Fact Database"
-
-
def _connection_get(self,cr,uid,ids,field_name,arg,context = {}):
"""
Return a connection string url needed by SQL Alchemy. Exemple:
@@ -109,7 +109,9 @@ class olap_fact_database(osv.osv):
}
olap_fact_database()
+
class olap_schema(osv.osv ):
+ """ Olap Schema """
_name = "olap.schema"
_description = "Olap Schema"
@@ -119,12 +121,12 @@ class olap_schema(osv.osv ):
"""
res = {}
+ app_objs = self.pool.get('olap.application')
+ app_ids = app_objs.search(cr,uid,[] )
+ app_res = app_objs.browse(cr,uid,app_ids)
for obj in self.browse(cr,uid,ids,context):
if obj.database_id.type == 'postgres':
e = sqlalchemy.create_engine(obj.database_id.connection_url)
- app_objs = self.pool.get('olap.application')
- app_ids = app_objs.search(cr,uid,[] )
- app_res = app_objs.browse(cr,uid,app_ids)
for app_obj in app_res:
try:
result = e.execute(app_obj.query)
@@ -155,7 +157,8 @@ class olap_schema(osv.osv ):
('dbready','Schema is ready to use'),
('done','We Can Start building Cube'),
],'Schema State',readonly = True),
- 'app_detect': fields.function(_app_detect,method = True,type = 'char',string = 'Connection URL',size = 128),
+ 'app_detect': fields.function(_app_detect, method = True, type = 'char',\
+ string = 'Connection URL', size = 128),
}
_defaults = {
@@ -180,7 +183,6 @@ class olap_schema(osv.osv ):
elif type == 'mysql':
try:
- import MySQLdb
host = schema.database_id.db_host or ''
port = schema.database_id.db_port or ''
db = schema.database_id.db_name or ''
@@ -192,7 +194,6 @@ class olap_schema(osv.osv ):
elif type == 'oracle':
try:
- import cx_Oracle
host = schema.database_id.db_host or ''
port = schema.database_id.db_port or ''
db = schema.database_id.db_name or ''
@@ -203,7 +204,7 @@ class olap_schema(osv.osv ):
raise osv.except_osv('Error (cx_Oracle) : ',e)
for id in ids:
- self.write(cr,uid,id,{'state':'dbconnect'})
+ self.write(cr,uid,id,{'state': 'dbconnect'})
except Exception,e:
raise osv.except_osv('BI Error !',e)
@@ -274,8 +275,6 @@ class olap_schema(osv.osv ):
if not len(ids):
raise 'Schema not found !'
schema = self.browse(cr,uid,ids[0],context)
-# warehouse = cube.warehouse()
-# find_table = warehouse.match_table(cr, uid, request, context)
print 'Parsing MDX...'
print '\t',request
mdx_parser = cube.mdx_parser()
@@ -291,35 +290,20 @@ class olap_schema(osv.osv ):
currency = res_comp[0].currency_id.name
print " Default Currency",currency
data = mdx.run(currency)
-# qry_obj = self.pool.get('olap.query.logs')
-# qry_id = qry_obj.search(cr, uid, [('query','=', request)])
-#
-# flag = True
-# if qry_id:
-# qry = qry_obj.browse(cr, uid, qry_id)[0]
-#
-# if qry.count >=3 and qry.table_name!='':
-# data = warehouse.run(currency, qry)
-# flag = False
-# qry.count = qry.count +1
-# qry_obj.write(cr, uid, qry_id, {'count': qry.count})
-# else:
-# data = mdx.run(currency)
-# else:
-# data = mdx.run(currency)
+
print 'Running Done...'
print 'Formatting Output...'
-# if cubex.query_log and flag:
if cubex.query_log:
log = context.get('log')
if log:
connection = schema.database_id.connection_url
-# warehouse.log(cr,uid,cubex,request,data,connection,context)
mdx.log(cr,uid,cubex,request,context)
return cube.mdx_output(data)
olap_schema()
+
class olap_database_tables(osv.osv):
+ """ Database Tables """
_name = "olap.database.tables"
_description = "Olap Database Tables"
_columns = {
@@ -345,7 +329,8 @@ class olap_database_tables(osv.osv):
def show_col_view(self,cr,uid,ids,context = {}):
ids_cols = self.pool.get('olap.database.columns').search(cr,uid,([('table_id','=',ids[0])]))
- id = self.pool.get('ir.ui.view').search(cr,uid,([('name','=','olap.database.columns.tree')]),context = {})[0]
+ id = self.pool.get('ir.ui.view').search(cr,uid,\
+ ([('name','=','olap.database.columns.tree')]),context = {})[0]
return {
'domain': "[('id','in', [" + ','.join(map(str,ids_cols)) + "])]",
'name': 'Database Columns',
@@ -371,7 +356,9 @@ class olap_database_tables(osv.osv):
olap_database_tables()
+
class olap_database_columns(osv.osv):
+ """ Database Columns """
_name = "olap.database.columns"
_description = "Olap Database Columns"
datatypes = {
@@ -391,6 +378,7 @@ class olap_database_columns(osv.osv):
'time': 'TimeStamp without Time Zone',
'number':'NUMBER',
}
+
def _datatypes_get(self,*args,**argv):
return self.datatypes.items()
_columns = {
@@ -408,6 +396,7 @@ class olap_database_columns(osv.osv):
'active': lambda * args: True,
'primary_key': lambda * args: False,
}
+
def name_get(self,cr,uid,ids,context = {}):
result = []
for t in self.browse(cr,uid,ids,context):
@@ -433,8 +422,10 @@ class olap_database_columns(osv.osv):
for lines in dim_obj.cube_id.table_id.line_ids:
make_ids.append(lines.field_id.related_to.id)
make_ids.append(lines.field_id.table_id.id)
- args = [('table_id','in',make_ids),('related_to','<>',False),('hide','<>',True),('active','<>',False)]
- return super(olap_database_columns,self).search(cr,uid,args,offset,limit,order,context = context,count = count)
+ args = [('table_id','in',make_ids),('related_to','<>',False),\
+ ('hide','<>',True),('active','<>',False)]
+ return super(olap_database_columns,self).search(cr,uid,args,\
+ offset,limit,order,context = context,count = count)
if args and context and context.has_key('flag') and context['flag']:
ids = args[0][2][0][2]
@@ -446,19 +437,25 @@ class olap_database_columns(osv.osv):
make_ids.append(lines.related_to.id)
link_id = col_pool.browse(cr,uid,int(context['link_col']))
make_ids.append(link_id.table_id.id)
- args = ['|',('table_id','in',make_ids),('related_to','in',make_ids),('primary_key','<>',True),('hide','<>',True),('active','<>',False)]
- ids = super(olap_database_columns,self).search(cr,uid,args,offset,limit,order,context = context,count = count)
+ args = ['|',('table_id','in',make_ids),('related_to','in',make_ids),\
+ ('primary_key','<>',True),('hide','<>',True),('active','<>',False)]
+ ids = super(olap_database_columns,self).search(cr,uid,args,\
+ offset,limit,order,context = context,count = count)
return ids
elif context and context.has_key('master_dim') and context['master_dim']:
make_ids = []
col_obj = col_pool.browse(cr,uid,int(context['link_col']))
- args = ['|',('table_id','=',col_obj.related_to.id),('related_to','=',col_obj.table_id.id),('hide','<>',True),('active','<>',False)]
- return super(olap_database_columns,self).search(cr,uid,args,offset,limit,order,context = context,count = count)
+ args = ['|',('table_id','=',col_obj.related_to.id),\
+ ('related_to','=',col_obj.table_id.id),('hide','<>',True),('active','<>',False)]
+ return super(olap_database_columns,self).search(cr,uid,args,\
+ offset,limit,order,context = context,count = count)
else:
col = col_pool.browse(cr,uid,int(context['link_col']))
base_table = col.table_id
- args = ['|',('table_id','=',base_table.id),('related_to','=',base_table.id),('hide','<>',True),('active','<>',False)]
- return super(olap_database_columns,self).search(cr,uid,args,offset,limit,order,context = context,count = count)
+ args = ['|',('table_id','=',base_table.id),\
+ ('related_to','=',base_table.id),('hide','<>',True),('active','<>',False)]
+ return super(olap_database_columns,self).search(cr,uid,args,\
+ offset,limit,order,context = context,count = count)
if context and context.has_key('filter_cols_cube'):
@@ -469,7 +466,10 @@ class olap_database_columns(osv.osv):
make_ids.append(lines.table_id.id)
if make_ids:
make_ids.append(cube_obj.table_id.line_ids[len(cube_obj.table_id.line_ids) - 1].field_id.related_to.id)
- args = [('table_id','in',make_ids),('related_to','=',False),('primary_key','<>',True),('type','not in',['date','timestamp','timestampz','time']),('hide','<>',True),('active','<>',False)]
+ args = [('table_id','in',make_ids),('related_to','=',False),\
+ ('primary_key','<>',True),\
+ ('type','not in',['date','timestamp','timestampz','time']),\
+ ('hide','<>',True),('active','<>',False)]
ids = super(olap_database_columns,self).search(cr,uid,args,offset,limit,
order,context = context,count = count)
return ids
@@ -503,7 +503,8 @@ class olap_database_columns(osv.osv):
table_ids = []
for line in lines:
table_ids.append(line.table_id.id)
- args = [('table_id','in',table_ids),('related_to','<>',False),('hide','<>',True),('active','<>',False)]
+ args = [('table_id','in',table_ids),('related_to','<>',False),\
+ ('hide','<>',True),('active','<>',False)]
elif context and context.has_key('master_schema') and context['master_schema']:
args = [('primary_key','=','True')]
return super(olap_database_columns,self).search(cr,uid,args,offset,limit,
@@ -536,7 +537,8 @@ class olap_database_columns(osv.osv):
}
id = self.pool.get('olap.cube.table.line').create(cr,uid,val,context)
else:
- parent_id = self.pool.get('olap.cube.table').create(cr,uid,{'name':col_data['table_id'][1]},context)
+ parent_id = self.pool.get('olap.cube.table').create(cr,uid,\
+ {'name':col_data['table_id'][1]},context)
ctx_list = [('client','web'),('app','bi'),('id',parent_id)]
return ctx_list
@@ -558,12 +560,12 @@ class olap_database_columns(osv.osv):
id = self.pool.get('olap.hierarchy').write(cr,uid,context['hier_parent_id'],val,context)
else:
if context['parent_name']: val['name'] = context['parent_name']
- if context['parent_dimension'] :val['dimension_id'] = context['parent_dimension']
- if context['hier_parent_table'] : val['table_id'] = context['hier_parent_table']
- if context['parent_field_name'] : val['field_name'] = context['parent_field_name']
- if context['parent_level'] : val['level_ids'] = conext['parent_level']
+ if context['parent_dimension']:val['dimension_id'] = context['parent_dimension']
+ if context['hier_parent_table']: val['table_id'] = context['hier_parent_table']
+ if context['parent_field_name']: val['field_name'] = context['parent_field_name']
+ if context['parent_level']: val['level_ids'] = conext['parent_level']
if context['parent_member_all']: val['member_all'] = context['parent_member_all']
- if context['parent_member_default'] : val['member_default'] = context['parent_member_default']
+ if context['parent_member_default']: val['member_default'] = context['parent_member_default']
if context['parent_type']: val['type'] = context['parent_type']
val['primary_key_table'] = col_data['table_id'][1]
id = self.pool.get('olap.hierarchy').create(cr,uid,val,context)
@@ -572,12 +574,16 @@ class olap_database_columns(osv.osv):
olap_database_columns()
+
class olap_cube_table(osv.osv):
+ """ Cube Table """
_name = "olap.cube.table"
_description = "Olap cube table"
def write(self,cr,uid,ids,vals,context = None):
- if vals and vals.get('available_table_ids',0) and context and (context.has_key('master_dim') or context.has_key('d_id') or context.has_key('parent_schema_id')):
+ if vals and vals.get('available_table_ids',0) and context and \
+ (context.has_key('master_dim') or context.has_key('d_id') or \
+ context.has_key('parent_schema_id')):
new_fields = vals['available_table_ids'][0][2]
final = []
for data in self.browse(cr,uid,ids):
@@ -626,7 +632,9 @@ class olap_cube_table(osv.osv):
def create(self,cr,uid,vals,context = None):
cube_table_id = super(olap_cube_table,self).create(cr,uid,vals,context)
- if vals and vals.get('available_table_ids',0) and context and (context.has_key('d_id') or context.has_key('parent_schema_id') or context.has_key('master_dim') or context.has_key('d_id')):
+ if vals and vals.get('available_table_ids',0) and context and \
+ (context.has_key('d_id') or context.has_key('parent_schema_id') or \
+ context.has_key('master_dim') or context.has_key('d_id')):
lines_ids = vals['available_table_ids'][0][2]
cols_obj = self.pool.get('olap.database.columns').browse(cr,uid,lines_ids)
val = {}
@@ -642,9 +650,10 @@ class olap_cube_table(osv.osv):
if context and context.has_key('parent_schema_id'):
args = [('schema_id','=',context['parent_schema_id'])]
if context and context.has_key('d_id'):
- dim_obj = self.pool.get('olap.dimension').browse(cr,uid,int(context['d_id']))
+ dim_obj = self.pool.get('olap.dimension').browse(cr,uid,int(['d_id']))
args = [('schema_id','=',dim_obj.cube_id.schema_id.id)]
- return super(olap_cube_table,self).search(cr,uid,args,offset,limit,order,context = context,count = count)
+ return super(olap_cube_table,self).search(cr,uid,args,offset,limit,\
+ order,context = context,count = count)
def _available_table_get(self,cr,uid,ids,name,arg,context = None):
result = {}
@@ -675,10 +684,14 @@ class olap_cube_table(osv.osv):
def _get_id(self,cr,uid,ids,context = {}):
if context and context.has_key('d_id'):
dim_obj = self.pool.get('olap.dimension').browse(cr,uid,int(context['d_id']))
- table_id = self.pool.get('olap.database.tables').search(cr,uid,[('table_db_name','in',[dim_obj.cube_id.table_id.name]),('fact_database_id','=',dim_obj.cube_id.schema_id.database_id.id)])
- col_ids = self.pool.get('olap.database.columns').search(cr,uid,[('table_id','in',table_id),('hide','<>',True),('related_to','<>',False)])
+ table_id = self.pool.get('olap.database.tables').search(cr,uid,\
+ [('table_db_name','in',[dim_obj.cube_id.table_id.name]),\
+ ('fact_database_id','=',dim_obj.cube_id.schema_id.database_id.id)])
+ col_ids = self.pool.get('olap.database.columns').search(cr,uid,\
+ [('table_id','in',table_id),('hide','<>',True),('related_to','<>',False)])
else:
- col_ids = self.pool.get('olap.database.columns').search(cr,uid,[('primary_key','=',True),('hide','<>',True)])
+ col_ids = self.pool.get('olap.database.columns').search(cr,uid,\
+ [('primary_key','=',True),('hide','<>',True)])
return col_ids
def _def_set(self,cr,uid,context = {}):
@@ -704,7 +717,9 @@ class olap_cube_table(osv.osv):
return {}
olap_cube_table()
+
class olap_cube_table_line(osv.osv):
+ """ Cube Table Line """
_name = "olap.cube.table.line"
_description = "Olap cube table"
_rec_name = 'table_id'
@@ -718,7 +733,9 @@ class olap_cube_table_line(osv.osv):
pass
olap_cube_table_line()
+
class olap_cube(osv.osv):
+ """ Olap Cube """
_name = "olap.cube"
_description = "Olap cube"
@@ -733,28 +750,30 @@ class olap_cube(osv.osv):
'schema_id': fields.many2one('olap.schema','Schema',readonly = True),
'dimension_ids': fields.one2many('olap.dimension','cube_id','Dimensions'),
'measure_ids': fields.one2many('olap.measure','cube_id','Measures'),
- 'query_log': fields.boolean('Query Logging', help = "Enabling this will log all the queries in the browser"),
+ 'query_log': fields.boolean('Query Logging', help = "Enabling this will \
+ log all the queries in the browser"),
'query_ids': fields.one2many('olap.query.logs','cube_id','Queries'),
}
_defaults = {
- 'schema_id':_set_schema
+ 'schema_id': _set_schema
}
olap_cube()
+
class olap_query_logs(osv.osv):
+ """ Query Logs """
_name = "olap.query.logs"
_description = "Olap query logs"
_columns = {
- 'user_id' : fields.many2one('res.users','Tiny ERP User'),
- 'query':fields.text('Query',required = True),
- 'time':fields.datetime('Time',required = True),
- 'result_size':fields.integer('Result Size',readonly = True),
+ 'user_id': fields.many2one('res.users','Tiny ERP User'),
+ 'query': fields.text('Query',required = True),
+ 'time': fields.datetime('Time',required = True),
+ 'result_size': fields.integer('Result Size',readonly = True),
'cube_id': fields.many2one('olap.cube','Cube',required = True),
'count': fields.integer('Count', readonly=True),
'schema_id': fields.many2one('olap.schema','Schema',readonly = True),
-# 'table_name': fields.char('Table Name', size=164, readonly = True),
}
-
+
_defaults = {
'count':lambda * args: 0
}
@@ -762,6 +781,7 @@ olap_query_logs()
class olap_dimension(osv.osv):
+ """ Olap Dimension """
_name = "olap.dimension"
_description = "Olap dimension"
@@ -776,12 +796,14 @@ class olap_dimension(osv.osv):
'hierarchy_ids': fields.one2many('olap.hierarchy','dimension_id','Hierarchies'),
}
_defaults = {
- 'cube_id':_set_cube,
+ 'cube_id': _set_cube,
}
olap_dimension()
+
class olap_hierarchy(osv.osv):
+ """ Olap Hierarchy """
_name = "olap.hierarchy"
_description = "Olap hierarchy"
_order = "sequence, id"
@@ -814,18 +836,21 @@ class olap_hierarchy(osv.osv):
'sequence': fields.integer('Sequence',required = True),
'dimension_id': fields.many2one('olap.dimension','Dimension',required = True),
'level_ids': fields.one2many('olap.level','hierarchy_id','Levels'),
- 'table_id': fields.many2one('olap.cube.table','Fact table(s)',required = True , help ="Table(s) to make hierarchy on the cube."),
+ 'table_id': fields.many2one('olap.cube.table','Fact table(s)',\
+ required = True , help ="Table(s) to make hierarchy on the cube."),
}
_defaults = {
'sequence': lambda * args: 1,
'primary_key': lambda * args: 'id',
- 'dimension_id':_set_dimension,
- 'name':_set_name
+ 'dimension_id': _set_dimension,
+ 'name': _set_name
}
olap_hierarchy()
+
class olap_level(osv.osv):
+ """ Olap Level """
_name = "olap.level"
_description = "Olap level"
_order = "sequence, id"
@@ -867,7 +892,9 @@ class olap_level(osv.osv):
'column_name':fields.many2one('olap.database.columns','Columns Name',required = True),
'column_id_name': fields.char('Column ID',size = 64,required = True),
'type': fields.selection(selection = _type_get,string = 'Level class',size = 64,required = True),
- 'table_name': fields.char('Table name',size = 64,required = True,help = "The name of the table on which the column is defined. If False, take the table from the hierarchy."),
+ 'table_name': fields.char('Table name',size = 64,required = True,\
+ help = "The name of the table on which the column is defined.\
+ If False, take the table from the hierarchy."),
'sequence': fields.integer('Sequence',required = True),
'hierarchy_id': fields.many2one('olap.hierarchy','Hierarchy',required = True),
}
@@ -876,14 +903,15 @@ class olap_level(osv.osv):
'column_id_name': lambda * args: 'name',
'sequence':lambda * args: '1',
'type':lambda * args:'normal',
- 'hierarchy_id':_set_hierarchy,
- 'name':_set_name
+ 'hierarchy_id': _set_hierarchy,
+ 'name': _set_name
}
olap_level()
class olap_measure(osv.osv):
+ """ Olap Measure """
_name = "olap.measure"
_description = "Olap measure"
@@ -908,76 +936,82 @@ class olap_measure(osv.osv):
'value_column': fields.many2one('olap.database.columns','Fact Table Column'),
'value_column_id_name': fields.char('Column ID',size = 64),
'table_name': fields.char('Table name',size = 64,help = "The name of the table on which the column is defined. If False, take the table from the cube."),
- 'measure_type':fields.selection([('fact_column','Fact Table Column'),('sql_expr','SQL Expression')],'Measure Type',required = True,help = "Select between auto column or sql expression for the measures"),
+ 'measure_type': fields.selection([('fact_column','Fact Table Column'),('sql_expr','SQL Expression')],'Measure Type',required = True,help = "Select between auto column or sql expression for the measures"),
'value_sql': fields.char('SQL Expression',size = 200,help = "You can provide valid sql expression. Make sure it have function with fully qualified column name like (sum,avg ...)(tablename.columnname (+,- ...) tablename.columnname)"),
'agregator': fields.selection([('sum','Sum'),('count','count'),('avg','Average')],'Agregator',required = True),
'datatype': fields.selection([('int','Integer'),('float','Float')],'Datatype',required = True),
'formatstring': fields.selection([
- ('none','None (0000.00)'),
- ('cr_prefix','Prefix Default Currency (EUR 0000.00)'),
- ('cr_postfix','Postfix Default Currency(0000.00 EUR)'),
- ('cr_prefix_comma','Prefix Default Currency with comma seperator (EUR 0,000.00)'),
- ('cr_postfix_comma','Postfix Default Currency with comma seperator (0,000.00 EUR)'),
- ('comma_sep', 'Comma Seperator (0,000)')
- ],
- 'Format string',required = True, help=" Let you specify how the measure to be displayed in cube browser"),
+ ('none','None (0000.00)'),
+ ('cr_prefix','Prefix Default Currency (EUR 0000.00)'),
+ ('cr_postfix','Postfix Default Currency(0000.00 EUR)'),
+ ('cr_prefix_comma','Prefix Default Currency with comma seperator (EUR 0,000.00)'),
+ ('cr_postfix_comma','Postfix Default Currency with comma seperator (0,000.00 EUR)'),
+ ('comma_sep', 'Comma Seperator (0,000)')
+ ],'Format string',required = True, help=" Let you specify how the measure to be displayed in cube browser"),
}
_defaults = {
'agregator': lambda * args: 'sum',
'datatype': lambda * args: 'float',
'formatstring': lambda * args: 'none',
- 'cube_id':_set_cube,
+ 'cube_id': _set_cube,
'measure_type':lambda * args:'fact_column',
}
olap_measure()
+
class olap_application(osv.osv):
+ """ Olap Application """
_name = "olap.application"
_description = "Olap application"
_columns = {
'name': fields.char('Application name',size = 64,required = True),
- 'query':fields.text('Application Query'),
- 'table_ids':fields.one2many('olap.application.table','application_id','Tables'),
+ 'query': fields.text('Application Query'),
+ 'table_ids': fields.one2many('olap.application.table','application_id','Tables'),
'field_ids': fields.one2many('olap.application.field','application_id','Fields'),
}
olap_application()
class olap_application_table(osv.osv):
+ """ Application Table """
_name = "olap.application.table"
_description = "Olap application table"
_columns = {
'name': fields.char('Application table name',size = 64,required = True),
'table_name': fields.char('Table name',size = 64,required = True),
'is_hidden': fields.boolean('Hidden'),
- 'application_id': fields.many2one('olap.application','Application Id',required = True),
+ 'application_id': fields.many2one('olap.application','Application Id',required = True),
}
olap_application_table()
+
class olap_application_field(osv.osv):
+ """ Application Field """
_name = "olap.application.field"
_description = "Olap application field"
_columns = {
'name': fields.char('Application field name',size = 64,required = True),
- 'table_name': fields.char('Application table name',size = 64),
+ 'table_name': fields.char('Application table name',size = 64),
'field_name':fields.char('Field name',size = 64),
'is_hidden': fields.boolean('Hidden'),
- 'application_id': fields.many2one('olap.application','Application Id',required = True),
+ 'application_id': fields.many2one('olap.application','Application Id',required = True),
}
olap_application_field()
+
class olap_saved_query(osv.osv):
+ """ Olap Saved Query """
_name = "olap.saved.query"
_decription = "Olap Saved Query"
-# _rec_name = 'user_id'
+
_columns = {
'name': fields.text('Query Name',size = 64),
- 'user_id' : fields.many2one('res.users','User'),
+ 'user_id': fields.many2one('res.users','User'),
'query': fields.text('Query',required = True),
'cube_id': fields.many2one('olap.cube','Cube',required = True),
'mdx_id': fields.char('Module', size=64),
'schema_id': fields.many2one('olap.schema','Schema',required = True),
- 'time':fields.datetime('Time',required = True),
+ 'time': fields.datetime('Time',required = True),
'axis_keys': fields.text('Axis Keys'),
}
olap_saved_query()
@@ -1004,123 +1038,21 @@ class bi_load_db_wizard(osv.osv_memory):
}
_defaults = {
- 'fact_table':_get_fact_table,
- 'db_name':_get_db_name,
+ 'fact_table': _get_fact_table,
+ 'db_name': _get_db_name,
}
def action_load(self,cr,uid,ids,context = None):
+ data = context and context.get('active_id', False) or False
if context and context.has_key('active_id'):
- lines = self.pool.get('olap.schema').browse(cr,uid,context['active_id'])
+ lines = self.pool.get('olap.schema').browse(cr,uid,data)
pool = pooler.get_pool(cr.dbname)
-# lines=pool.get('olap.schema').browse(cr, uid, part['id'],context)
id_db = lines.database_id.id
type = lines.database_id.type
db_name = lines.database_id.db_name
tobj = pool.get('olap.database.tables')
tcol = pool.get('olap.database.columns')
if type == 'postgres':
-# host = lines.database_id.db_host and "host=%s" % lines.database_id.db_host or ''
-# port = lines.database_id.db_port and "port=%s" % lines.database_id.db_port or ''
-# name = lines.database_id.db_name and "dbname=%s" % lines.database_id.db_name or ''
-# user = lines.database_id.db_login and "user=%s" % lines.database_id.db_login or ''
-# password = lines.database_id.db_password and "password=%s" % lines.database_id.db_password or ''
-# tdb = psycopg2.connect('%s %s %s %s %s' % (host, port, name, user, password))
-# cr_db = tdb.cursor()
-# cr.execute('select table_db_name,id from olap_database_tables where fact_database_id=%d', (id_db,))
-# tables = dict(cr.fetchall())
-# # Format for storing the tables
-# # tables['table_db_name']=id
-# tables_id = map(lambda x: str(tables[x]),tables)
-# cols={}
-# if tables_id:
-# cr.execute('select column_db_name,id,table_id from olap_database_columns where table_id in (' + ','.join(tables_id) +')')
-# else:
-# cr.execute('select column_db_name,id,table_id from olap_database_columns')
-#
-# for data in cr.fetchall():
-# cols[str(data[1])]=(data[0],int(data[2]))
-# # Format of storing the cols
-# # cols['id']=(col_db_name,table_id)
-# print 'Creating / Updating Tables...'
-# cr_db.execute("select table_name, table_catalog from INFORMATION_SCHEMA.tables as a where a.table_schema = 'public'")
-# for table in cr_db.fetchall():
-# val = {
-# 'fact_database_id':id_db,
-# 'table_db_name':table[0]
-# }
-#
-# if table[0] in tables.keys():
-# table_id=tobj.write(cr,uid,[tables[table[0]]], val, context)
-# else:
-# val['name']=table[0]
-# tables[val['name']] = tobj.create(cr,uid,val, context)
-# print 'Creating / Updating Columns...'
-# cr_db.execute("""SELECT
-# table_name, column_name, udt_name
-# from
-# INFORMATION_SCHEMA.columns
-# WHERE table_schema = 'public'""")
-#
-# for col in cr_db.fetchall():
-# val={
-# 'table_id': tables[col[0]],
-# 'column_db_name': col[1],
-# 'type': col[2],
-# }
-#
-# id_made=filter(lambda x:(int(cols[x][1])==int(tables[col[0]])),cols)
-# if col[1] in cols.keys() and col[0] in tables.keys()and id_made:
-# col_id=tcol.write(cr,uid,cols[tables[str(col[0])]], val, context)
-# else:
-# val['name']=col[1]
-# id_made = tcol.create(cr,uid,val, context)
-# cols[str(id_made)] = (val['name'],int(val['table_id']))
-# print 'Creating / Updating Constraints...'
-# cr_db.execute("""select
-# table_name,column_name
-# from
-# INFORMATION_schema.key_column_usage
-# where
-# constraint_name in (
-# select constraint_name from INFORMATION_SCHEMA .table_constraints
-# where
-# constraint_type = 'PRIMARY KEY')""")
-# print "Updating the Primary Key Constraint"
-# for constraint in cr_db.fetchall():
-# val={
-# 'primary_key':True
-# }
-#
-# id_to_write=filter(lambda x:(int(cols[x][1])==int(tables[constraint[0]])and(constraint[1]==cols[x][0])),cols)
-# col_id=tcol.write(cr,uid,int(id_to_write[0]),val,context)
-# print "Updating the Foreign key constraint"
-# cr_db.execute("""select
-# constraint_name,table_name
-# from
-# INFORMATION_schema.constraint_column_usage
-# where
-# constraint_name in (
-# select constraint_name from INFORMATION_SCHEMA.table_constraints
-# where
-# constraint_type = 'FOREIGN KEY')""")
-# for_key=dict(cr_db.fetchall())
-#
-# cr_db.execute("""select
-# table_name,column_name,constraint_name
-# from
-# INFORMATION_schema.key_column_usage
-# where
-# constraint_name in (
-# select constraint_name from INFORMATION_SCHEMA.table_constraints
-# where
-# constraint_type = 'FOREIGN KEY')""")
-
-# for constraint in cr_db.fetchall():
-# val={
-# 'related_to':tables[for_key[constraint[2]]]
-# }
-# id_to_write=filter(lambda x:(int(cols[x][1])==int(tables[constraint[0]])and (constraint[1]==cols[x][0])),cols)
-# col_id=tcol.write(cr,uid,int(id_to_write[0]),val,context)
host = lines.database_id.db_host and "host=%s" % lines.database_id.db_host or ''
port = lines.database_id.db_port and "port=%s" % lines.database_id.db_port or ''
@@ -1129,15 +1061,13 @@ class bi_load_db_wizard(osv.osv_memory):
password = lines.database_id.db_password and "password=%s" % lines.database_id.db_password or ''
tdb = psycopg2.connect('%s %s %s %s %s' % (host,port,name,user,password))
cr_db = tdb.cursor()
- cr.execute('select table_db_name,id from olap_database_tables where fact_database_id=%d',(id_db,))
+ cr.execute('select table_db_name,id from olap_database_tables \
+ where fact_database_id=%d',(id_db,))
tables = dict(cr.fetchall())
- # Format for storing the tables
- # tables['table_db_name']=id
tables_id = map(lambda x: str(tables[x]),tables)
- # Format of storing the cols
- # cols['id']=(col_db_name,table_id)
print 'Creating / Updating Tables...'
- cr_db.execute("select table_name, table_catalog from INFORMATION_SCHEMA.tables as a where a.table_schema = 'public'")
+ cr_db.execute("select table_name, table_catalog from \
+ INFORMATION_SCHEMA.tables as a where a.table_schema = 'public'")
for table in cr_db.fetchall():
val = {
'fact_database_id':id_db,
@@ -1152,10 +1082,14 @@ class bi_load_db_wizard(osv.osv_memory):
print 'Creating / Updating Columns ....'
cols = {}
if tables_id:
- cr.execute('select column_db_name,id,table_id from olap_database_columns where table_id in (' + ','.join(tables_id) + ')')
+ cr.execute('select column_db_name,id,table_id from \
+ olap_database_columns where table_id in (' + ','.join(tables_id) + ')')
else:
-# cr.execute('select column_db_name,id,table_id from olap_database_columns ')
- cr.execute("select olap_database_columns.column_db_name, olap_database_columns.id, olap_database_columns.table_id from olap_database_columns join olap_database_tables on olap_database_columns.table_id = olap_database_tables.id where olap_database_tables.fact_database_id=%d",(id_db,))
+ cr.execute("select olap_database_columns.column_db_name,\
+ olap_database_columns.id, olap_database_columns.table_id \
+ from olap_database_columns join olap_database_tables \
+ on olap_database_columns.table_id = olap_database_tables.id \
+ where olap_database_tables.fact_database_id=%d",(id_db,))
table_col = {}
cols_name = {}
for x in tables:
@@ -1189,14 +1123,14 @@ class bi_load_db_wizard(osv.osv_memory):
cols[str(id_made)] = (val['name'],int(val['table_id']))
print 'Creating / Updating Constraints...'
- cr_db.execute("""select
- table_name,column_name
- from
+ cr_db.execute("""select
+ table_name,column_name
+ from
INFORMATION_schema.key_column_usage
- where
+ where
constraint_name in (
select constraint_name from INFORMATION_SCHEMA .table_constraints
- where
+ where
constraint_type = 'PRIMARY KEY')""")
print "Updating the Primary Key Constraint"
@@ -1209,25 +1143,25 @@ class bi_load_db_wizard(osv.osv_memory):
col_id = tcol.write(cr,uid,int(id_to_write[0]),val,context)
print "Updating the Foreign key constraint"
- cr_db.execute("""select
- constraint_name,table_name
- from
- INFORMATION_schema.constraint_column_usage
+ cr_db.execute("""select
+ constraint_name,table_name
+ from
+ INFORMATION_schema.constraint_column_usage
where
constraint_name in (
- select constraint_name from INFORMATION_SCHEMA.table_constraints
- where
+ select constraint_name from INFORMATION_SCHEMA.table_constraints
+ where
constraint_type = 'FOREIGN KEY')""")
for_key = dict(cr_db.fetchall())
- cr_db.execute("""select
- table_name,column_name,constraint_name
- from
+ cr_db.execute("""select
+ table_name,column_name,constraint_name
+ from
INFORMATION_schema.key_column_usage
- where
+ where
constraint_name in (
- select constraint_name from INFORMATION_SCHEMA.table_constraints
- where
+ select constraint_name from INFORMATION_SCHEMA.table_constraints
+ where
constraint_type = 'FOREIGN KEY')""")
for constraint in cr_db.fetchall():
@@ -1253,18 +1187,21 @@ class bi_load_db_wizard(osv.osv_memory):
raise osv.except_osv('MySQLdb Packages Not Installed.',e)
cr_db = tdb.cursor()
- cr.execute('select table_db_name,id from olap_database_tables where fact_database_id=%d',(id_db,))
+ cr.execute('select table_db_name,id from olap_database_tables \
+ where fact_database_id=%d',(id_db,))
tables = dict(cr.fetchall())
tables_id = map(lambda x: str(tables[x]),tables)
cols = {}
if tables_id:
- cr.execute('select column_db_name,id,table_id from olap_database_columns where table_id in (' + ','.join(tables_id) + ')')
+ cr.execute('select column_db_name,id,table_id from \
+ olap_database_columns where table_id in (' + ','.join(tables_id) + ')')
else:
cr.execute('select column_db_name,id,table_id from olap_database_columns')
for data in cr.fetchall():
cols[str(data[1])] = (data[0],int(data[2]))
- cr_db.execute("select table_name, table_catalog from INFORMATION_SCHEMA.tables where table_schema =%s",(db_name))
+ cr_db.execute("select table_name, table_catalog from \
+ INFORMATION_SCHEMA.tables where table_schema =%s",(db_name))
for table in cr_db.fetchall():
val = {
@@ -1300,17 +1237,16 @@ class bi_load_db_wizard(osv.osv_memory):
id_made = tcol.create(cr,uid,val,context)
cols[str(id_made)] = (val['name'],int(val['table_id']))
- cr_db.execute("""select
+ cr_db.execute("""select
REFERENCED_COLUMN_NAME,REFERENCED_TABLE_NAME,COLUMN_NAME,TABLE_NAME
- from
+ from
INFORMATION_schema.key_column_usage
- where table_schema= %s and
+ where table_schema= %s and
constraint_name in (
select constraint_name from INFORMATION_SCHEMA .table_constraints
- where
+ where
constraint_type in('PRIMARY KEY','FOREIGN KEY'))
""",(db_name))
- # lines=pool.get('olap.schema').browse(cr, uid, part['id'],context)
for constraint in cr_db.fetchall():
if constraint[0]:
@@ -1322,7 +1258,8 @@ class bi_load_db_wizard(osv.osv_memory):
val = {
'primary_key':True
}
- id_to_write = filter(lambda x:(int(cols[x][1]) == int(tables[constraint[3]])and(constraint[2] == cols[x][0])),cols)
+ id_to_write = filter(lambda x:(int(cols[x][1]) == int(tables[constraint[3]])and \
+ (constraint[2] == cols[x][0])),cols)
col_id = tcol.write(cr,uid,int(id_to_write[0]),val,context)
elif type == 'oracle':
@@ -1339,12 +1276,14 @@ class bi_load_db_wizard(osv.osv_memory):
raise osv.except_osv('cx_Oracle Packages Not Installed.',e)
cr_db = tdb.cursor()
- cr.execute('select table_db_name,id from olap_database_tables where fact_database_id=%d',(id_db,))
+ cr.execute('select table_db_name,id from olap_database_tables \
+ where fact_database_id=%d',(id_db,))
tables = dict(cr.fetchall())
tables_id = map(lambda x: str(tables[x]),tables)
cols = {}
if tables_id:
- cr.execute('select column_db_name,id,table_id from olap_database_columns where table_id in (' + ','.join(tables_id) + ')')
+ cr.execute('select column_db_name,id,table_id from \
+ olap_database_columns where table_id in (' + ','.join(tables_id) + ')')
else:
cr.execute('select column_db_name,id,table_id from olap_database_columns')
@@ -1369,7 +1308,7 @@ class bi_load_db_wizard(osv.osv_memory):
cr_db.execute("""SELECT
table_name, column_name, data_type
from
- all_tab_columns
+ all_tab_columns
WHERE owner = %s""",(user))
temp = cr_db.fetchall()
for col in temp:
@@ -1395,14 +1334,14 @@ class bi_load_db_wizard(osv.osv_memory):
id_made = tcol.create(cr,uid,val,context)
cols[str(id_made)] = (val['name'],int(val['table_id']))
- cr_db.execute("""select
+ cr_db.execute("""select
table_name,column_name,constraint_name
- from
+ from
all_cons_columns
where
constraint_name in (
select constraint_name from all_constraints
- where
+ where
constraint_type = 'P' and owner= %s)
""",(user))
temp = cr_db.fetchall()
@@ -1413,26 +1352,27 @@ class bi_load_db_wizard(osv.osv_memory):
}
pk_table[constraint[2]] = constraint[0]
- id_to_write = filter(lambda x : (int(cols[x][1]) == int(tables[constraint[0]])and(constraint[1] == cols[x][0])),cols)
+ id_to_write = filter(lambda x : (int(cols[x][1]) == int(tables[constraint[0]])\
+ and(constraint[1] == cols[x][0])),cols)
col_id = tcol.write(cr,uid,int(id_to_write[0]),val,context)
- cr_db.execute("""select
+ cr_db.execute("""select
constraint_name,r_constraint_name from all_constraints
- where
+ where
constraint_type = 'R' and owner = %s
""",(user))
constraints_map = {}
for data in cr_db.fetchall():
constraints_map[data[0]] = data[1]
- cr_db.execute("""select
+ cr_db.execute("""select
table_name,column_name,constraint_name
- from
+ from
all_cons_columns
where
constraint_name in (
select constraint_name from all_constraints
- where
+ where
constraint_type = 'R' and owner = %s)
""",(user))
@@ -1444,45 +1384,35 @@ class bi_load_db_wizard(osv.osv_memory):
val = {
'related_to' : tables[req_table]
}
- id_to_write = filter(lambda x:(int(cols[x][1]) == int(tables[constraint[0]])and (constraint[1] == cols[x][0])),cols)
+ id_to_write = filter(lambda x:(int(cols[x][1]) == int(tables[constraint[0]])\
+ and (constraint[1] == cols[x][0])),cols)
col_id = tcol.write(cr,uid,int(id_to_write[0]),val,context)
+ data = context and context.get('active_id', False) or False
temp = pooler.get_pool(cr.dbname).get('olap.fact.database').write(cr,uid,[id_db],{'loaded':True})
wf_service = netsvc.LocalService('workflow')
- wf_service.trg_validate(uid,'olap.schema',context['active_id'],'dbload',cr)
- model_data_ids = self.pool.get('ir.model.data').search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_olap_schema_form')])
- resource_id = self.pool.get('ir.model.data').read(cr,uid,model_data_ids,fields = ['res_id'])[0]['res_id']
+ wf_service.trg_validate(uid,'olap.schema',data,'dbload',cr)
+ model_data_ids = self.pool.get('ir.model.data').search(cr,uid,\
+ [('model','=','ir.ui.view'),('name','=','view_olap_schema_form')])
+ resource_id = self.pool.get('ir.model.data').read(cr,uid,\
+ model_data_ids,fields = ['res_id'])[0]['res_id']
return {'type':'ir.actions.act_window_close' }
-# return{
-# 'domain': [],
-# 'name': 'view_olap_schema_form',
-# 'view_type': 'form',
-# 'view_mode': 'form,tree',
-# 'res_id': context['active_id'],
-# 'res_model': 'olap.schema',
-# 'view': [(resource_id,'form')],
-# 'type': 'ir.actions.act_window_close'
-# }
-#
def action_cancel(self,cr,uid,ids,context = None):
return {'type':'ir.actions.act_window_close' }
bi_load_db_wizard()
-
-
-
# Wizard for the Automatic Application Configuration
# Replacement for the Load Wizard according to the new structure
class bi_auto_configure_wizard(osv.osv_memory):
_name = 'bi.auto.configure.wizard'
-
- def _get_name(self,cr,uid,ctx):
- if ctx and ctx.has_key('active_id'):
- schema_obj = self.pool.get('olap.schema').browse(cr,uid,ctx['active_id'])
+ def _get_name(self,cr,uid,context):
+ data = context and context.get('active_id', False) or False
+ if context and context.has_key('active_id'):
+ schema_obj = self.pool.get('olap.schema').browse(cr,uid,data)
return schema_obj.name
return False
@@ -1499,8 +1429,8 @@ class bi_auto_configure_wizard(osv.osv_memory):
vals = {}
apptabnew_vals = {}
appfieldnew_vals = {}
-
- ids = pooler.get_pool(cr.dbname).get('olap.schema').browse(cr,uid,context['active_id'])
+ data = context and context.get('active_id', False) or False
+ ids = pooler.get_pool(cr.dbname).get('olap.schema').browse(cr,uid,data)
if ids.app_detect == "Unknown Application":
raise wizard.except_wizard('Warning','The Application is Unknown, we can not configure it automatically.')
@@ -1532,13 +1462,17 @@ class bi_auto_configure_wizard(osv.osv_memory):
appcol_name.append(apcol.name)
dbtab_obj = pooler.get_pool(cr.dbname).get('olap.database.tables')
-# id_tables=dbtab_obj.search(cr,uid,[('fact_database_id','=',ids.database_id.id),('table_db_name','not in',['inherit','res_roles','user_rule_group_rel','res_roles_users_rel','group_rule_group_rel'])])
id_tables = dbtab_obj.search(cr,uid,[('fact_database_id','=',ids.database_id.id)])
tables_main = dbtab_obj.read(cr,uid,id_tables,context = {'wizard':True})
for tables in tables_main:
- end_user_name = {'name':(" ").join(map(lambda x:x.capitalize(),tables['table_db_name'].split("_")))}
+ end_user_name = {'name':(" ").join(map(lambda x:x.capitalize(),\
+ tables['table_db_name'].split("_")))}
table_new = dbtab_obj.write(cr,uid,tables['id'],end_user_name)
- if not(tables['table_db_name'].startswith('ir') or tables['table_db_name'].startswith('wkf') or tables['table_db_name'].startswith('res_groups') or tables['table_db_name'].startswith('res_role')) and tables['table_db_name'] not in ['inherit','user_rule_group_rel','group_rule_group_rel']:
+ if not(tables['table_db_name'].startswith('ir') or \
+ tables['table_db_name'].startswith('wkf') or \
+ tables['table_db_name'].startswith('res_groups') or \
+ tables['table_db_name'].startswith('res_role')) and \
+ tables['table_db_name'] not in ['inherit','user_rule_group_rel','group_rule_group_rel']:
vals = {}
if len(apptab_ids) == 0 and (tables['table_db_name'] not in apptab_name):
@@ -1551,17 +1485,21 @@ class bi_auto_configure_wizard(osv.osv_memory):
else:
if map_apptab_name_id.has_key(tables['table_db_name']):
app_table = map_apptab_name_id[tables['table_db_name']]
- if ((app_table['table_name'] == tables['table_db_name']) and not (app_table['table_name'] == tables['name'])):
- vals['name'] = (" ").join(map(lambda x:x.capitalize(),tables['name'].split("_")))
+ if ((app_table['table_name'] == tables['table_db_name']) \
+ and not (app_table['table_name'] == tables['name'])):
+ vals['name'] = (" ").join(map(lambda x:x.capitalize(),\
+ tables['name'].split("_")))
vals['is_hidden'] = tables['hide']
tables_obj_new = apptab_objs.write(cr,uid,app_table['id'],vals)
else:
vals['table_name'] = tables['table_db_name']
- vals['name'] = (" ").join(map(lambda x:x.capitalize(),tables['table_db_name'].split("_")))
+ vals['name'] = (" ").join(map(lambda x:x.capitalize(),\
+ tables['table_db_name'].split("_")))
vals['is_hidden'] = tables['hide']
vals['application_id'] = app_id
apptab_new_obj = apptab_objs.create(cr,uid,vals)
- id_columns = pooler.get_pool(cr.dbname).get('olap.database.columns').search(cr,uid,[('table_id','in',id_tables)])
+ id_columns = pooler.get_pool(cr.dbname).get('olap.database.columns').search(cr,uid,\
+ [('table_id','in',id_tables)])
columns = pooler.get_pool(cr.dbname).get('olap.database.columns').read(cr,uid,id_columns,[])
for columns in columns:
vals = {}
@@ -1573,7 +1511,8 @@ class bi_auto_configure_wizard(osv.osv_memory):
vals['application_id'] = x_app['id']
appfield_new_obj = appfield_objs.create(cr,uid,vals)
else:
- filter_column = filter(lambda x: columns['column_db_name'] == x['field_name'] and columns['table_id'][1] == x['table_name'],appfield_data_res)
+ filter_column = filter(lambda x: columns['column_db_name'] == x['field_name'] \
+ and columns['table_id'][1] == x['table_name'],appfield_data_res)
if map_apptab_name_id.has_key(columns['table_id'][1]) and filter_column:
table_id_write = map_apptab_name_id[columns['table_id'][1]]
vals['name'] = (" ").join(map(lambda x:x.capitalize(),columns['name'].split("_")))
@@ -1594,7 +1533,12 @@ class bi_auto_configure_wizard(osv.osv_memory):
make_id = []
for table in tables:
vals = {}
- if (table['table_db_name'].startswith('ir') or table['table_db_name'].startswith('wkf')) or (table['table_db_name'].startswith('res_groups')) or (table['table_db_name'] in ['inherit','res_roles','user_rule_group_rel','res_roles_users_rel','group_rule_group_rel']):
+ if (table['table_db_name'].startswith('ir') or \
+ table['table_db_name'].startswith('wkf')) or \
+ (table['table_db_name'].startswith('res_groups')) or \
+ (table['table_db_name'] in \
+ ['inherit','res_roles','user_rule_group_rel',\
+ 'res_roles_users_rel','group_rule_group_rel']):
vals['hide'] = True
vals['active'] = False
make_id.append(table['id'])
@@ -1609,11 +1553,13 @@ class bi_auto_configure_wizard(osv.osv_memory):
vals['active'] = False
database_columns.write(cr,uid,col['id'],vals)
-
+ data = context and context.get('active_id', False) or False
wf_service = netsvc.LocalService('workflow')
- wf_service.trg_validate(uid,'olap.schema',context['active_id'],'dbconfigure',cr)
- model_data_ids = self.pool.get('ir.model.data').search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_olap_schema_form')])
- resource_id = self.pool.get('ir.model.data').read(cr,uid,model_data_ids,fields = ['res_id'])[0]['res_id']
+ wf_service.trg_validate(uid,'olap.schema',data,'dbconfigure',cr)
+ model_data_ids = self.pool.get('ir.model.data').search(cr,uid,\
+ [('model','=','ir.ui.view'),('name','=','view_olap_schema_form')])
+ resource_id = self.pool.get('ir.model.data').read(cr,uid,\
+ model_data_ids,fields = ['res_id'])[0]['res_id']
return {'type':'ir.actions.act_window_close' }
@@ -1625,9 +1571,10 @@ bi_auto_configure_wizard()
class olap_warehouse_wizard(osv.osv_memory):
+ """ Warehouse """
_name = "olap.warehouse.wizard"
_description = "Olap Warehouse"
-
+
def _get_queries(self, cr, uid, context = {}):
query_obj = self.pool.get('olap.query.logs')
qry_ids = query_obj.search(cr, uid, [('user_id','=',uid),('count','>=',3)])
@@ -1643,15 +1590,18 @@ class olap_warehouse_wizard(osv.osv_memory):
return ''
def action_ok(self, cr, uid, ids, context = {}):
return {'type':'ir.actions.act_window_close' }
-
+
_columns = {
- 'query': fields.text('Query', readonly=True),
+ 'query':fields.text('Query',readonly=True),
}
_defaults = {
'query': _get_queries,
}
olap_warehouse_wizard()
+
+
class olap_parameters_config_wizard(osv.osv_memory):
+ """ Apply Parameters for configuration """
_name = "olap.parameters.config.wizard"
_description = "Olap Server Parameters"
@@ -1661,7 +1611,9 @@ class olap_parameters_config_wizard(osv.osv_memory):
aid = objid._get_id(cr,uid,'olap','menu_url_cube_browser')
aid = objid.browse(cr,uid,aid,context = context).res_id
aid = self.pool.get('ir.actions.url').browse(cr,uid,aid,context = context)
- s_p = Literal("http://").suppress() + Word(alphanums + "_" + ".") + Literal(":").suppress() + Word(nums) + Literal("/").suppress() + Word(alphanums + "_" + " ").suppress()
+ s_p = Literal("http://").suppress() + Word(alphanums + "_" + ".") +\
+ Literal(":").suppress() + Word(nums) + Literal("/").suppress()\
+ + Word(alphanums + "_" + " ").suppress()
return s_p.parseString(aid.url)[0]
def _get_port(self,cr,uid,context = None):
@@ -1670,7 +1622,9 @@ class olap_parameters_config_wizard(osv.osv_memory):
aid = objid._get_id(cr,uid,'olap','menu_url_cube_browser')
aid = objid.browse(cr,uid,aid,context = context).res_id
aid = self.pool.get('ir.actions.url').browse(cr,uid,aid,context = context)
- s_p = Literal("http://").suppress() + Word(alphanums + "_" + ".") + Literal(":").suppress() + Word(nums) + Literal("/").suppress() + Word(alphanums + "_" + " ").suppress()
+ s_p = Literal("http://").suppress() + Word(alphanums + "_" + ".") + \
+ Literal(":").suppress() + Word(nums) + Literal("/").suppress() + \
+ Word(alphanums + "_" + " ").suppress()
return s_p.parseString(aid.url)[1]
_columns = {
@@ -1713,6 +1667,7 @@ class olap_parameters_config_wizard(osv.osv_memory):
'type': 'ir.actions.act_window',
'target':'new',
}
+
olap_parameters_config_wizard()
# vim: ts=4 sts=4 sw=4 si et
diff --git a/addons/olap/wizard/olap_load_column.py b/addons/olap/wizard/olap_load_column.py
index 97dc635d3fc..6fe594f60c8 100755
--- a/addons/olap/wizard/olap_load_column.py
+++ b/addons/olap/wizard/olap_load_column.py
@@ -28,7 +28,6 @@
from osv import fields, osv
class olap_load_column(osv.osv_memory):
- """ Load Database Column """
_name = "olap.load.column"
_description = "Olap Load Column"
@@ -38,11 +37,12 @@ class olap_load_column(osv.osv_memory):
@param cr: the current row, from the database cursor,
@param uid: the current user\'s ID for security checks,
@param ids: List of load column,
- @return : dictionary of database columns window on give id
+ @return: dictionary of database columns window on give id
"""
+ data = context and context.get('active_id', False) or False
ids_cols = self.pool.get('olap.database.columns').search(cr, uid,\
- ([('table_id','=',context['active_id'])]),context={})
+ ([('table_id','=',data)]),context={})
model_data_ids = self.pool.get('ir.model.data').search(cr,uid,\
[('model','=','ir.ui.view'),\
('name','=','view_olap_database_columns_form')],context={})
diff --git a/addons/olap/wizard/olap_load_column_view.xml b/addons/olap/wizard/olap_load_column_view.xml
index ef76ec555c6..21053274e54 100644
--- a/addons/olap/wizard/olap_load_column_view.xml
+++ b/addons/olap/wizard/olap_load_column_view.xml
@@ -1,8 +1,11 @@
+
+
+
- Create Logs
+ Open Columns
olap.load.column
form
diff --git a/addons/olap/wizard/olap_query_logs_clear.py b/addons/olap/wizard/olap_query_logs_clear.py
index 8d271315874..95623ac11d3 100755
--- a/addons/olap/wizard/olap_query_logs_clear.py
+++ b/addons/olap/wizard/olap_query_logs_clear.py
@@ -28,7 +28,6 @@
from osv import fields, osv
class olap_query_logs_clear(osv.osv_memory):
- """ Clear the Logs for Given User """
_name = "olap.query.logs.clear"
_description = "Olap Query Logs Clear"
_columns = {
@@ -69,6 +68,7 @@ class olap_query_logs_clear(osv.osv_memory):
olap_query_logs_clear()
+
class olap_query_logs_clear_msg(osv.osv_memory):
""" Display clear log message """
_name = "olap.query.logs.clear.msg"
@@ -77,4 +77,5 @@ class olap_query_logs_clear_msg(osv.osv_memory):
}
olap_query_logs_clear_msg()
+
# vim: ts=4 sts=4 sw=4 si et
diff --git a/addons/olap/wizard/olap_query_logs_clear_view.xml b/addons/olap/wizard/olap_query_logs_clear_view.xml
index 08d93c9410b..a780988c2b9 100644
--- a/addons/olap/wizard/olap_query_logs_clear_view.xml
+++ b/addons/olap/wizard/olap_query_logs_clear_view.xml
@@ -1,8 +1,11 @@
+
+
+
- Create Logs
+ Clear Logs
olap.query.logs.clear
form
@@ -19,7 +22,7 @@
- Create Logs
+ Clear Logs
ir.actions.act_window
olap.query.logs.clear
form
@@ -28,7 +31,7 @@
- Create Logs Message
+ Clear Logs Message
olap.query.logs.clear.msg
form
diff --git a/addons/wiki/security/ir.model.access.csv b/addons/wiki/security/ir.model.access.csv
index acb871141ff..9ddfa27eee2 100644
--- a/addons/wiki/security/ir.model.access.csv
+++ b/addons/wiki/security/ir.model.access.csv
@@ -6,3 +6,7 @@
"wiki_groups_link","wiki.groups.link","model_wiki_groups_link","base.group_system",1,1,1,1
"wiki_wiki_history","wiki.wiki.history","model_wiki_wiki_history","base.group_user",1,0,1,0
"wiki_wizard_wiki_history_show_diff","wizard.wiki.history.show_diff","model_wizard_wiki_history_show_diff","base.group_user",1,1,1,1
+"wiki_wiki_page_open","wiki.wiki.page.open","model_wiki_wiki_page_open","base.group_user",1,1,1,1
+"wiki_create_menu","wiki.create.menu","model_wiki_create_menu","base.group_user",1,1,1,1
+"wiki_wiki_help_open","wiki.wiki.help.open","model_wiki_wiki_help_open","base.group_user",1,1,1,1
+"wiki_make_index","wiki.make.index","model_wiki_make_index","base.group_user",1,1,1,1
diff --git a/addons/wiki/wiki.py b/addons/wiki/wiki.py
index db6fcadac92..55b71b8ae10 100644
--- a/addons/wiki/wiki.py
+++ b/addons/wiki/wiki.py
@@ -27,67 +27,89 @@
##############################################################################
from osv import fields, osv
-import time
-from StringIO import StringIO
-from HTMLParser import HTMLParser
+import difflib
class Wiki(osv.osv):
- _name="wiki.wiki"
+ """ wiki """
+
+ _name = "wiki.wiki"
+
Wiki()
class WikiGroup(osv.osv):
+ """ Wiki Groups """
+
_name = "wiki.groups"
- _description="Wiki Groups"
+ _description = "Wiki Groups"
_order = 'name'
- _columns={
- 'name':fields.char('Wiki Group', size=256, select=True, required=True),
- 'page_ids':fields.one2many('wiki.wiki', 'group_id', 'Pages'),
- 'notes':fields.text("Description"),
- 'create_date':fields.datetime("Created Date", select=True),
- 'template': fields.text('Wiki Template'),
- 'section': fields.boolean("Make Section ?"),
- 'method':fields.selection([('list','List'),('page','Home Page'),('tree','Tree')],'Display Method'),
- 'home':fields.many2one('wiki.wiki', 'Pages'),
+
+ _columns = {
+ 'name':fields.char('Wiki Group', size=256, select=True, required=True),
+ 'page_ids':fields.one2many('wiki.wiki', 'group_id', 'Pages'),
+ 'notes':fields.text("Description"),
+ 'create_date':fields.datetime("Created Date", select=True),
+ 'template': fields.text('Wiki Template'),
+ 'section': fields.boolean("Make Section ?"),
+ 'method':fields.selection([('list', 'List'), ('page', 'Home Page'), \
+ ('tree', 'Tree')], 'Display Method'),
+ 'home':fields.many2one('wiki.wiki', 'Pages'),
}
+
_defaults = {
- 'method': lambda *a: 'page',
+ 'method': lambda *a: 'page',
}
+
WikiGroup()
+
class GroupLink(osv.osv):
+ """ Apply Group Link """
+
_name = "wiki.groups.link"
- _description="Wiki Groups Links"
+ _description = "Wiki Groups Links"
_rec_name = 'action_id'
- _columns={
- 'group_id':fields.many2one('wiki.groups', 'Parent Group', ondelete='set null'),
+
+ _columns = {
+ 'group_id': fields.many2one('wiki.groups', 'Parent Group', ondelete='set null'),
'action_id': fields.many2one('ir.ui.menu', 'Menu')
}
+
GroupLink()
+
class Wiki(osv.osv):
- _inherit="wiki.wiki"
- _description="Wiki Page"
+ """ Wiki Page """
+
+ _inherit = "wiki.wiki"
+ _description = "Wiki Page"
_order = 'section,create_date desc'
- _columns={
- 'name':fields.char('Title', size=256, select=True, required=True),
- 'write_uid':fields.many2one('res.users',"Last Author"),
- 'text_area':fields.text("Content"),
- 'create_uid':fields.many2one('res.users','Author', select=True),
- 'create_date':fields.datetime("Created on", select=True),
- 'write_date':fields.datetime("Modification Date", select=True),
- 'tags':fields.char('Tags', size=1024),
- 'history_id':fields.one2many('wiki.wiki.history','wiki_id','History Lines'),
- 'minor_edit':fields.boolean('Minor edit', select=True),
- 'summary':fields.char('Summary',size=256),
- 'section': fields.char('Sequence', size=32, help="Use page section code like 1.2.1"),
- 'group_id':fields.many2one('wiki.groups', 'Wiki Group', select=1, ondelete='set null'),
- 'toc':fields.boolean('Table of Contents'),
- 'review': fields.boolean('Need Review'),
- 'parent_id':fields.many2one('wiki.wiki', 'Parent Page'),
- 'child_ids':fields.one2many('wiki.wiki', 'parent_id', 'Child Pages'),
+
+ _columns = {
+ 'name': fields.char('Title', size=256, select=True, required=True),
+ 'write_uid': fields.many2one('res.users', "Last Author"),
+ 'text_area': fields.text("Content"),
+ 'create_uid': fields.many2one('res.users', 'Author', select=True),
+ 'create_date': fields.datetime("Created on", select=True),
+ 'write_date': fields.datetime("Modification Date", select=True),
+ 'tags': fields.char('Tags', size=1024),
+ 'history_id': fields.one2many('wiki.wiki.history', 'wiki_id', 'History Lines'),
+ 'minor_edit': fields.boolean('Minor edit', select=True),
+ 'summary': fields.char('Summary', size=256),
+ 'section': fields.char('Sequence', size=32, help="Use page section code like 1.2.1"),
+ 'group_id': fields.many2one('wiki.groups', 'Wiki Group', select=1, ondelete='set null'),
+ 'toc': fields.boolean('Table of Contents'),
+ 'review': fields.boolean('Need Review'),
+ 'parent_id': fields.many2one('wiki.wiki', 'Parent Page'),
+ 'child_ids': fields.one2many('wiki.wiki', 'parent_id', 'Child Pages'),
}
-
+
def onchange_group_id(self, cr, uid, ids, group_id, content, context={}):
+
+ """ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param ids: List of wiki page’s IDs
+ @return: dictionay of open wiki page on give page section """
+
if (not group_id) or content:
return {}
grp = self.pool.get('wiki.groups').browse(cr, uid, group_id)
@@ -103,62 +125,85 @@ class Wiki(osv.osv):
section = '.'.join(s)
return {
'value':{
- 'text_area': template,
+ 'text_area': template,
'section': section
}
}
+
def copy_data(self, cr, uid, id, default=None, context=None):
- return super(Wiki, self).copy_data(cr, uid, id, {'wiki_id':False}, context)
+
+ """ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ @param id: Give wiki page's ID """
+
+ return super(Wiki, self).copy_data(cr, uid, id, {'wiki_id': False}, context)
def create(self, cr, uid, vals, context=None):
- id = super(Wiki,self).create(cr, uid, vals, context)
+
+ """ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks, """
+
+ id = super(Wiki, self).create(cr, uid, vals, context)
history = self.pool.get('wiki.wiki.history')
- if vals.get('text_area'):
- res = {
- 'minor_edit':vals.get('minor_edit', True),
- 'text_area':vals.get('text_area',''),
- 'write_uid':uid,
- 'wiki_id' : id,
- 'summary':vals.get('summary','')
+ if vals.get('text_area'):
+ res = {
+ 'minor_edit': vals.get('minor_edit', True),
+ 'text_area': vals.get('text_area', ''),
+ 'write_uid': uid,
+ 'wiki_id': id,
+ 'summary':vals.get('summary', '')
}
history.create(cr, uid, res)
- return id
+ return id
def write(self, cr, uid, ids, vals, context=None):
- result = super(Wiki,self).write(cr, uid, ids, vals, context)
+
+ """ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks, """
+
+ result = super(Wiki, self).write(cr, uid, ids, vals, context)
history = self.pool.get('wiki.wiki.history')
if vals.get('text_area'):
for id in ids:
res = {
- 'minor_edit':vals.get('minor_edit', True),
- 'text_area':vals.get('text_area',''),
- 'write_uid':uid,
- 'wiki_id' : id,
- 'summary':vals.get('summary','')
+ 'minor_edit': vals.get('minor_edit', True),
+ 'text_area': vals.get('text_area', ''),
+ 'write_uid': uid,
+ 'wiki_id': id,
+ 'summary': vals.get('summary', '')
}
history.create(cr, uid, res)
return result
Wiki()
+
class History(osv.osv):
- _name="wiki.wiki.history"
- _description="Wiki History"
- _rec_name="date_time"
+ """ Wiki History """
+
+ _name = "wiki.wiki.history"
+ _description = "Wiki History"
+ _rec_name = "date_time"
_order = 'id DESC'
- _columns={
- 'create_date':fields.datetime("Date",select=True),
- 'text_area':fields.text("Text area"),
- 'minor_edit':fields.boolean('This is a major edit ?',select=True),
- 'summary':fields.char('Summary',size=256, select=True),
- 'write_uid':fields.many2one('res.users',"Modify By", select=True),
- 'wiki_id':fields.many2one('wiki.wiki','Wiki Id', select=True)
- }
+
+ _columns = {
+ 'create_date': fields.datetime("Date", select=True),
+ 'text_area': fields.text("Text area"),
+ 'minor_edit': fields.boolean('This is a major edit ?', select=True),
+ 'summary': fields.char('Summary', size=256, select=True),
+ 'write_uid': fields.many2one('res.users', "Modify By", select=True),
+ 'wiki_id': fields.many2one('wiki.wiki', 'Wiki Id', select=True)
+ }
+
_defaults = {
- 'write_uid': lambda obj,cr,uid,context: uid,
+ 'write_uid': lambda obj, cr, uid, context: uid,
}
+
def getDiff(self, cr, uid, v1, v2, context={}):
- import difflib
+
+ """ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks, """
+
history_pool = self.pool.get('wiki.wiki.history')
text1 = history_pool.read(cr, uid, [v1], ['text_area'])[0]['text_area']
text2 = history_pool.read(cr, uid, [v2], ['text_area'])[0]['text_area']
@@ -166,5 +211,7 @@ class History(osv.osv):
line2 = text2.splitlines(1)
diff = difflib.HtmlDiff()
return diff.make_file(line1, line2, "Revision-%s" % (v1), "Revision-%s" % (v2), context=False)
+
History()
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/wiki/wiki_view.xml b/addons/wiki/wiki_view.xml
index ec738a5a91f..875aa460f6a 100644
--- a/addons/wiki/wiki_view.xml
+++ b/addons/wiki/wiki_view.xml
@@ -1,12 +1,22 @@
-
-
-
-
+
-
+
+
+
+
+
+
+
+
+
wiki.groups.tree
wiki.groups
tree
@@ -16,6 +26,9 @@
+
+
+
wiki.groups.form
wiki.groups
@@ -26,8 +39,8 @@
-
-
+
@@ -46,16 +59,15 @@
+
+
Wikis
wiki.groups
form
tree,form
-
+
diff --git a/addons/wiki/wizard/show_diff.py b/addons/wiki/wizard/show_diff.py
index d77130f2aed..83708a8d8ce 100644
--- a/addons/wiki/wizard/show_diff.py
+++ b/addons/wiki/wizard/show_diff.py
@@ -19,12 +19,20 @@
#
##############################################################################
-from osv import fields,osv
+from osv import fields, osv
+from tools.translate import _
class showdiff(osv.osv_memory):
+ """ Disp[ay Difference for History """
+
_name = 'wizard.wiki.history.show_diff'
def _get_diff(self, cr, uid, ctx):
+
+ """ @param cr: the current row, from the database cursor,
+ @param uid: the current user’s ID for security checks,
+ """
+
history = self.pool.get('wiki.wiki.history')
ids = ctx.get('active_ids')
diff = ""
@@ -36,7 +44,7 @@ class showdiff(osv.osv_memory):
elif len(ids) == 1:
old = history.browse(cr, uid, ids[0])
- nids = history.search(cr, uid, [('wiki_id','=',old.wiki_id.id)])
+ nids = history.search(cr, uid, [('wiki_id', '=', old.wiki_id.id)])
nids.sort()
diff = history.getDiff(cr, uid, ids[0], nids[-1])
else:
@@ -44,10 +52,13 @@ class showdiff(osv.osv_memory):
return diff
_columns = {
- 'diff': fields.text('Diff'),
+ 'diff': fields.text('Diff'),
}
+
_defaults = {
'diff': _get_diff
}
+
showdiff()
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/wiki/wizard/wiki_create_menu.py b/addons/wiki/wizard/wiki_create_menu.py
index b9b2d5563c4..597592ab154 100644
--- a/addons/wiki/wizard/wiki_create_menu.py
+++ b/addons/wiki/wizard/wiki_create_menu.py
@@ -22,44 +22,46 @@
from osv import fields, osv
class wiki_create_menu(osv.osv_memory):
+ """ Create Menu """
+
_name = "wiki.create.menu"
_description = "Wizard Create Menu"
+
_columns = {
- 'menu_name': fields.char('Menu Name', size=256, select=True, required=True),
- 'menu_parent_id': fields.many2one('ir.ui.menu', 'Parent Menu', required=True),
- 'page': fields.many2one('wiki.wiki', 'Group Home Page'),
+ 'menu_name': fields.char('Menu Name', size=256, select=True, required=True),
+ 'menu_parent_id': fields.many2one('ir.ui.menu', 'Parent Menu', required=True),
+ 'page': fields.many2one('wiki.wiki', 'Group Home Page'),
}
def wiki_menu_create(self, cr, uid, ids, context):
+
""" Create Menu On the base of Group id and Action id
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of create menu’s IDs
"""
+ mod_obj = self.pool.get('ir.model.data')
+ action_id = mod_obj._get_id(cr, uid, 'wiki', 'action_view_wiki_wiki_page_open')
- for group in self.pool.get('wiki.groups').browse(cr, uid, ids):
- for menu in self.pool.get('wiki.create.menu').browse(cr, uid, ids):
+ for menu in self.browse(cr, uid, ids):
+ menu_id = self.pool.get('ir.ui.menu').create(cr, uid, {
+ 'name':menu.menu_name,
+ 'parent_id':menu.menu_parent_id.id,
+ 'icon': 'STOCK_DIALOG_QUESTION',
+ 'action': 'ir.actions.act_window,'+ str(action_id)
+ }, context)
+ home = menu.page.id
+ group_id = menu.id
+ res = {
+ 'home':home,
+ }
+ self.pool.get('wiki.groups').write(cr, uid, ids, res)
+ self.pool.get('wiki.groups.link').create(cr, uid,
+ {'group_id': group_id, 'action_id': menu_id})
- mod_obj = self.pool.get('ir.model.data')
- action_id = mod_obj._get_id(cr, uid, 'wiki', 'action_view_wiki_wiki_page_open')
- menu_id = self.pool.get('ir.ui.menu').create(cr, uid, {
- 'name':menu.menu_name,
- 'parent_id':menu.menu_parent_id.id,
- 'icon': 'STOCK_DIALOG_QUESTION',
- 'action': 'ir.actions.act_window,'+ str(action_id)
- }, context)
- home = menu.page.id
- group_id = menu.id
- res = {
- 'home':home,
- }
- self.pool.get('wiki.groups').write(cr, uid, ids, res)
- self.pool.get('wiki.groups.link').create(cr, uid,
- {'group_id': group_id, 'action_id':menu_id})
-
- return {}
+ return {}
wiki_create_menu()
-# 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/addons/wiki/wizard/wiki_create_menu_view.xml b/addons/wiki/wizard/wiki_create_menu_view.xml
index 7acd1e2a70d..e62f9647ecd 100644
--- a/addons/wiki/wizard/wiki_create_menu_view.xml
+++ b/addons/wiki/wizard/wiki_create_menu_view.xml
@@ -1,6 +1,9 @@
+
+
+
+
+