diff --git a/openerp/addons/base/ir/ir_actions.py b/openerp/addons/base/ir/ir_actions.py index c80a20e40e5..eab803bdf24 100644 --- a/openerp/addons/base/ir/ir_actions.py +++ b/openerp/addons/base/ir/ir_actions.py @@ -240,9 +240,9 @@ class act_window(osv.osv): 'name': fields.char('Action Name', size=64, translate=True), 'type': fields.char('Action Type', size=32, required=True), 'view_id': fields.many2one('ir.ui.view', 'View Ref.', ondelete='cascade'), - 'domain': fields.char('Domain Value', size=250, + 'domain': fields.char('Domain Value', help="Optional domain filtering of the destination data, as a Python expression"), - 'context': fields.char('Context Value', size=250, required=True, + 'context': fields.char('Context Value', required=True, help="Context dictionary as Python expression, empty by default (Default: {})"), 'res_id': fields.integer('Record ID', help="Database ID of record to open in form view, when ``view_mode`` is set to 'form' only"), 'res_model': fields.char('Destination Model', size=64, required=True, @@ -285,6 +285,36 @@ class act_window(osv.osv): 'multi': False, } + def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'): + """ call the method get_empty_list_help of the model and set the window action help message + """ + ids_int = isinstance(ids, (int, long)) + if ids_int: + ids = [ids] + results = super(act_window, self).read(cr, uid, ids, fields=fields, context=context, load=load) + + if not fields or 'help' in fields: + context = dict(context or {}) + eval_dict = { + 'active_model': context.get('active_model'), + 'active_id': context.get('active_id'), + 'active_ids': context.get('active_ids'), + 'uid': uid, + } + for res in results: + model = res.get('res_model') + if model and self.pool.get(model): + try: + with tools.mute_logger("openerp.tools.safe_eval"): + eval_context = eval(res['context'] or "{}", eval_dict) or {} + except Exception: + continue + custom_context = dict(context, **eval_context) + res['help'] = self.pool.get(model).get_empty_list_help(cr, uid, res.get('help', ""), context=custom_context) + if ids_int: + return results[0] + return results + def for_xml_id(self, cr, uid, module, xml_id, context=None): """ Returns the act_window object created for the provided xml_id diff --git a/openerp/addons/base/res/res_partner_view.xml b/openerp/addons/base/res/res_partner_view.xml index 9d5f55052d0..88a1266b689 100644 --- a/openerp/addons/base/res/res_partner_view.xml +++ b/openerp/addons/base/res/res_partner_view.xml @@ -10,7 +10,7 @@ - + @@ -420,7 +420,7 @@ - + Customers diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 8529bd8bab6..96e0296884f 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -3538,6 +3538,14 @@ class BaseModel(object): return res + def get_empty_list_help(self, cr, user, help, context=None): + """ Generic method giving the help message displayed when having + no result to display in a list or kanban view. By default it returns + the help given in parameter that is generally the help message + defined in the action. + """ + return help + def check_field_access_rights(self, cr, user, operation, fields, context=None): """ Check the user access rights on the given fields. This raises Access