2011-10-10 14:29:53 +00:00
|
|
|
|
|
|
|
openerp.share = function(instance) {
|
|
|
|
|
2011-12-18 15:43:32 +00:00
|
|
|
function launch_wizard(self, view, button) {
|
|
|
|
var button = button || 'go_step_1';
|
2011-10-10 14:29:53 +00:00
|
|
|
var action = view.widget_parent.action;
|
2011-10-14 12:12:12 +00:00
|
|
|
var Share = new instance.web.DataSet(self, 'share.wizard', view.dataset.get_context());
|
2011-12-14 17:35:29 +00:00
|
|
|
var domain = new instance.web.CompoundDomain(view.dataset.domain);
|
2011-10-14 12:12:12 +00:00
|
|
|
if (view.fields_view.type == 'form') {
|
|
|
|
domain = new instance.web.CompoundDomain(domain, [['id', '=', view.datarecord.id]]);
|
|
|
|
}
|
2011-12-14 17:35:29 +00:00
|
|
|
self.rpc('/web/session/eval_domain_and_context', {
|
|
|
|
domains: [domain],
|
|
|
|
contexts: [view.dataset.context]
|
|
|
|
}, function (result) {
|
|
|
|
Share.create({
|
|
|
|
name: action.name,
|
|
|
|
domain: result.domain,
|
|
|
|
action_id: action.id,
|
2011-12-16 15:49:12 +00:00
|
|
|
view_type: view.fields_view.type,
|
2011-12-14 17:35:29 +00:00
|
|
|
}, function(result) {
|
|
|
|
var share_id = result.result;
|
2011-12-18 15:43:32 +00:00
|
|
|
var step1 = Share.call(button, [[share_id],], function(result) {
|
2011-12-14 17:35:29 +00:00
|
|
|
var action = result;
|
|
|
|
self.do_action(action);
|
|
|
|
});
|
2011-10-10 14:29:53 +00:00
|
|
|
});
|
|
|
|
});
|
2011-10-14 12:12:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
instance.web.Sidebar = instance.web.Sidebar.extend({
|
|
|
|
add_default_sections: function() {
|
|
|
|
this._super();
|
|
|
|
var self = this;
|
2011-12-16 16:19:09 +00:00
|
|
|
self.add_items('other', [{
|
|
|
|
label: 'Share',
|
|
|
|
callback: self.on_sidebar_click_share,
|
|
|
|
classname: 'oe-share',
|
|
|
|
}]);
|
2011-10-14 12:12:12 +00:00
|
|
|
},
|
|
|
|
on_sidebar_click_share: function(item) {
|
|
|
|
var view = this.widget_parent
|
|
|
|
launch_wizard(this, view);
|
2011-10-10 14:29:53 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2011-10-14 12:12:12 +00:00
|
|
|
instance.web.ViewManagerAction.include({
|
|
|
|
start: function() {
|
|
|
|
var self = this;
|
2011-12-18 15:43:32 +00:00
|
|
|
self.$element.find('a.oe-share_link').click(self.on_click_share_link);
|
2011-12-16 16:19:09 +00:00
|
|
|
self.$element.find('a.oe-share').click(self.on_click_share);
|
2011-10-14 12:12:12 +00:00
|
|
|
return this._super.apply(this, arguments);
|
|
|
|
},
|
2011-12-18 15:43:32 +00:00
|
|
|
on_click_share_link: function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
launch_wizard(this, this.views[this.active_view].controller,'go_step_1_link');
|
|
|
|
},
|
2011-10-14 12:12:12 +00:00
|
|
|
on_click_share: function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
launch_wizard(this, this.views[this.active_view].controller);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2011-10-10 14:29:53 +00:00
|
|
|
};
|