From 0280a5f390a78360a3906ddf7f24f67efe60305f Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Tue, 28 Apr 2015 11:49:47 +0200 Subject: [PATCH] [FIX] fields: do not infer a related field to be required Forcing a related field to be required causes some issues. Having such a field in a one2many relation may block the creation of records in the field, as the main record does not exist yet, and the field has no value. It may also cause trouble if the field is stored: being required constrains the corresponding column to be NOT NULL. Inserting a row will fail, because related fields are currently determined *after* the row insertion. --- openerp/fields.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/openerp/fields.py b/openerp/fields.py index 75e63e8879c..c5f93a4a63a 100644 --- a/openerp/fields.py +++ b/openerp/fields.py @@ -494,12 +494,10 @@ class Field(object): # determine the chain of fields, and make sure they are all set up recs = env[self.model_name] - fields = [] for name in self.related: field = recs._fields[name] field.setup(env) recs = recs[name] - fields.append(field) self.related_field = field @@ -529,10 +527,6 @@ class Field(object): if not self.states and self.inherited: self.states = field.states - # special case for required: check if all fields are required - if not self.store and not self.required: - self.required = all(field.required for field in fields) - def _compute_related(self, records): """ Compute the related field `self` on `records`. """ # when related_sudo, bypass access rights checks when reading values