

def form2obj(self, ar, instance, post_data, is_new):
    "\n        Test cases:\n        - setting a CharField to ''\n        - sales.Invoice.number may be blank\n        "
    v = self.extract_form_data(post_data)
    if (v is None):
        return
    if (v == ''):
        if self.field.empty_strings_allowed:
            v = self.parse_form_value(v, instance)
        else:
            v = self.form2obj_default
    else:
        v = self.parse_form_value(v, instance)
    if ((not is_new) and self.field.primary_key and (instance.pk is not None)):
        if (instance.pk == v):
            return
        raise exceptions.ValidationError({
            self.field.name: (_('Existing primary key value %r may not be modified.') % instance.pk),
        })
    return self.set_value_in_object(ar, instance, v)

dataset/ETHPy150Open lsaffre/lino/lino/core/store.py StoreField.form2obj/original