diff --git a/openerp/addons/base/ir/ir_model_view.xml b/openerp/addons/base/ir/ir_model_view.xml index 2b016e954dd..904ba7b4f5c 100644 --- a/openerp/addons/base/ir/ir_model_view.xml +++ b/openerp/addons/base/ir/ir_model_view.xml @@ -109,6 +109,31 @@ +

How to define a computed field

+

Computed fields are defined with the fields + Dependencies and Compute.

+

The field Dependencies lists the fields that + the current field depends on. It is a comma-separated list of + field names, like name, size. You can also refer to + fields accessible through other relational fields, for instance + partner_id.company_id.name.

+

The field Compute is the Python code to + compute the value of the field on a set of records. The value of + the field must be assigned to each record with a dictionary-like + assignment.

+
+    for record in self:
+        record['size'] = len(record.name)
+
+

The only predefined variables are

+ +

Other features are accessible through self, like + self.env, etc.

@@ -247,6 +272,31 @@ +

How to define a computed field

+

Computed fields are defined with the fields + Dependencies and Compute.

+

The field Dependencies lists the fields that + the current field depends on. It is a comma-separated list of + field names, like name, size. You can also refer to + fields accessible through other relational fields, for instance + partner_id.company_id.name.

+

The field Compute is the Python code to + compute the value of the field on a set of records. The value of + the field must be assigned to each record with a dictionary-like + assignment.

+
+    for record in self:
+        record['size'] = len(record.name)
+
+

The only predefined variables are

+
    +
  • self (the set of records to compute)
  • +
  • datetime (Python module)
  • +
  • dateutil (Python module)
  • +
  • time (Python module)
  • +
+

Other features are accessible through self, like + self.env, etc.