[FIX] Improved share action method,share url and passed active db in email.
bzr revid: vda@tinyerp.com-20101115103706-vhkrxbnrw73sljmr
This commit is contained in:
parent
988ad9ccc9
commit
15f8f81e05
|
@ -48,7 +48,6 @@
|
|||
'wizard/share_wizard_view.xml'
|
||||
],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
'web': True,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,37 +1,33 @@
|
|||
import urlparse
|
||||
from openobject.tools import expose, ast
|
||||
from openerp.controllers import actions
|
||||
from openerp.utils import rpc
|
||||
|
||||
import openerp.controllers
|
||||
import cherrypy
|
||||
|
||||
from openobject.tools import expose, ast
|
||||
import openerp.controllers
|
||||
from openerp.controllers import actions
|
||||
from openerp.utils import rpc, TinyDict
|
||||
|
||||
|
||||
class Piratepad(openerp.controllers.SecuredController):
|
||||
_cp_path = "/share"
|
||||
|
||||
@expose()
|
||||
def index(self, **kw):
|
||||
domain = ast.literal_eval(kw['domain'])
|
||||
search_domain = ast.literal_eval(kw['search_domain'])
|
||||
filter_domain = ast.literal_eval(kw['filter_domain'])
|
||||
|
||||
context = ast.literal_eval(kw['context'])
|
||||
view_name = context.get('_terp_view_name')
|
||||
|
||||
def index(self, domain, search_domain, context, name):
|
||||
domain = ast.literal_eval(domain)
|
||||
search_domain = ast.literal_eval(search_domain)
|
||||
domain.extend(search_domain)
|
||||
|
||||
action_id = rpc.RPCProxy('ir.actions.actions').search([('name','=',view_name)], 0, 0, 0, context)
|
||||
if action_id:
|
||||
action_id = action_id[0]
|
||||
|
||||
model = 'share.wizard'
|
||||
proxy = rpc.RPCProxy(model)
|
||||
|
||||
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'})
|
||||
data = {'domain': str(domain), 'action_id':action_id}
|
||||
id = proxy.create(data, context)
|
||||
res = rpc.session.execute('object', 'execute', model, 'go_step_1', [id], context)
|
||||
return actions.execute(res, ids=[id])
|
||||
|
||||
context = ast.literal_eval(context)
|
||||
view_name = context.get('_terp_view_name') or name
|
||||
if view_name:
|
||||
action_id = rpc.RPCProxy('ir.actions.actions').search([('name','=',view_name)], 0, 0, 0, context)
|
||||
if action_id:
|
||||
action_id = action_id[0]
|
||||
share_model = 'share.wizard'
|
||||
share_root_url = cherrypy.config.get('server.socket_host') + ':' + str(cherrypy.config.get('server.socket_port'))
|
||||
|
||||
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)
|
||||
|
||||
|
|
|
@ -12,24 +12,20 @@ class SidebarTemplateEditor(openobject.templating.TemplateEditor):
|
|||
'\n',
|
||||
output.index(self.ADD_SHARE_BUTTON)) + 1
|
||||
output = output[:form_opener_insertion] + \
|
||||
'''<div id="share-wizard" class="sideheader-a"><h2>${_("Share View")}</h2></div>
|
||||
'''<div id="share-wizard" class="sideheader-a"><h2>${_("Sharing")}</h2></div>
|
||||
<ul class="clean-a">
|
||||
<li>
|
||||
<a id="share_view" href="javascript: void(0)"
|
||||
style="right: 36px;"
|
||||
>${_("Share")}</a>
|
||||
<a id="sharing" href="#share">${_("Share")}</a>
|
||||
</li>
|
||||
</ul>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function() {
|
||||
jQuery('#share_view').click(function(){
|
||||
var _view_type = jQuery('#_terp_view_type').val();
|
||||
$share = jQuery('#sharing').click(function(){
|
||||
var _domain = jQuery('#_terp_domain').val();
|
||||
var _search_domain = jQuery('#_terp_search_domain').val();
|
||||
var _filter_domain = jQuery('#_terp_filter_domain').val();
|
||||
var _context = jQuery('#_terp_context').val();
|
||||
var url = openobject.http.getURL('/share', {view_type: _view_type, domain: _domain, search_domain: _search_domain, filter_domain : _filter_domain, context: _context});
|
||||
window.open(url);
|
||||
var _view_name = jQuery('#_terp_string').val();
|
||||
window.open(openobject.http.getURL('/share', {domain: _domain, search_domain: _search_domain, context: _context, name: _view_name}));
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
@ -41,4 +37,4 @@ class SidebarTemplateEditor(openobject.templating.TemplateEditor):
|
|||
output = super(SidebarTemplateEditor, self).edit(template, template_text)
|
||||
|
||||
output = self.insert_share_link(output)
|
||||
return output
|
||||
return output
|
||||
|
|
|
@ -427,6 +427,7 @@ class share_create(osv.osv_memory):
|
|||
body += _("You may use the following login and password to get access to this protected area:") + "\n"
|
||||
body += "%s: %s" % (_("Username"), result_line.login) + "\n"
|
||||
body += "%s: %s" % (_("Password"), result_line.password) + "\n"
|
||||
body += "%s: %s" % (_("Database"), cr.dbname) + "\n"
|
||||
else:
|
||||
body += _("This additional data has been automatically added to your current access.\n")
|
||||
body += _("You may use your existing login and password to view it. As a reminder, your login is %s.\n") % result_line.login
|
||||
|
|
Loading…
Reference in New Issue