In odoo8 we use Computed fields. For more you can refer : https://www.odoo.com/documentation/8.0/howtos/backend.html#computed-fields-and-default-values
name = fields.Char(compute='_compute_name')
for record in self:
record.name = str(random.randint(1, 1e6))
In odoo 8 functional field is replaced by computed field.
To create a computed field, create a field and set its attribute compute to the name of a method.
The computation method should simply set the value of the field to compute on every record in self.
Here is the simple example.
name = fields.Char(compute='_get_value', string='Name')
value = fields.Char(string='Value')
self.name = "Value of name is %s" % self.value
@api.depends('value') decorator specifies the dependency on the 'value' field.
and it is used by the ORM to trigger recomputation of the field.
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
|Asked: 1/1/15, 11:50 PM|
|Seen: 8380 times|
|Last updated: 4/27/16, 3:54 AM|