Added 'salable' field to Part model

This commit is contained in:
Oliver 2018-04-17 18:11:34 +10:00
parent 9dc41ba122
commit 45c5edee4d
5 changed files with 43 additions and 7 deletions

View File

@ -28,6 +28,7 @@ class EditPartForm(forms.ModelForm):
'buildable',
'trackable',
'purchaseable',
'salable',
]

View File

@ -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?'),
),
]

View File

@ -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(

View File

@ -29,15 +29,19 @@
</tr>
<tr>
<td>Buildable</td>
<td>{{ part.buildable }}</td>
<td>{% include "yesnolabel.html" with value=part.buildable %}</td>
</tr>
<tr>
<td>Trackable</td>
<td>{{ part.trackable }}</td>
<td>{% include "yesnolabel.html" with value=part.trackable %}</td>
</tr>
<tr>
<td>Purchaseable</td>
<td>{{ part.purchaseable }}</td>
<td>{% include "yesnolabel.html" with value=part.purchaseable %}</td>
</tr>
<tr>
<td>Salable</td>
<td>{% include "yesnolabel.html" with value=part.salable %}</td>
</tr>
{% if part.minimum_stock > 0 %}
<tr>

View File

@ -0,0 +1,5 @@
{% if value %}
<span class='label label-success'>Yes</span>
{% else %}
<span class='label label-warning'>No</span>
{% endif %}