mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add function to duplicate stock item
This commit is contained in:
parent
05beb26c82
commit
8040ad8a6a
@ -102,7 +102,7 @@
|
||||
{
|
||||
follow: true,
|
||||
data: {
|
||||
copy_part: {{ part.id }},
|
||||
copy: {{ part.id }},
|
||||
},
|
||||
}
|
||||
);
|
||||
|
@ -78,7 +78,7 @@ class PartCreate(AjaxCreateView):
|
||||
def get_initial(self):
|
||||
|
||||
# Is the client attempting to copy an existing part?
|
||||
part_to_copy = self.request.GET.get('copy_part', None)
|
||||
part_to_copy = self.request.GET.get('copy', None)
|
||||
|
||||
if part_to_copy:
|
||||
try:
|
||||
|
@ -13,6 +13,7 @@
|
||||
<h3>
|
||||
<div style='float: right;'>
|
||||
<div class="dropdown" style="float: right;">
|
||||
<button class='btn btn-primary' type='button' id='duplicate-item'>Copy Stock Item</button>
|
||||
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Options
|
||||
<span class="caret"></span></button>
|
||||
<ul class="dropdown-menu">
|
||||
@ -140,6 +141,19 @@
|
||||
{% endblock %}
|
||||
{% block js_ready %}
|
||||
{{ block.super }}
|
||||
|
||||
$("#duplicate-item").click(function() {
|
||||
launchModalForm(
|
||||
"{% url 'stock-item-create' %}",
|
||||
{
|
||||
follow: true,
|
||||
data: {
|
||||
copy: {{ item.id }},
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$("#stock-edit").click(function () {
|
||||
launchModalForm(
|
||||
"{% url 'stock-item-edit' item.id %}",
|
||||
|
@ -4,6 +4,7 @@ from __future__ import unicode_literals
|
||||
from django.shortcuts import get_object_or_404
|
||||
|
||||
from django.views.generic import DetailView, ListView
|
||||
from django.forms.models import model_to_dict
|
||||
|
||||
from InvenTree.views import AjaxUpdateView, AjaxDeleteView, AjaxCreateView
|
||||
|
||||
@ -126,7 +127,20 @@ class StockItemCreate(AjaxCreateView):
|
||||
ajax_form_title = 'Create new Stock Item'
|
||||
|
||||
def get_initial(self):
|
||||
initials = super(StockItemCreate, self).get_initial().copy()
|
||||
|
||||
# Is the client attempting to copy an existing stock item?
|
||||
item_to_copy = self.request.GET.get('copy', None)
|
||||
|
||||
if item_to_copy:
|
||||
try:
|
||||
original = StockItem.objects.get(pk=item_to_copy)
|
||||
initials = model_to_dict(original)
|
||||
self.ajax_form_title = "Copy Stock Item"
|
||||
except StockItem.DoesNotExist:
|
||||
initials = super(StockItemCreate, self).get_initial().copy()
|
||||
|
||||
else:
|
||||
initials = super(StockItemCreate, self).get_initial().copy()
|
||||
|
||||
part_id = self.request.GET.get('part', None)
|
||||
loc_id = self.request.GET.get('location', None)
|
||||
|
Loading…
Reference in New Issue
Block a user