[IMP] Action wip - popup is working.
bzr revid: nicolas.vanhoren@openerp.com-20110408152508-5mes2key0yzq9avq
This commit is contained in:
parent
887ec82f20
commit
29ed9f9be3
|
@ -9,6 +9,8 @@ import openerpweb
|
|||
import openerpweb.ast
|
||||
import openerpweb.nonliterals
|
||||
|
||||
import cherrypy
|
||||
|
||||
# Should move to openerpweb.Xml2Json
|
||||
class Xml2Json:
|
||||
# xml2json-direct
|
||||
|
@ -168,6 +170,47 @@ class Session(openerpweb.Controller):
|
|||
'domain': domain,
|
||||
'group_by': group_by_sequence
|
||||
}
|
||||
|
||||
@openerpweb.jsonrequest
|
||||
def save_session_action(self, req, the_action):
|
||||
"""
|
||||
This method store an action object in the session object and returns an integer
|
||||
identifying that action. The method get_session_action() can be used to get
|
||||
back the action.
|
||||
|
||||
:param the_action: The action to save in the session.
|
||||
:type the_action: anything
|
||||
:return: A key identifying the saved action.
|
||||
:rtype: integer
|
||||
"""
|
||||
saved_actions = cherrypy.session.get('saved_actions')
|
||||
if not saved_actions:
|
||||
saved_actions = {"next":0, "actions":{}}
|
||||
cherrypy.session['saved_actions'] = saved_actions
|
||||
# we don't allow more than 10 stored actions
|
||||
if len(saved_actions["actions"]) >= 10:
|
||||
del saved_actions["actions"][min(saved_actions["actions"].keys())]
|
||||
key = saved_actions["next"]
|
||||
saved_actions["actions"][key] = the_action
|
||||
saved_actions["next"] = key + 1
|
||||
return key
|
||||
|
||||
@openerpweb.jsonrequest
|
||||
def get_session_action(self, req, key):
|
||||
"""
|
||||
Gets back a previously saved action. This method can return None if the action
|
||||
was saved since too much time (this case should be handled in a smart way).
|
||||
|
||||
:param key: The key given by save_session_action()
|
||||
:type key: integer
|
||||
:return: The saved action or None.
|
||||
:rtype: anything
|
||||
"""
|
||||
saved_actions = cherrypy.session.get('saved_actions')
|
||||
if not saved_actions:
|
||||
return None
|
||||
return saved_actions["actions"].get(key)
|
||||
|
||||
|
||||
def load_actions_from_ir_values(req, key, key2, models, meta, context):
|
||||
Values = req.session.model('ir.values')
|
||||
|
|
|
@ -159,10 +159,13 @@ openerp.base.ViewManagerAction = openerp.base.ViewManager.extend({
|
|||
search_defaults[match[1]] = value;
|
||||
}
|
||||
});
|
||||
var searchview_loaded = this.setup_search_view(view_id,search_defaults);
|
||||
var searchview_loaded = null;
|
||||
if (view_id) {
|
||||
searchview_loaded = this.setup_search_view(view_id,search_defaults);
|
||||
}
|
||||
|
||||
// schedule auto_search
|
||||
if (this.action['auto_search']) {
|
||||
if (searchview_loaded != null && this.action['auto_search']) {
|
||||
$.when(searchview_loaded, inital_view_loaded)
|
||||
.then(this.searchview.do_search);
|
||||
}
|
||||
|
@ -291,9 +294,10 @@ openerp.base.Sidebar = openerp.base.BaseWidget.extend({
|
|||
this.$element.find("a").click(function(e) {
|
||||
$this = jQuery(this);
|
||||
var i = $this.attr("data-i");
|
||||
var j = $this.attr("data-i");
|
||||
var j = $this.attr("data-j");
|
||||
var action = self.sections[i].elements[j];
|
||||
openerp.base.handle_action(self.view_manager.session, action);
|
||||
(new openerp.base.ExternalActionManager(self.view_manager.session, null))
|
||||
.handle_action(action);
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
});
|
||||
|
@ -304,19 +308,31 @@ 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.ViewManagerAction(session,element_id, action, false);
|
||||
viewmanager.start();
|
||||
openerp.base.ExternalActionManager = openerp.base.Controller.extend({
|
||||
handle_action: function(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.ViewManagerAction(this.session
|
||||
,element_id, action, false);
|
||||
viewmanager.start();
|
||||
} else if (action.target == "current") {
|
||||
this.rpc("/base/session/save_session_action", {the_action:action}, function(key) {
|
||||
debugger;
|
||||
var url = window.location.href;
|
||||
//window.open();
|
||||
});
|
||||
}
|
||||
}
|
||||
// TODO: show an error like "not implemented" here
|
||||
// since we don't currently have any way to handle errors do you have any better idea
|
||||
// than using todos?
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
openerp.base.views.add('calendar', 'openerp.base.CalendarView');
|
||||
openerp.base.CalendarView = openerp.base.Controller.extend({
|
||||
|
|
|
@ -492,7 +492,7 @@
|
|||
<t t-set="j" t-value="0"/>
|
||||
<t t-foreach="section.elements" t-as="element">
|
||||
<li><a t-att-data-i="i" t-att-data-j="j" href="#"><t t-esc="element.name"/></a></li>
|
||||
<t t-set="j+1" t-value="0"/>
|
||||
<t t-set="j" t-value="j+1"/>
|
||||
</t>
|
||||
</ul>
|
||||
</t>
|
||||
|
|
Loading…
Reference in New Issue