diff --git a/model.py b/model.py index 9d0699193efd1676cb901117ee3863e2b53df46d_bW9kZWwucHk=..164d8181eccbe2cad4de41dd1f0a4636e61207ca_bW9kZWwucHk= 100644 --- a/model.py +++ b/model.py @@ -35,6 +35,7 @@ NewinstanceType, PostHookConverter, Skip, + SkipType, build_context, ) from .validate import NotInitialized, Validation, Validator @@ -131,8 +132,8 @@ message_value: Any, instance: models.BaseModel, value_present: bool = True, - ) -> dict: - values = OrderedDict() + ) -> dict | SkipType: + values: dict[str, Any] = OrderedDict() if self._type is not None and message_value["__type__"] != self._type: raise Exception( @@ -142,12 +143,10 @@ ) for key in self._converters: value = message_value.get(key, None) if message_value else None - values.update( - self._converters[key].message_to_odoo( - odoo_env, - phase, - value, - instance, - message_value and key in message_value, - ) + attribute_vals = self._converters[key].message_to_odoo( + odoo_env, + phase, + value, + instance, + message_value and key in message_value, ) @@ -153,6 +152,9 @@ ) + if isinstance(attribute_vals, SkipType): + continue + values.update(attribute_vals) if self.merge_with: for conv in self.merge_with: value = conv.message_to_odoo( odoo_env, phase, message_value, instance, value_present ) @@ -154,9 +156,9 @@ if self.merge_with: for conv in self.merge_with: value = conv.message_to_odoo( odoo_env, phase, message_value, instance, value_present ) - if value is Skip: + if isinstance(value, SkipType): continue values.update(value) diff --git a/switch.py b/switch.py index 9d0699193efd1676cb901117ee3863e2b53df46d_c3dpdGNoLnB5..164d8181eccbe2cad4de41dd1f0a4636e61207ca_c3dpdGNoLnB5 100644 --- a/switch.py +++ b/switch.py @@ -90,7 +90,7 @@ message_value: Any, instance: models.BaseModel, value_present: bool = True, - ) -> dict: + ) -> dict | SkipType: for _out_cond, in_cond, converter in self._converters: if in_cond is None or in_cond(message_value): return converter.message_to_odoo(