I try to make some calculation of fields of my object and store them to a new field. I'm beginning with a simple example of using fileds.function, but when I try to login to openerp, the system raise an error that the user or password is incorrect.
in my class I add the field:
'a' : fields.integer('A'),
'b' : fields.integer('B'),
'total' : fields.function(fnct, method=True, string='Tot',type='integer'),
definition of the function:
def fnct(self, cr, uid, ids, fields, arg, context):
x = {}
for record in self.browse(cr, uid, ids):
x[record.id] = record.a + record.b
return x
Please ,can anyone help me ? thanks
To fix that issue, I check for some intendation and also the definition of my function should be before declaration of fields .
There is no Connection of Function Filed with OpenERP Login.
So It may be possible that you are providing wrong user id or password.
The Main Use of Function Field is:
Auto Calculate Value of the field based on other Fields.
i.e Total = field1 + field2 + field3
Example: 'total' : fields.function(get_total, method=True, string='Total',type='integer'),
How to define Function:
def get_total(self, cr, uid, ids, fields, arg, context):
x={}
for record in self.browse(cr, uid, ids):
x[record.id]= record.field1 + record.field2 + record.field3
return x
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With