Function fields in OpenERP:
A functional field is a field whose value is calculated by a function and Fields that do not directly store into the DB but compute their value instead
Parameters:
fnct, arg=None, fnct_inv=None, fnct_inv_arg=None, type="float",
fnct_search=None, obj=None, method=False, store=False, multi=False
Here
- fnct is the function or method that will compute the field value. It should be declared before declaration of the functional field.
- fnct_inv is the function or method which will allow writing values in that field.
- type is the field type name returned by the function. It can be any field type name except function.
- fnct_search allows you to define the searching behavior on that field.
- method whether the field is computed by a method (of an object) or a global function
- store If you want to store field in database or not. Default is False.
- multi is a group name. All fields with the same multi parameter will be calculated in a single function call.
Example
'testrest':fields.function(get_reste, store=True, string='Restant',type='integer'),
def get_reste(self, cr, uid, ids, field_name, arg, context):
x = {}
for record in self.browse(cr, uid, ids ,context):
if record.statut != 'entree':
x[record.id]= record.testrest + record.entree_nbr
return x
0 Comment(s)