2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-30 00:21:34 +00:00

Merge pull request from SchrodingersGat/qr-codes

Qr codes
This commit is contained in:
Oliver
2019-05-02 21:15:34 +10:00
committed by GitHub
10 changed files with 114 additions and 13 deletions

@@ -0,0 +1,18 @@
# Generated by Django 2.2 on 2019-05-02 10:39
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('part', '0013_auto_20190429_2229'),
]
operations = [
migrations.AlterField(
model_name='part',
name='URL',
field=models.URLField(blank=True, help_text='Link to extenal URL'),
),
]

@@ -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 %}