Skip to content

Commit

Permalink
Added 'salable' field to Part model
Browse files Browse the repository at this point in the history
  • Loading branch information
SchrodingersGat committed Apr 17, 2018
1 parent 9dc41ba commit 45c5ede
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 7 deletions.
1 change: 1 addition & 0 deletions InvenTree/part/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Meta:
'buildable',
'trackable',
'purchaseable',
'salable',
]


Expand Down
20 changes: 20 additions & 0 deletions InvenTree/part/migrations/0020_part_salable.py
Original file line number Diff line number Diff line change
@@ -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?'),
),
]
14 changes: 10 additions & 4 deletions InvenTree/part/models.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -121,6 +124,9 @@ def get_absolute_url(self):
# 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(
Expand Down
10 changes: 7 additions & 3 deletions InvenTree/part/templates/part/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,19 @@ <h3>Part Details</h3>
</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>
Expand Down
5 changes: 5 additions & 0 deletions InvenTree/part/templates/yesnolabel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% if value %}
<span class='label label-success'>Yes</span>
{% else %}
<span class='label label-warning'>No</span>
{% endif %}

0 comments on commit 45c5ede

Please sign in to comment.