diff --git a/libgnucash/app-utils/gnc-option-impl.cpp b/libgnucash/app-utils/gnc-option-impl.cpp index 92f60c29cd..f339eabf35 100644 --- a/libgnucash/app-utils/gnc-option-impl.cpp +++ b/libgnucash/app-utils/gnc-option-impl.cpp @@ -27,7 +27,7 @@ #include #include #include - +#include extern "C" { #include "gnc-accounting-period.h" @@ -440,6 +440,16 @@ GncOptionValue::serialize() const noexcept static const std::string no_value{"No Value"}; if constexpr(std::is_same_v) return m_value ? qof_instance_to_string(m_value) : no_value; + if constexpr(std::is_same_v) + { + if (!m_value) + return no_value; + auto guid{qof_instance_to_string(qofOwnerGetOwner(m_value))}; + auto type{qofOwnerGetType(m_value)}; + std::ostringstream ostr{}; + ostr << type << " " << guid; + return ostr.str(); + } else if constexpr(is_same_decayed_v) return m_value; else if constexpr(is_same_decayed_v) @@ -455,6 +465,14 @@ GncOptionValue::deserialize(const std::string& str) noexcept { if constexpr(std::is_same_v) set_value(qof_instance_from_string(str, get_ui_type())); + if constexpr(std::is_same_v) + { + std::istringstream istr{str}; + std::string type, guid; + istr >> type >> guid; + auto inst{qof_instance_from_string(guid, get_ui_type())}; + qofOwnerSetEntity(const_cast(m_value), inst); + } else if constexpr(is_same_decayed_v) set_value(str); else if constexpr(is_same_decayed_v) diff --git a/libgnucash/app-utils/gnc-optiondb.i b/libgnucash/app-utils/gnc-optiondb.i index 334bb5d112..769e1d6ed7 100644 --- a/libgnucash/app-utils/gnc-optiondb.i +++ b/libgnucash/app-utils/gnc-optiondb.i @@ -1069,7 +1069,11 @@ inline SCM return_scm_value(ValueType value) if constexpr (is_same_decayed_v>) { - return scm_from_utf8_string("Not Yet Implemented"); + auto value{option.get_value()}; + auto guid{scm_from_utf8_string(qof_instance_to_string(qofOwnerGetOwner(value)).c_str())}; + auto type{scm_from_long(gncOwnerGetType(value))}; + return scm_simple_format(SCM_BOOL_F, ticked_format_str, + scm_list_1(scm_cons(type, guid))); } if constexpr (is_QofQueryValue_v) {