[IMP] Actions handling wip
bzr revid: nicolas.vanhoren@openerp.com-20110407095912-r6cqswx9pvo684ek
This commit is contained in:
parent
448e551276
commit
0cab8e6972
|
@ -177,20 +177,24 @@ def load_actions_from_ir_values(req, key, key2, models, meta, context):
|
|||
actions = Values.get(key, key2, models, meta, context)
|
||||
|
||||
for _, _, action in actions:
|
||||
# values come from the server, we can just eval them
|
||||
if isinstance(action['context'], basestring):
|
||||
action['context'] = eval(
|
||||
action['context'],
|
||||
req.session.evaluation_context()) or {}
|
||||
clean_action(action, req.session)
|
||||
|
||||
if isinstance(action['domain'], basestring):
|
||||
action['domain'] = eval(
|
||||
action['domain'],
|
||||
req.session.evaluation_context(
|
||||
action['context'])) or []
|
||||
fix_view_modes(action)
|
||||
return actions
|
||||
|
||||
def clean_action(action, session):
|
||||
# values come from the server, we can just eval them
|
||||
if isinstance(action['context'], basestring):
|
||||
action['context'] = eval(
|
||||
action['context'],
|
||||
session.evaluation_context()) or {}
|
||||
|
||||
if isinstance(action['domain'], basestring):
|
||||
action['domain'] = eval(
|
||||
action['domain'],
|
||||
session.evaluation_context(
|
||||
action['context'])) or []
|
||||
fix_view_modes(action)
|
||||
|
||||
def fix_view_modes(action):
|
||||
""" For historical reasons, OpenERP has weird dealings in relation to
|
||||
view_mode and the view_type attribute (on window actions):
|
||||
|
|
|
@ -20,7 +20,7 @@ openerp.base.ActionManager = openerp.base.Controller.extend({
|
|||
if (this.viewmanager) {
|
||||
this.viewmanager.stop();
|
||||
}
|
||||
this.viewmanager = new openerp.base.ViewManager(this.session,this.element_id, false);
|
||||
this.viewmanager = new openerp.base.ViewManager(this.session,this.element_id, true);
|
||||
this.viewmanager.do_action_window(action);
|
||||
this.viewmanager.start();
|
||||
}
|
||||
|
@ -33,17 +33,17 @@ openerp.base.ActionManager = openerp.base.Controller.extend({
|
|||
openerp.base.views = new openerp.base.Registry();
|
||||
|
||||
openerp.base.ViewManager = openerp.base.Controller.extend({
|
||||
init: function(session, element_id, desactivate_sidebar) {
|
||||
init: function(session, element_id, has_sidebar) {
|
||||
this._super(session, element_id);
|
||||
this.action = null;
|
||||
this.dataset = null;
|
||||
this.searchview = null;
|
||||
this.active_view = null;
|
||||
this.views = {};
|
||||
if (desactivate_sidebar)
|
||||
this.sidebar = null;
|
||||
else
|
||||
if (has_sidebar)
|
||||
this.sidebar = new openerp.base.Sidebar(null, this);
|
||||
else
|
||||
this.sidebar = null;
|
||||
},
|
||||
start: function() {
|
||||
if (this.sidebar) {
|
||||
|
@ -307,8 +307,7 @@ openerp.base.Sidebar = openerp.base.BaseWidget.extend({
|
|||
var i = $this.attr("data-i");
|
||||
var j = $this.attr("data-i");
|
||||
var action = self.sections[i].elements[j];
|
||||
// I know this doesn't work, one day it will
|
||||
new openerp.base.ActionManager(this.view_manager, null).do_action(action);
|
||||
openerp.base.handle_action(self.view_manager.session, action);
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
});
|
||||
|
@ -319,6 +318,21 @@ openerp.base.Sidebar = openerp.base.BaseWidget.extend({
|
|||
}
|
||||
});
|
||||
|
||||
openerp.base.handle_action = function(session, action) {
|
||||
if(action.type=="ir.actions.act_window") {
|
||||
if(action.target=="new") {
|
||||
var element_id = _.uniqueId("act_window_dialog");
|
||||
var dialog = $('<div id="'+element_id+'"></div>');
|
||||
dialog.dialog({
|
||||
title: action.name
|
||||
});
|
||||
var viewmanager = new openerp.base.ViewManager(session,element_id, false);
|
||||
viewmanager.do_action_window(action);
|
||||
viewmanager.start();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
openerp.base.views.add('calendar', 'openerp.base.CalendarView');
|
||||
|
||||
openerp.base.CalendarView = openerp.base.Controller.extend({
|
||||
|
|
|
@ -17,6 +17,7 @@ import simplejson
|
|||
|
||||
import nonliterals
|
||||
import xmlrpctimeout
|
||||
import logging
|
||||
|
||||
#----------------------------------------------------------
|
||||
# OpenERP Client Library
|
||||
|
@ -320,6 +321,8 @@ class JsonRequest(object):
|
|||
}
|
||||
}
|
||||
except Exception:
|
||||
cherrypy.log("An error occured while handling a json request",
|
||||
severity=logging.ERROR, traceback=True)
|
||||
error = {
|
||||
'code': 300,
|
||||
'message': "OpenERP WebClient Error",
|
||||
|
@ -470,3 +473,4 @@ def main(argv):
|
|||
cherrypy.server.subscribe()
|
||||
cherrypy.engine.start()
|
||||
cherrypy.engine.block()
|
||||
|
||||
|
|
Loading…
Reference in New Issue