From 45c5edee4d71294d8ba6cc7fdd823b857b595f08 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 17 Apr 2018 18:11:34 +1000 Subject: [PATCH] Added 'salable' field to Part model --- InvenTree/part/forms.py | 1 + .../part/migrations/0020_part_salable.py | 20 +++++++++++++++++++ InvenTree/part/models.py | 14 +++++++++---- InvenTree/part/templates/part/detail.html | 10 +++++++--- InvenTree/part/templates/yesnolabel.html | 5 +++++ 5 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 InvenTree/part/migrations/0020_part_salable.py create mode 100644 InvenTree/part/templates/yesnolabel.html diff --git a/InvenTree/part/forms.py b/InvenTree/part/forms.py index f986e1a0ae..1b35767a31 100644 --- a/InvenTree/part/forms.py +++ b/InvenTree/part/forms.py @@ -28,6 +28,7 @@ class EditPartForm(forms.ModelForm): 'buildable', 'trackable', 'purchaseable', + 'salable', ] diff --git a/InvenTree/part/migrations/0020_part_salable.py b/InvenTree/part/migrations/0020_part_salable.py new file mode 100644 index 0000000000..9d24532273 --- /dev/null +++ b/InvenTree/part/migrations/0020_part_salable.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.12 on 2018-04-17 08:06 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('part', '0019_auto_20180416_1249'), + ] + + operations = [ + migrations.AddField( + model_name='part', + name='salable', + field=models.BooleanField(default=False, help_text='Can this part be sold to customers?'), + ), + ] diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 3d2fe90628..16c349cf11 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -1,15 +1,18 @@ +# -*- coding: utf-8 -*- from __future__ import unicode_literals + +import os + from django.db import models from django.db.models import Sum from django.core.validators import MinValueValidator -from InvenTree.models import InvenTreeTree - -import os - from django.db.models.signals import pre_delete from django.dispatch import receiver +from InvenTree.models import InvenTreeTree +# from stock.models import StockLocation + class PartCategory(InvenTreeTree): """ PartCategory provides hierarchical organization of Part objects. @@ -121,6 +124,9 @@ class Part(models.Model): # Is this part "purchaseable"? purchaseable = models.BooleanField(default=True, help_text='Can this part be purchased from external suppliers?') + # Can this part be sold to customers? + salable = models.BooleanField(default=False, help_text="Can this part be sold to customers?") + def __str__(self): if self.IPN: return "{name} ({ipn})".format( diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index 1059b65f04..0e1c7aae34 100644 --- a/InvenTree/part/templates/part/detail.html +++ b/InvenTree/part/templates/part/detail.html @@ -29,15 +29,19 @@ Buildable - {{ part.buildable }} + {% include "yesnolabel.html" with value=part.buildable %} Trackable - {{ part.trackable }} + {% include "yesnolabel.html" with value=part.trackable %} Purchaseable - {{ part.purchaseable }} + {% include "yesnolabel.html" with value=part.purchaseable %} + + + Salable + {% include "yesnolabel.html" with value=part.salable %} {% if part.minimum_stock > 0 %} diff --git a/InvenTree/part/templates/yesnolabel.html b/InvenTree/part/templates/yesnolabel.html new file mode 100644 index 0000000000..cdc6070560 --- /dev/null +++ b/InvenTree/part/templates/yesnolabel.html @@ -0,0 +1,5 @@ +{% if value %} +Yes +{% else %} +No +{% endif %} \ No newline at end of file