diff --git a/addons/share/__openerp__.py b/addons/share/__openerp__.py index f6a0c93285d..ec026742f87 100644 --- a/addons/share/__openerp__.py +++ b/addons/share/__openerp__.py @@ -3,6 +3,7 @@ # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). +# Copyright (C) 2010-2011 OpenERP SA (). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -22,7 +23,7 @@ { "name" : "Web Share", - "version" : "1.5", + "version" : "2.0", "depends" : ["base", "mail"], "author" : "OpenERP SA", "category": 'Hidden', @@ -53,7 +54,9 @@ synchronization with other companies, etc. 'installable': True, 'web': True, 'certificate' : '001301246528927038493', - 'images': ['images/share_wizard.jpeg','images/sharing_wizard_step1.jpeg', 'images/sharing_wizard_step2.jpeg'], + 'js': ['static/src/js/share.js'], + 'css': ['static/src/css/share.css'], + 'images': ['static/src/img/share_wizard.jpeg','static/src/img/sharing_wizard_step1.jpeg', 'static/src/img/sharing_wizard_step2.jpeg'], } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/share/static/src/css/share.css b/addons/share/static/src/css/share.css new file mode 100644 index 00000000000..781bfe197f1 --- /dev/null +++ b/addons/share/static/src/css/share.css @@ -0,0 +1,5 @@ + +.openerp li.oe_share { + background: url(../img/share.png) no-repeat; + padding-left: 20px; +} diff --git a/addons/share/static/src/js/share.js b/addons/share/static/src/js/share.js new file mode 100644 index 00000000000..8a8294d0f12 --- /dev/null +++ b/addons/share/static/src/js/share.js @@ -0,0 +1,43 @@ + +openerp.share = function(instance) { + +instance.web.Sidebar = instance.web.Sidebar.extend({ + + add_default_sections: function() { + this._super(); + this.add_items('Sharing', [{ + label: 'Share', + callback: this.on_sidebar_click_share, + classname: 'oe_share', + }]); + }, + + on_sidebar_click_share: function(item) { + var self = this; + var view = this.widget_parent + var action = view.widget_parent.action; + + var share_url_template = _('%s//%s/?db=%%(dbname)s&login=%%(login)s').sprintf(document.location.protocol, document.location.host); + var Share = new instance.web.DataSet(this, 'share.wizard', view.dataset.get_context()); + + Share.create({ + name: action.name, + domain: view.dataset.domain, + action_id: action.id, + share_url_template: share_url_template, + }, function(result) { + var share_id = result.result; + console.log('share_id', share_id); + + var step1 = Share.call('go_step_1', [[share_id],], function(result) { + var action = result; + console.log('step1', action); + self.do_action(action); + }); + }); + + }, + +}); + +}; diff --git a/addons/share/web/__init__.py b/addons/share/web/__init__.py deleted file mode 100644 index f95bb222c10..00000000000 --- a/addons/share/web/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -import controllers -import editors \ No newline at end of file diff --git a/addons/share/web/controllers.py b/addons/share/web/controllers.py deleted file mode 100644 index e682c8d9709..00000000000 --- a/addons/share/web/controllers.py +++ /dev/null @@ -1,49 +0,0 @@ -import urlparse -import cherrypy - -from openobject import rpc -from openobject.tools import expose, ast - -import openerp.controllers - - - -class ShareWizardController(openerp.controllers.SecuredController): - _cp_path = "/share" - - @expose() - def index(self, domain, context, view_id, search_domain='[]', action_id=None): - context = ast.literal_eval(context) - - if not action_id: - # This should not be needed anymore, but just in case users are - # running the module with an older version of the web client... - - # to remove soon-ish - action_id = rpc.RPCProxy('ir.actions.act_window').search( - [('view_id','=',int(view_id))], context=context) - if not action_id: return "" - - action_id = action_id[0] - - domain = ast.literal_eval(domain) - domain.extend(ast.literal_eval(search_domain)) - - scheme, netloc, _, _, _ = urlparse.urlsplit(cherrypy.request.base) - share_root_url = urlparse.urlunsplit(( - scheme, netloc, '/openerp/login', - 'db=%(dbname)s&user=%(login)s&password=%(password)s', '')) - - context.update( - #active_ids=share_wiz_id, - #active_id=share_wiz_id[0], - _terp_view_name='Share Wizard', - share_root_url=share_root_url) - Share = rpc.RPCProxy('share.wizard') - sharing_view_id = Share.create({ - 'domain': str(domain), - 'action_id': action_id and int(action_id) - }, context) - return openerp.controllers.actions.execute( - Share.go_step_1([sharing_view_id], context), - ids=[sharing_view_id], context=context) diff --git a/addons/share/web/editors.py b/addons/share/web/editors.py deleted file mode 100644 index 677de4a8317..00000000000 --- a/addons/share/web/editors.py +++ /dev/null @@ -1,94 +0,0 @@ -# -*- coding: utf-8 -*- -import openobject.templating - -class FormEditor(openobject.templating.TemplateEditor): - templates = ['/openerp/controllers/templates/form.mako'] - MAIN_FORM_BODY = u'id="main_form_body"' - - def insert_share_button(self, output): - # Insert the share button on the form title H1 line, at the very end, - # but only if the user is a member of the sharing group - share_opener_insertion = output.index('% endif', output.index( - '/view_diagram/process', - output.index(self.MAIN_FORM_BODY))) + len('% endif') - return output[:share_opener_insertion] + ''' - <% - if 'has_share' not in cp.session: - cp.session['has_share'] = rpc.RPCProxy('share.wizard').has_share() - %> - % if cp.session['has_share'] and buttons.toolbar and not is_dashboard: - - - - - \n - % endif -''' + output[share_opener_insertion:] - - def edit(self, template, template_text): - return self.insert_share_button( - super(FormEditor, self).edit(template, template_text)) - - -class SidebarEditor(openobject.templating.TemplateEditor): - templates = ['/openerp/widgets/templates/sidebar.mako'] - ADD_SHARE_SECTION = u'id="sidebar"' - - def insert_share_link(self, output): - # Insert the link on the line, right after the link to open the - # attachment form, but only if the user is a member of the sharing group - share_opener_insertion = output.index( - '\n', - output.index(self.ADD_SHARE_SECTION)) + 1 - return output[:share_opener_insertion] + ''' - <% - if 'has_share' not in cp.session: - cp.session['has_share'] = rpc.RPCProxy('share.wizard').has_share() - %> - % if cp.session['has_share']: -

${_("Sharing")}

- - - \n - % endif -''' + output[share_opener_insertion:] - - def edit(self, template, template_text): - return self.insert_share_link( - super(SidebarEditor, self).edit(template, template_text))