Cannot 'set only once' for link fields

I have a doctype that has link fields I want to mark with the ‘set only once’ flag set. My intent is to create ‘permanent’ relations that can only be modified by deleting the record.

Unfortunately, while the ‘set only once’ flag is set on the doctype definition I cannot create new records.

Stack trace on create:

Traceback (innermost last):
  File "/vagrant/frappe-bench/apps/frappe/frappe/widgets/form/save.py", line 18, in savedocs
    doc.save()
  File "/vagrant/frappe-bench/apps/frappe/frappe/model/document.py", line 175, in save
    self.insert()
  File "/vagrant/frappe-bench/apps/frappe/frappe/model/document.py", line 145, in insert
    self._validate()
  File "/vagrant/frappe-bench/apps/frappe/frappe/model/document.py", line 257, in _validate
    self._validate_constants()
  File "/vagrant/frappe-bench/apps/frappe/frappe/model/base_document.py", line 343, in _validate_constants
    if self.get(fieldname) != values.get(fieldname):
 AttributeError: 'NoneType' object has no attribute 'get'

Traceback (innermost last):
  File "/vagrant/frappe-bench/apps/frappe/frappe/app.py", line 49, in application
    response = frappe.handler.handle()
  File "/vagrant/frappe-bench/apps/frappe/frappe/handler.py", line 66, in handle
    execute_cmd(cmd)
  File "/vagrant/frappe-bench/apps/frappe/frappe/handler.py", line 89, in execute_cmd
    ret = frappe.call(method, **frappe.form_dict)
  File "/vagrant/frappe-bench/apps/frappe/frappe/__init__.py", line 531, in call
    return fn(*args, **newargs)
  File "/vagrant/frappe-bench/apps/frappe/frappe/widgets/form/save.py", line 18, in savedocs
    doc.save()
  File "/vagrant/frappe-bench/apps/frappe/frappe/model/document.py", line 175, in save
    self.insert()
  File "/vagrant/frappe-bench/apps/frappe/frappe/model/document.py", line 145, in insert
    self._validate()
  File "/vagrant/frappe-bench/apps/frappe/frappe/model/document.py", line 257, in _validate
    self._validate_constants()
  File "/vagrant/frappe-bench/apps/frappe/frappe/model/base_document.py", line 343, in _validate_constants
    if self.get(fieldname) != values.get(fieldname):
 AttributeError: 'NoneType' object has no attribute 'get'

Is this a bug, or intentional? I wouldn’t expect this to be a problem.

1 Like

Seems like a bug, can you post it on GitHub Issues?

Sure
https://github.com/frappe/frappe/issues/959

I also issued a pull request. Hope I did it correctly, I’m new to github