From 139c84465582727bd2091233b20c3e89b33eeb94 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 30 Jun 2011 13:51:34 +0200 Subject: [PATCH] [ADD] client action bzr revid: xmo@openerp.com-20110630115134-m5tppqs9whmqtqow --- openerp/addons/base/base.sql | 5 +++ openerp/addons/base/ir/ir_actions.py | 58 +++++++++++++++++++++++----- 2 files changed, 53 insertions(+), 10 deletions(-) diff --git a/openerp/addons/base/base.sql b/openerp/addons/base/base.sql index 17378061b29..54dcc3a55ae 100644 --- a/openerp/addons/base/base.sql +++ b/openerp/addons/base/base.sql @@ -106,6 +106,11 @@ CREATE TABLE ir_act_server ( ) INHERITS (ir_actions); +CREATE TABLE ir_act_client ( + primary key(id) +) +INHERITS (ir_actions); + CREATE TABLE ir_ui_view ( id serial NOT NULL, diff --git a/openerp/addons/base/ir/ir_actions.py b/openerp/addons/base/ir/ir_actions.py index 290eeb36509..c42e43fd051 100644 --- a/openerp/addons/base/ir/ir_actions.py +++ b/openerp/addons/base/ir/ir_actions.py @@ -18,20 +18,21 @@ # along with this program. If not, see . # ############################################################################## - -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 logging -import re +import ast import copy +import logging import os +import re +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 @@ class ir_actions_todo(osv.osv): 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: