I receive an exception when trying to read the Access rights of some Odoo Users (res.users) : Not implemented json mapping value: '$\"sel_groups_9_18_10\": 10' to Nullable
After careful check, it looks like the mapping are correct : there is a .NET property with the correct JsonProperty attribute and the Enum has the corresponding value 10.
I tried both with Nullable property and non Nullable and it both fails.
Note that those Enum mapping work perfectly on dozens of other fields.
The .NET property
[JsonProperty("sel_groups_9_18_10")]
public SalesResUsersOdoo11Enum? SelGroups91810 { get; set; }
Note that the value 10 in the Exception is the 4th EnumMember Value of the SalesResusersOdooEnum enum.
Exception Details
System.Exception: Not implemented json mapping value: '$\"sel_groups_9_18_10\": 10' to Nullable`1\n at PortaCapena.OdooJsonRpcClient.Converters.OdooModelMapper.ConverOdooPropertyToDotNet(Type dotnetType, JToken value, Object& result)\n at PortaCapena.OdooJsonRpcClient.Converters.OdooModelConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\n at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)\n at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)\n at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)\n at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)\n at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)\n at PortaCapena.OdooJsonRpcClient.OdooClient.CallAndDeserializeAsync[T](OdooRequestModel request, CancellationToken cancellationToken), \n "
Possible solution
My guess is that in OdooModelMapper.ConverOdooPropertyToDotNet switch, there should be branches for JTokenType.Integer similar to the following JTokenType.String branches :
case JTokenType.String when dotnetType.IsEnum:
// ...
case JTokenType.String when dotnetType.IsGenericType && dotnetType.GetGenericTypeDefinition() == typeof(Nullable<>) && dotnetType.GenericTypeArguments.Length == 1 && dotnetType.GenericTypeArguments[0].IsEnum:
// ...
I receive an exception when trying to read the Access rights of some Odoo Users (res.users) :
Not implemented json mapping value: '$\"sel_groups_9_18_10\": 10' to Nullable
After careful check, it looks like the mapping are correct : there is a .NET property with the correct JsonProperty attribute and the Enum has the corresponding value
10
. I tried both with Nullable property and non Nullable and it both fails.Note that those Enum mapping work perfectly on dozens of other fields.
The .NET property
The .NET enum
Note that the value
10
in the Exception is the 4th EnumMember Value of theSalesResusersOdooEnum
enum.Exception Details
System.Exception: Not implemented json mapping value: '$\"sel_groups_9_18_10\": 10' to Nullable`1\n at PortaCapena.OdooJsonRpcClient.Converters.OdooModelMapper.ConverOdooPropertyToDotNet(Type dotnetType, JToken value, Object& result)\n at PortaCapena.OdooJsonRpcClient.Converters.OdooModelConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\n at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)\n at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)\n at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)\n at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)\n at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)\n at PortaCapena.OdooJsonRpcClient.OdooClient.CallAndDeserializeAsync[T](OdooRequestModel request, CancellationToken cancellationToken), \n "
Possible solution
My guess is that in
OdooModelMapper.ConverOdooPropertyToDotNet
switch, there should be branches forJTokenType.Integer
similar to the followingJTokenType.String
branches :Environment
.NET 6 on Mac M1 Odoo v11