Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Drop None meta fields as it is not nullable

Maciej Korycinskic737a5690f48
diff --git a/saleor/plugins/avatax/plugin.py b/saleor/plugins/avatax/plugin.py
index 05c5084a4d..8068e38cb4 100644
--- a/saleor/plugins/avatax/plugin.py
+++ b/saleor/plugins/avatax/plugin.py
@@ -398,8 +398,13 @@ class AvataxPlugin(BasePlugin):
if not self.active:
return previous_value
+ if tax_code is None and obj.pk:
+ obj.delete_value_from_metadata(META_CODE_KEY)
+ obj.delete_value_from_metadata(META_DESCRIPTION_KEY)
+ return
+
codes = get_cached_tax_codes_or_fetch(self.config)
- if tax_code and tax_code not in codes:
+ if tax_code not in codes:
return
tax_description = codes.get(tax_code)
diff --git a/saleor/plugins/vatlayer/plugin.py b/saleor/plugins/vatlayer/plugin.py
index 678c08c731..d1d1f3dcf0 100644
--- a/saleor/plugins/vatlayer/plugin.py
+++ b/saleor/plugins/vatlayer/plugin.py
@@ -244,7 +244,12 @@ class VatlayerPlugin(BasePlugin):
if not self.active:
return previous_value
- if tax_code and tax_code not in dict(TaxRateType.CHOICES):
+ if tax_code is None and obj.pk:
+ obj.delete_value_from_metadata(self.META_CODE_KEY)
+ obj.delete_value_from_metadata(self.META_DESCRIPTION_KEY)
+ return
+
+ if tax_code not in dict(TaxRateType.CHOICES):
return previous_value
tax_item = {self.META_CODE_KEY: tax_code, self.META_DESCRIPTION_KEY: tax_code}