Skip to Content
Menu
This question has been flagged
1 Reply
938 Views

I tried several auto-generation SKU addons and I'm really surprised at the low quality of addons - from spelling mistakes to functionality that just doesn't make sense. 


I needed to ensure that every time the SKUs are generated, they're the same for existing products and strip spaces and special characters out from product names and variants.


For example, using [product]-[variant]-[category]-[product id]

Product: Floral Bliss Subscription
Variant: 1 Month, 2 Months, 3 Months
Category: Subscriptions
ProductID: ...

Should be: Flor-1Mo-Subs-###


Similar for coupon products, i.e.: 10% Off, Discounts should be  10-Disc-###


The issue I found with a few is that they don't strip spaces or special characters, which really surprised me.


Quick Review

This serves as a quick review of a few I tried to save others time and identify possible issues.


Auto Product SKU Generator App by Edge Technologies

  • This one generates its own product ID numbers that change every time they're generated
  • Maybe there's a case for this one:  Every time you regenerate your product SKUs, an internal counter re-numbers all of your products.  So when your product SKU was PROD1-100, next time you regenerate it's PRODU1-593 or similar.  This one generates its own product ID numbers that change
  • Does not strip spaces nor special characters out from product names

Auto Generate Product Code(Sku/Internal Reference) by BrowseInfo

  • Simple, straight forward setup and instruction video
  • Uses Odoo product numbers rather than creating their own
  • Regenerated SKUs are always the same
  • Does not strip spaces and special characters
Avatar
Discard

Third-party add-ons do tend to be "cheap and cheerful" (at best). Both of these cost around $10.

Author Best Answer

Since Auto Generate Product Code(Sku/Internal Reference) by BrowseInfo was the closest to what I needed, I updated the poduct_sku_config.py to strip out spaces and special characters.


Where:

string+=product.name[0:count]
string+=att.name[0:count]
string+=product.categ_id.name[0:count]

# Replace with:
string += ''.join(letter for letter in product.name[0:count] if letter.isalnum()) + "-"
string += ''.join(letter for letter in att.name[0:count] if letter.isalnum()) + "-"
string += ''.join(letter for letter in product.categ_id.name[0:count] if letter.isalnum()) + "-"

There may be a better way of doing this, but this worked for me. 


I'm curious to know of cases where you want those special characters and spaces in your SKUs.


Hope this helps.

Avatar
Discard
Related Posts Replies Views Activity
2
Jun 23
2341
0
May 19
2144
0
Mar 15
60
0
Mar 15
2780
1
Mar 15
2853