Xavier (Open ERP) has proposed merging 
lp:~openerp-dev/openobject-server/trunk-client-actions-xmo into 
lp:openobject-server.

Requested reviews:
  Olivier Dony (OpenERP) (odo)
  Vo Minh Thu (OpenERP) (vmt-openerp)
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-client-actions-xmo/+merge/66609

This proposal adds "client actions" to the server: a very simple description 
which will be almost entirely managed on the client side (with the client 
interpreting the action liberally, or ignoring it altogether).

This is necessary to several features of the new web client, correct behavior 
of the POS (which should open as fullscreen as possible and with as little 
chrome — from the browser and the web client — as possible) for instance. An 
other use case are actions which are not attached to OpenERP models (either 
cross-models, or simply not directly relevant to openerp objects) or which 
would require quite disgusting hacks in/of openerp models and widgets 
(composing a web-6.0-style home page from a dashboard for instance).

This merge proposal contains the following:
* Addition of an `ir.actions.client` action type (along with the creation of a 
skeleton in the db, due to requirements of postgres table inheritance). This 
action has the following attributes (apart from the usual type, name and 
?usage? inherited from `ir.actions.actions`):
  - tag, which is required, is the client-side of the action type. It is 
arbitrary and meaningless as far as the server is concerned, and the client can 
do whatever it wants with it
  - kwargs, which is optional and a Python dictionary (a live object)
        it's exactly as its name describes: a keyword arguments dictionary 
provided to the client along with the action tag, e.g. in order to customize 
the behavior of a generic client action
  - kwargs_store, which is the backing serialization store for the kwargs 
function field.
        currently, it serializes kwargs using repr & literal_eval, to ensure no 
data is retrieved which could not be sent over xmlrpc or converted into 
javascript).
* Addition of that action type to the possibilities for `ir.ui.menu`'s action 
related field, so client actions can be invoked directly from menus.

Support for client actions in the web client (as well as the implementation of 
a client action) has been added in the following branch:
    https://code.launchpad.net/~openerp-dev/openerp-web/trunk-client-actions-xmo
The client action implemented in the web client has been added to the 
administration dashboard in this branch of the addons:
    
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-client-actions-xmo
-- 
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-client-actions-xmo/+merge/66609
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-server/trunk-client-actions-xmo.
=== modified file 'openerp/addons/base/base.sql'
--- openerp/addons/base/base.sql	2011-05-23 13:21:53 +0000
+++ openerp/addons/base/base.sql	2011-07-01 13:40:18 +0000
@@ -106,6 +106,11 @@
 )
 INHERITS (ir_actions);
 
+CREATE TABLE ir_act_client (
+    primary key(id)
+)
+INHERITS (ir_actions);
+
 
 CREATE TABLE ir_ui_view (
     id serial NOT NULL,

=== modified file 'openerp/addons/base/ir/ir_actions.py'
--- openerp/addons/base/ir/ir_actions.py	2011-04-01 12:48:52 +0000
+++ openerp/addons/base/ir/ir_actions.py	2011-07-01 13:40:18 +0000
@@ -18,20 +18,21 @@
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
-
-from osv import fields,osv
-from tools.safe_eval import safe_eval as eval
-import tools
-import time
-from tools.config import config
-from tools.translate import _
-import netsvc
+import ast
+import copy
 import logging
+import os
 import re
-import copy
-import os
+import time
+import tools
 from xml import dom
+
+import netsvc
+from osv import fields,osv
 from report.report_sxw import report_sxw, report_rml
+from tools.config import config
+from tools.safe_eval import safe_eval as eval
+from tools.translate import _
 
 class actions(osv.osv):
     _name = 'ir.actions.actions'
@@ -842,5 +843,42 @@
 
 ir_actions_todo()
 
+class act_client(osv.osv):
+    _name = 'ir.actions.client'
+    _inherit = 'ir.actions.actions'
+    _table = 'ir_act_client'
+    _sequence = 'ir_actions_id_seq'
+    _order = 'name'
+
+    def _get_kwargs(self, cr, uid, ids, field_name, arg, context):
+        return dict([
+            ((record.id, ast.literal_eval(record.kwargs_store))
+             if record.kwargs_store else (record.id, False))
+            for record in self.browse(cr, uid, ids, context=context)
+        ])
+
+    def _set_kwargs(self, cr, uid, ids, field_name, field_value, arg, context):
+        assert isinstance(field_value, dict), "kwargs can only be dictionaries"
+        for record in self.browse(cr, uid, ids, context=context):
+            record.write({field_name: repr(field_value)})
+
+    _columns = {
+        'tag': fields.char('Client action tag', size=64, required=True,
+                           help="An arbitrary string, interpreted by the client"
+                                " according to its own needs and wishes. There "
+                                "is no central tag repository across clients."),
+        'kwargs': fields.function(_get_kwargs, fnct_inv=_set_kwargs,
+                                  type='binary', method=True,
+                                  string="Supplementary arguments",
+                                  help="Arguments sent to the client along with"
+                                       "the view tag"),
+        'kwargs_store': fields.binary("Kwargs storage", readonly=True)
+    }
+    _defaults = {
+        'type': 'ir.actions.client',
+
+    }
+act_client()
+
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 

=== modified file 'openerp/addons/base/ir/ir_ui_menu.py'
--- openerp/addons/base/ir/ir_ui_menu.py	2011-04-20 15:27:18 +0000
+++ openerp/addons/base/ir/ir_ui_menu.py	2011-07-01 13:40:18 +0000
@@ -273,6 +273,7 @@
                 ('ir.actions.wizard', 'ir.actions.wizard'),
                 ('ir.actions.url', 'ir.actions.url'),
                 ('ir.actions.server', 'ir.actions.server'),
+                ('ir.actions.client', 'ir.actions.client'),
             ]),
     }
 

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to