mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge remote-tracking branch 'inventree/master'
This commit is contained in:
commit
119cccc318
@ -173,23 +173,7 @@ class PartPriceForm(forms.Form):
|
|||||||
help_text=_('Input quantity for price calculation')
|
help_text=_('Input quantity for price calculation')
|
||||||
)
|
)
|
||||||
|
|
||||||
currency = forms.ChoiceField(label='Currency', help_text=_('Select currency for price calculation'))
|
currency = forms.ModelChoiceField(queryset=Currency.objects.all(), label='Currency', help_text=_('Select currency for price calculation'))
|
||||||
|
|
||||||
def get_currency_choices(self):
|
|
||||||
""" Create options for Currency """
|
|
||||||
|
|
||||||
currencies = Currency.objects.all()
|
|
||||||
choices = [(None, '---------')]
|
|
||||||
|
|
||||||
for c in currencies:
|
|
||||||
choices.append((c.pk, str(c)))
|
|
||||||
|
|
||||||
return choices
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
self.fields['currency'].choices = self.get_currency_choices()
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Part
|
model = Part
|
||||||
|
@ -1140,6 +1140,8 @@ class BomItem(models.Model):
|
|||||||
if self.part == self.sub_part:
|
if self.part == self.sub_part:
|
||||||
raise ValidationError({'sub_part': _('Part cannot be added to its own Bill of Materials')})
|
raise ValidationError({'sub_part': _('Part cannot be added to its own Bill of Materials')})
|
||||||
|
|
||||||
|
# TODO - Make sure that there is no recusion
|
||||||
|
|
||||||
# Test for simple recursion
|
# Test for simple recursion
|
||||||
for item in self.sub_part.bom_items.all():
|
for item in self.sub_part.bom_items.all():
|
||||||
if self.part == item.sub_part:
|
if self.part == item.sub_part:
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
<li{% ifequal tab 'stock' %} class="active"{% endifequal %}>
|
<li{% ifequal tab 'stock' %} class="active"{% endifequal %}>
|
||||||
<a href="{% url 'part-stock' part.id %}">Stock <span class="badge">{{ part.total_stock }}</span></a>
|
<a href="{% url 'part-stock' part.id %}">Stock <span class="badge">{{ part.total_stock }}</span></a>
|
||||||
</li>
|
</li>
|
||||||
{% if part.allocation_count > 0 %}
|
{% if part.component or part.used_in_count > 0 %}
|
||||||
<li{% ifequal tab 'allocation' %} class="active"{% endifequal %}>
|
<li{% ifequal tab 'allocation' %} class="active"{% endifequal %}>
|
||||||
<a href="{% url 'part-allocation' part.id %}">Allocated <span class="badge">{{ part.allocation_count }}</span></a>
|
<a href="{% url 'part-allocation' part.id %}">Allocated <span class="badge">{{ part.allocation_count }}</span></a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -9,6 +9,8 @@ from django import forms
|
|||||||
from django.forms.utils import ErrorDict
|
from django.forms.utils import ErrorDict
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
|
from mptt.fields import TreeNodeChoiceField
|
||||||
|
|
||||||
from InvenTree.helpers import GetExportFormats
|
from InvenTree.helpers import GetExportFormats
|
||||||
from InvenTree.forms import HelperForm
|
from InvenTree.forms import HelperForm
|
||||||
from .models import StockLocation, StockItem, StockItemTracking
|
from .models import StockLocation, StockItem, StockItemTracking
|
||||||
@ -67,25 +69,12 @@ class CreateStockItemForm(HelperForm):
|
|||||||
class SerializeStockForm(forms.ModelForm):
|
class SerializeStockForm(forms.ModelForm):
|
||||||
""" Form for serializing a StockItem. """
|
""" Form for serializing a StockItem. """
|
||||||
|
|
||||||
destination = forms.ChoiceField(label='Destination', required=True, help_text='Destination for serialized stock (by default, will remain in current location)')
|
destination = TreeNodeChoiceField(queryset=StockLocation.objects.all(), label='Destination', required=True, help_text='Destination for serialized stock (by default, will remain in current location)')
|
||||||
|
|
||||||
serial_numbers = forms.CharField(label='Serial numbers', required=True, help_text='Unique serial numbers (must match quantity)')
|
serial_numbers = forms.CharField(label='Serial numbers', required=True, help_text='Unique serial numbers (must match quantity)')
|
||||||
|
|
||||||
note = forms.CharField(label='Notes', required=False, help_text='Add transaction note (optional)')
|
note = forms.CharField(label='Notes', required=False, help_text='Add transaction note (optional)')
|
||||||
|
|
||||||
def get_location_choices(self):
|
|
||||||
locs = StockLocation.objects.all()
|
|
||||||
|
|
||||||
choices = [(None, '---------')]
|
|
||||||
|
|
||||||
for loc in locs:
|
|
||||||
choices.append((loc.pk, loc.pathstring + ' - ' + loc.description))
|
|
||||||
|
|
||||||
return choices
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
self.fields['destination'].choices = self.get_location_choices()
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = StockItem
|
model = StockItem
|
||||||
|
|
||||||
@ -135,28 +124,16 @@ class AdjustStockForm(forms.ModelForm):
|
|||||||
This form is used for managing stock adjuments for single or multiple stock items.
|
This form is used for managing stock adjuments for single or multiple stock items.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def get_location_choices(self):
|
destination = TreeNodeChoiceField(queryset=StockLocation.objects.all(), label='Destination', required=True, help_text=_('Destination stock location'))
|
||||||
locs = StockLocation.objects.all()
|
|
||||||
|
|
||||||
choices = [(None, '---------')]
|
|
||||||
|
|
||||||
for loc in locs:
|
|
||||||
choices.append((loc.pk, loc.pathstring + ' - ' + loc.description))
|
|
||||||
|
|
||||||
return choices
|
|
||||||
|
|
||||||
destination = forms.ChoiceField(label='Destination', required=True, help_text=_('Destination stock location'))
|
|
||||||
note = forms.CharField(label='Notes', required=True, help_text='Add note (required)')
|
note = forms.CharField(label='Notes', required=True, help_text='Add note (required)')
|
||||||
|
|
||||||
# transaction = forms.BooleanField(required=False, initial=False, label='Create Transaction', help_text='Create a stock transaction for these parts')
|
# transaction = forms.BooleanField(required=False, initial=False, label='Create Transaction', help_text='Create a stock transaction for these parts')
|
||||||
|
|
||||||
confirm = forms.BooleanField(required=False, initial=False, label='Confirm stock adjustment', help_text=_('Confirm movement of stock items'))
|
confirm = forms.BooleanField(required=False, initial=False, label='Confirm stock adjustment', help_text=_('Confirm movement of stock items'))
|
||||||
|
|
||||||
set_loc = forms.BooleanField(required=False, initial=False, label='Set Default Location', help_text=_('Set the destination as the default location for selected parts'))
|
set_loc = forms.BooleanField(required=False, initial=False, label='Set Default Location', help_text=_('Set the destination as the default location for selected parts'))
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
self.fields['destination'].choices = self.get_location_choices()
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = StockItem
|
model = StockItem
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user