diff --git a/addons/share/__openerp__.py b/addons/share/__openerp__.py index 21b63fd3bc1..768d24974a5 100644 --- a/addons/share/__openerp__.py +++ b/addons/share/__openerp__.py @@ -48,6 +48,7 @@ 'wizard/share_wizard_view.xml' ], 'installable': True, + 'web': True, } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/share/web/__init__.py b/addons/share/web/__init__.py new file mode 100644 index 00000000000..f95bb222c10 --- /dev/null +++ b/addons/share/web/__init__.py @@ -0,0 +1,2 @@ +import controllers +import editors \ No newline at end of file diff --git a/addons/share/web/controllers.py b/addons/share/web/controllers.py new file mode 100644 index 00000000000..de44d0ecac3 --- /dev/null +++ b/addons/share/web/controllers.py @@ -0,0 +1,51 @@ +import urlparse + +from openobject.tools import expose, ast +from openerp.controllers import actions +from openerp.utils import rpc + +import openerp.controllers +import cherrypy + + + +class ShareWizardController(openerp.controllers.SecuredController): + _cp_path = "/share" + + @expose() + def index(self, domain, search_domain, context, name): + context = ast.literal_eval(context) + view_name = context.get('_terp_view_name') or name + if not view_name: return + + action_id = rpc.RPCProxy('ir.actions.actions').search( + [('name','=',view_name)], 0, 0, 0, context) + if not action_id: return + + domain = ast.literal_eval(domain) + search_domain = ast.literal_eval(search_domain) + domain.extend(search_domain) + + action_id = action_id[0] + share_model = 'share.wizard' + + 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', '')) + + share_wiz_id = rpc.RPCProxy('ir.ui.menu').search( + [('name','=', 'Share Wizard')]) + context.update( + active_ids=share_wiz_id, + active_id=share_wiz_id[0], + _terp_view_name='Share Wizard', + share_root_url=share_root_url) + sharing_view_id = rpc.RPCProxy(share_model).create({ + 'domain': str(domain), + 'action_id':action_id + }, context) + return actions.execute( + rpc.session.execute('object', 'execute', share_model, '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 new file mode 100644 index 00000000000..d156d40c6b3 --- /dev/null +++ b/addons/share/web/editors.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +import openobject.templating + +class ShareActionEditor(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 + share_opener_insertion = output.index( + '\n', + output.index(self.ADD_SHARE_SECTION)) + 1 + return output[:share_opener_insertion] + \ + '''
+