Add a button to create a new part if necessary

This commit is contained in:
Oliver Walters 2019-07-07 11:56:44 +10:00
parent a6da3ed4a4
commit ff5af8f217
3 changed files with 20 additions and 1 deletions

View File

@ -685,7 +685,7 @@ class Part(models.Model):
- Exclude parts which this part is in the BOM for
"""
parts = Part.objects.filter(component=True)
parts = Part.objects.filter(component=True).exclude(id=self.id)
parts = parts.exclude(id__in=[part.id for part in self.used_in.all()])
return parts

View File

@ -47,6 +47,10 @@
{% for item in row.data %}
<td>
{% if item.column.guess == 'Part' %}
<button class='btn btn-default btn-create' id='new_part_row_{{ row.index }}' title='Create new part' type='button'>
<span row_id='{{ row.index }}' class='glyphicon glyphicon-small glyphicon-plus' onClick='newPartFromBomWizard()'/>
</button>
<select class='select bomselect' id='id_part_{{ row.index }}' name='part_select_{{ row.index }}'>
<option value=''>---------</option>
{% for part in row.part_options %}

View File

@ -62,6 +62,21 @@ function removeColFromBomWizard(e) {
}
function newPartFromBomWizard(e) {
/* Create a new part directly from the BOM wizard.
*/
e = e || window.event;
var src = e.target || e.srcElement;
launchModalForm('/part/new/', {
success: function() {
}
});
}
function loadBomTable(table, options) {
/* Load a BOM table with some configurable options.
*