@@ -106,7 +106,7 @@
tree,calendar
[('state','!=','done')]
-
+ {}
diff --git a/addons/report_webkit/header_view.xml b/addons/report_webkit/header_view.xml
index 30407f89385..833e813ba4e 100644
--- a/addons/report_webkit/header_view.xml
+++ b/addons/report_webkit/header_view.xml
@@ -48,7 +48,8 @@
form
tree,form
-
+
+
-
+
diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py
index eac1f163cf6..5a5226cef81 100644
--- a/addons/website/controllers/main.py
+++ b/addons/website/controllers/main.py
@@ -378,20 +378,25 @@ class Website(openerp.addons.web.controllers.main.Home):
#------------------------------------------------------
# Server actions
#------------------------------------------------------
- @http.route(['/website/action/'], type='http', auth="public", website=True)
- def actions_server(self, id_or_xml_id, **post):
+
+ @http.route('/website/action/', type='http', auth="public", website=True)
+ def actions_server(self, path_or_xml_id_or_id, **post):
cr, uid, context = request.cr, request.uid, request.context
res, action_id, action = None, None, None
ServerActions = request.registry['ir.actions.server']
- # find the action_id, either an int, an int into a basestring, or an xml_id
- if isinstance(id_or_xml_id, basestring) and '.' in id_or_xml_id:
- action_id = request.registry['ir.model.data'].xmlid_to_res_id(request.cr, request.uid, id_or_xml_id, raise_if_not_found=False)
- else:
+ # find the action_id: either an xml_id, the path, or an ID
+ if isinstance(path_or_xml_id_or_id, basestring) and '.' in path_or_xml_id_or_id:
+ action_id = request.registry['ir.model.data'].xmlid_to_res_id(request.cr, request.uid, path_or_xml_id_or_id, raise_if_not_found=False)
+ if not action_id:
+ action_ids = ServerActions.search(cr, uid, [('website_path', '=', path_or_xml_id_or_id), ('website_published', '=', True)], context=context)
+ action_id = action_ids and action_ids[0] or None
+ if not action_id:
try:
- action_id = int(id_or_xml_id)
+ action_id = int(path_or_xml_id_or_id)
except ValueError:
pass
+
# check it effectively exists
if action_id:
action_ids = ServerActions.exists(cr, uid, [action_id], context=context)
diff --git a/addons/website/data/website_demo.xml b/addons/website/data/website_demo.xml
index a7fa4d76a07..6f37b871100 100644
--- a/addons/website/data/website_demo.xml
+++ b/addons/website/data/website_demo.xml
@@ -43,6 +43,7 @@
Website Partner Post and Thanks Demo
True
+ partner_thanks
partner_id, partner = False, None
@@ -118,6 +119,7 @@ response = request.website.render("website.template_partner_post", values)
Website Partners Comment Form
True
+ partner_comment
partner_ids = pool['res.partner'].search(cr, uid, [('customer', '=', True)], context=context)
diff --git a/addons/website/models/ir_actions.py b/addons/website/models/ir_actions.py
index 731ee4c47e6..5f627eec54a 100644
--- a/addons/website/models/ir_actions.py
+++ b/addons/website/models/ir_actions.py
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
+import urlparse
+
from openerp.addons.web.http import request
from openerp.osv import fields, osv
@@ -9,15 +11,43 @@ class actions_server(osv.Model):
_name = 'ir.actions.server'
_inherit = ['ir.actions.server']
+ def _compute_website_url(self, cr, uid, id, website_path, xml_id, context=None):
+ base_url = self.pool['ir.config_parameter'].get_param(cr, uid, 'web.base.url', context=context)
+ link = website_path or xml_id or (id and '%d' % id) or ''
+ if base_url and link:
+ path = '%s/%s' % ('/website/action', link)
+ return '%s' % urlparse.urljoin(base_url, path)
+ return ''
+
+ def _get_website_url(self, cr, uid, ids, name, args, context=None):
+ res = dict.fromkeys(ids, False)
+ for action in self.browse(cr, uid, ids, context=context):
+ if action.state == 'code' and action.website_published:
+ res[action.id] = self._compute_website_url(cr, uid, action.id, action.website_path, action.xml_id, context=context)
+ return res
+
_columns = {
+ 'xml_id': fields.function(
+ osv.osv.get_xml_id, type='char', string="External ID",
+ help="ID of the action if defined in a XML file"),
+ 'website_path': fields.char('Website Path'),
+ 'website_url': fields.function(
+ _get_website_url, type='char', string='Website URL',
+ help='The full URL to access the server action through the website.'),
'website_published': fields.boolean(
'Available on the Website',
help='A code server action can be executed from the website, using a dedicated'
- 'controller. The address is /website/action/.'
+ 'controller. The address is /website/action/.'
'Set this field as True to allow users to run this action. If it'
'set to is False the action cannot be run through the website.'),
}
+ def on_change_website_path(self, cr, uid, ids, website_path, xml_id, context=None):
+ values = {
+ 'website_url': self._compute_website_url(cr, uid, ids[0], website_path, xml_id, context=context)
+ }
+ return {'value': values}
+
def _get_eval_context(self, cr, uid, action, context=None):
""" Override to add the request object in eval_context. """
eval_context = super(actions_server, self)._get_eval_context(cr, uid, action, context=context)
diff --git a/addons/website/views/ir_actions.xml b/addons/website/views/ir_actions.xml
index 0b017a43192..0573c87af31 100644
--- a/addons/website/views/ir_actions.xml
+++ b/addons/website/views/ir_actions.xml
@@ -6,10 +6,43 @@
ir.actions.server.form.website
ir.actions.server
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ir.actions.server.tree.website
+ ir.actions.server
+
+
+
+
+
+
+
+
+
+ ir.actions.server.search.website
+ ir.actions.server
+
-
+