Skip to content

Commit

Permalink
[FIX] connector_woocommerce: expected string or bytes-like object whe…
Browse files Browse the repository at this point in the history
…n export product without description
  • Loading branch information
FrankC013 committed Oct 10, 2024
1 parent 0a02890 commit 189b440
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
14 changes: 9 additions & 5 deletions connector_woocommerce/models/product_product/export_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,15 @@ def stock(self, record):
return stock

def _get_product_description(self, record):
return tools.color_rgb2hex(
record.with_context(
lang=self.backend_record.language_id.code
).variant_public_description
)
description = record.with_context(
lang=self.backend_record.language_id.code
).variant_public_description
if not description:
raise ValidationError(
_("The product variant {%s} has no variant public description.")
% record.display_name
)
return tools.color_rgb2hex(description)

@mapping
def description(self, record):
Expand Down
28 changes: 18 additions & 10 deletions connector_woocommerce/models/product_template/export_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,26 @@ def sale_price(self, record):
return {"sale_price": None}

def _get_product_description(self, record):
return tools.color_rgb2hex(
record.record.with_context(
lang=self.backend_record.language_id.code
).public_description
)
description = record.with_context(
lang=self.backend_record.language_id.code
).public_description
if not description:
raise ValidationError(
_("The product template %s has no public description")
% record.display_name
)
return tools.color_rgb2hex(description)

def _get_product_variant_description(self, record):
return tools.color_rgb2hex(
record.product_variant_id.with_context(
lang=self.backend_record.language_id.code
).variant_public_description
)
description = record.product_variant_id.with_context(
lang=self.backend_record.language_id.code
).variant_public_description
if not description:
raise ValidationError(
_("The product template %s has no variant public description")
% record.display_name
)
return tools.color_rgb2hex(description)

@mapping
def description(self, record):
Expand Down

0 comments on commit 189b440

Please sign in to comment.