mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-19 05:25:42 +00:00
Added barcode for Part object
This commit is contained in:
@ -21,6 +21,7 @@ from django.core.validators import MinValueValidator
|
||||
from django.db.models.signals import pre_delete
|
||||
from django.dispatch import receiver
|
||||
|
||||
from InvenTree import helpers
|
||||
from InvenTree.models import InvenTreeTree
|
||||
from company.models import Company
|
||||
|
||||
@ -179,6 +180,16 @@ class Part(models.Model):
|
||||
def __str__(self):
|
||||
return "{n} - {d}".format(n=self.name, d=self.description)
|
||||
|
||||
@property
|
||||
def format_barcode(self):
|
||||
""" Return a JSON string for formatting a barcode for this Part object """
|
||||
|
||||
return helpers.MakeBarcode(
|
||||
"Part",
|
||||
self.id,
|
||||
reverse('api-part-detail', kwargs={'pk': self.id}),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Part"
|
||||
verbose_name_plural = "Parts"
|
||||
|
@ -1,5 +1,6 @@
|
||||
{% extends "part/part_base.html" %}
|
||||
{% load static %}
|
||||
{% load qr_code %}
|
||||
{% block details %}
|
||||
|
||||
{% include 'part/tabs.html' with tab='detail' %}
|
||||
@ -115,6 +116,8 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% qr_from_text part.format_barcode size="s" image_format="png" error_correction="L" %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block js_load %}
|
||||
|
Reference in New Issue
Block a user