mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-02 05:26:45 +00:00
Better string formatting for models
Allows for easier searching in drop-downs for ForeignKeys
This commit is contained in:
parent
233f093093
commit
7644617af0
@ -53,7 +53,7 @@ class Company(models.Model):
|
|||||||
is_supplier = models.BooleanField(default=True)
|
is_supplier = models.BooleanField(default=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return "{n} - {d}".format(n=self.name, d=self.description)
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return "/company/{id}/".format(id=self.id)
|
return "/company/{id}/".format(id=self.id)
|
||||||
|
@ -4,15 +4,28 @@
|
|||||||
|
|
||||||
{% include 'company/tabs.html' with tab='parts' %}
|
{% include 'company/tabs.html' with tab='parts' %}
|
||||||
|
|
||||||
<h3>Company Parts</h3>
|
<div class='row'>
|
||||||
|
<div class='col-sm-6'>
|
||||||
|
<h3>Supplier Parts</h3>
|
||||||
|
</div>
|
||||||
|
<div class='col-sm-6'>
|
||||||
|
<h3 class='float-right'>
|
||||||
|
<button class="btn btn-success" id='part-create'>New Supplier Part</button>
|
||||||
|
<div class="dropdown" style="float: right;">
|
||||||
|
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Options
|
||||||
|
<span class="caret"></span></button>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
<table clas='table table-striped table-condensed' id='part-table'>
|
<table clas='table table-striped table-condensed' id='part-table'>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class='container-fluid'>
|
|
||||||
<button class="btn btn-success" id='part-create'>New Supplier Part</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block js_ready %}
|
{% block js_ready %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<div class='row'>
|
<div class='row'>
|
||||||
<div class='col-sm-6'>
|
<div class='col-sm-6'>
|
||||||
<h3>Supplier Part</h3>
|
<h3>Supplier Part</h3>
|
||||||
<p>{{ part.SKU }} - <a href="{% url 'company-detail' part.supplier.id %}">{{ part.supplier.name }}</a></p>
|
<p>{{ part.SKU }} - <a href="{% url 'company-detail-parts' part.supplier.id %}">{{ part.supplier.name }}</a></p>
|
||||||
</div>
|
</div>
|
||||||
<div class='col-sm-6'>
|
<div class='col-sm-6'>
|
||||||
<h3>
|
<h3>
|
||||||
|
@ -145,12 +145,7 @@ class Part(models.Model):
|
|||||||
notes = models.TextField(blank=True)
|
notes = models.TextField(blank=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.IPN:
|
return "{n} - {d}".format(n=self.name, d=self.description)
|
||||||
return "{name} ({ipn})".format(
|
|
||||||
ipn=self.IPN,
|
|
||||||
name=self.name)
|
|
||||||
else:
|
|
||||||
return self.name
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Part"
|
verbose_name = "Part"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user