From 59638e9dbe7d1f7581fd85f937ca30f593a2b670 Mon Sep 17 00:00:00 2001 From: Bertrand Chenal Date: Mon, 6 Oct 2008 14:40:59 +0200 Subject: [PATCH] Added doc about Function field --- doc/models.rst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/doc/models.rst b/doc/models.rst index 5149515694..0a61a8d741 100644 --- a/doc/models.rst +++ b/doc/models.rst @@ -409,6 +409,25 @@ used in the method definition, hence adapting the way the method is called. +Another way to tackle Function implementation is to pass a dictionary +to the ``args`` argument on the field definition. It will be forwarded +to the function call: + +.. highlight:: python + +:: + + state = fields.Function( + 'get_state', type='selection', string='Total Service', + args={'key':'value'}, + selection=[('draft','Draft'),('done','Done')], + ) + + def get_state(self, cursor, user, ids, names, arg, context=None): + # [...] + if arg.get('key'): + pass # do something with 'value' + Search on function fields `````````````````````````