Hi,
What’s the right way to create a virtual docfield with the Options field?
The documentation
https://frappeframework.com/docs/v14/user/en/basics/virtual_docfield#2-define-a-source-for-the-field
bullet two says
Using the DocField.options
[...]
frappe.utils.now_datetime() - self.creation
The above mentioned Person.full_name example uses Python's f-string feature to achive this in a similar way.
The example uses self
to refer to the document
Just above it there is a screenshot which reads f"{doc.first_name}"
so it uses doc
instead of self
When saving a doctype with a virtual field with either doc or self, Frappe says {self.first_name} is not a valid fieldname pattern. It should be {field_name}.
And in the end Frappe still tries to read the field from the database, saying pymysql.err.OperationalError: (1054, "Unknown column '....full_name' in 'field list'")