Skip to content

Commit

Permalink
Merge pull request #91 from afkiwers/stock_display_fix
Browse files Browse the repository at this point in the history
Fix for stock display in KiCad
  • Loading branch information
afkiwers authored Mar 25, 2024
2 parents fa73b18 + d92c9ff commit ef986e4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions inventree_kicad/KiCadLibraryPlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class KiCadLibraryPlugin(UrlsMixin, AppMixin, SettingsMixin, SettingsContentMixi
},
'KICAD_ENABLE_STOCK_COUNT_FORMAT': {
'name': _('Display Format for Stock Count'),
'description': _('This will be displayed after the part\'s name in KiCad (left column).'),
'default': ">> In Stock: %s"
'description': _('This will be displayed after the part\'s description in KiCad (right column). Note: {1} contains the Stock information, {0} the description of the part.'),
'default': "[Stock: {1}] >> {0}"
},
'DEFAULT_FOR_MISSING_SYMBOL': {
'name': _('Backup KiCad Symbol'),
Expand Down
6 changes: 3 additions & 3 deletions inventree_kicad/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,17 +410,17 @@ def __init__(self, *args, **kwargs):

id = serializers.CharField(source='pk', read_only=True)

name = serializers.SerializerMethodField('get_name')
description = serializers.SerializerMethodField('get_description')

def get_name(self, part):
def get_description(self, part):
"""Custom name function.
This will allow users to display stock information
if they enable it.
"""

if str2bool(self.plugin.get_setting('KICAD_ENABLE_STOCK_COUNT', False)):
return f'{part.name} {self.plugin.get_setting("KICAD_ENABLE_STOCK_COUNT_FORMAT", "(%)") % (decimal2string(part.get_stock_count()))}'
return self.plugin.get_setting("KICAD_ENABLE_STOCK_COUNT_FORMAT", "[Stock: {1}] >> {0}").format(part.description, decimal2string(part.get_stock_count()))

return part.name

Expand Down
2 changes: 1 addition & 1 deletion inventree_kicad/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
KICAD_PLUGIN_VERSION = "1.3.20"
KICAD_PLUGIN_VERSION = "1.3.21"

0 comments on commit ef986e4

Please sign in to comment.