do changes for the dashboard custom view for the user
bzr revid: mga@tinyerp.com-20080806090154-xk18wtmndnxhpqhi
This commit is contained in:
parent
32f1fe4698
commit
6d0c48027c
|
@ -134,6 +134,7 @@
|
|||
<field name="name" select="1"/>
|
||||
<field name="type" select="1"/>
|
||||
<field name="usage"/>
|
||||
<field name="parent_id"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
@ -331,6 +331,11 @@ class actions_server(osv.osv):
|
|||
logger.notifyChannel('email', netsvc.LOG_INFO, 'Email successfully send to : %s' % (action.address))
|
||||
else:
|
||||
logger.notifyChannel('email', netsvc.LOG_ERROR, 'Failed to send email to : %s' % (action.address))
|
||||
if action.state == 'sms':
|
||||
if tools.sms_send(user, password, api_id, text, to) == True:
|
||||
logger.notifyChannel('sms', netsvc.LOG_INFO, 'SMS successfully send to : %s' % (action.address))
|
||||
else:
|
||||
logger.notifyChannel('sms', netsvc.LOG_ERROR, 'Failed to send SMS to : %s' % (action.address))
|
||||
return False
|
||||
actions_server()
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@ def _check_xml(self, cr, uid, ids, context={}):
|
|||
return False
|
||||
return True
|
||||
|
||||
class view(osv.osv):
|
||||
_name = 'ir.ui.view'
|
||||
class CustomView(osv.osv):
|
||||
_name = 'ir.ui.view.custom'
|
||||
_columns = {
|
||||
'name': fields.char('View Name',size=64, required=True),
|
||||
'model': fields.char('Model', size=64, required=True),
|
||||
|
@ -72,6 +72,31 @@ class view(osv.osv):
|
|||
_constraints = [
|
||||
(_check_xml, 'Invalid XML for View Architecture!', ['arch'])
|
||||
]
|
||||
CustomView()
|
||||
|
||||
class view(osv.osv):
|
||||
_name = 'ir.ui.view'
|
||||
_columns = {
|
||||
'name': fields.char('View Name',size=64, required=True),
|
||||
'model': fields.char('Model', size=64, required=True),
|
||||
'priority': fields.integer('Priority', required=True),
|
||||
'type': fields.selection((
|
||||
('tree','Tree'),
|
||||
('form','Form'),
|
||||
('graph', 'Graph'),
|
||||
('calendar', 'Calendar')), 'View Type', required=True),
|
||||
'arch': fields.text('View Architecture', required=True),
|
||||
'inherit_id': fields.many2one('ir.ui.view', 'Inherited View'),
|
||||
'field_parent': fields.char('Childs Field',size=64),
|
||||
}
|
||||
_defaults = {
|
||||
'arch': lambda *a: '<?xml version="1.0"?>\n<tree title="Unknwown">\n\t<field name="name"/>\n</tree>',
|
||||
'priority': lambda *a: 16
|
||||
}
|
||||
_order = "priority"
|
||||
_constraints = [
|
||||
(_check_xml, 'Invalid XML for View Architecture!', ['arch'])
|
||||
]
|
||||
|
||||
def read(self,cr, uid, ids, fields=None, context={}, load='_classic_read'):
|
||||
|
||||
|
@ -80,10 +105,10 @@ class view(osv.osv):
|
|||
|
||||
result = super(view, self).read(cr, uid, ids, fields, context, load)
|
||||
|
||||
if context.get('read', False) != 'default':
|
||||
if context.get('read', False) != 'custom':
|
||||
for rs in result:
|
||||
if rs.get('model',False) == 'board.board':
|
||||
cr.execute("select id,arch,ref_id from ir_ui_view where user_id=%d and ref_id=%d", (uid, rs['id']))
|
||||
cr.execute("select id,arch,ref_id from ir_ui_view_custom where user_id=%d and ref_id=%d", (uid, rs['id']))
|
||||
oview = cr.dictfetchall()
|
||||
if oview:
|
||||
rs['arch'] = oview[0]['arch']
|
||||
|
@ -93,22 +118,21 @@ class view(osv.osv):
|
|||
def write(self, cr, uid, ids, vals, context={}):
|
||||
exist = self.pool.get('ir.ui.view').browse(cr, uid, ids[0])
|
||||
if exist.model == 'board.board':
|
||||
if not exist.ref_id.id:
|
||||
vids = self.pool.get('ir.ui.view').search(cr, uid, [('user_id','=',uid), ('ref_id','=',ids[0])])
|
||||
if not vids:
|
||||
if context.get('tiny') == 'base':
|
||||
result = super(view, self).write(cr, uid, ids, vals, context)
|
||||
return result
|
||||
else:
|
||||
default = {}
|
||||
default['user_id'] = uid
|
||||
default['ref_id'] = ids[0]
|
||||
nids = super(view, self).copy(cr, uid, ids[0], default, context=context)
|
||||
result = super(view, self).write(cr, uid, [nids], vals, {})
|
||||
return result
|
||||
else:
|
||||
result = super(view, self).write(cr, uid, vids, vals, context)
|
||||
return result
|
||||
vids = self.pool.get('ir.ui.view.custom').search(cr, uid, [('user_id','=',uid), ('ref_id','=',ids[0])])
|
||||
if not vids:
|
||||
# if context.get('write') == 'custom':
|
||||
|
||||
old = self.pool.get('ir.ui.view').read(cr, uid, ids)[0]
|
||||
|
||||
del old['id']
|
||||
old['user_id'] = uid
|
||||
old['ref_id'] = ids[0]
|
||||
nid = self.pool.get('ir.ui.view.custom').create(cr, uid, old)
|
||||
result = self.pool.get('ir.ui.view.custom').write(cr, uid, [nid], vals)
|
||||
return result
|
||||
else:
|
||||
result = super(view, self).write(cr, uid, vids, vals, context)
|
||||
return result
|
||||
|
||||
result = super(view, self).write(cr, uid, ids, vals, context)
|
||||
cr.commit()
|
||||
|
|
Loading…
Reference in New Issue