mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Allow selection of bom_copy and parameter_copy when making a new variant
This commit is contained in:
parent
6ef4390e29
commit
c4989e59b2
@ -137,7 +137,7 @@ class EditPartForm(HelperForm):
|
||||
|
||||
parameters_copy = forms.BooleanField(required=False,
|
||||
initial=True,
|
||||
help_text=_("Duplicate all parameters data for this part"),
|
||||
help_text=_("Duplicate all parameter data for this part"),
|
||||
label=_('Copy Parameters'),
|
||||
widget=forms.HiddenInput())
|
||||
|
||||
|
@ -303,6 +303,12 @@ class MakePartVariant(AjaxCreateView):
|
||||
# Hide some variant-related fields
|
||||
# form.fields['variant_of'].widget = HiddenInput()
|
||||
|
||||
# Force display of the 'bom_copy' widget
|
||||
form.fields['bom_copy'].widget = CheckboxInput()
|
||||
|
||||
# Force display of the 'parameters_copy' widget
|
||||
form.fields['parameters_copy'].widget = CheckboxInput()
|
||||
|
||||
return form
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
@ -329,8 +335,11 @@ class MakePartVariant(AjaxCreateView):
|
||||
data['text'] = str(part)
|
||||
data['url'] = part.get_absolute_url()
|
||||
|
||||
bom_copy = str2bool(request.POST.get('bom_copy', False))
|
||||
parameters_copy = str2bool(request.POST.get('parameters_copy', False))
|
||||
|
||||
# Copy relevent information from the template part
|
||||
part.deepCopy(part_template, bom=True, parameters=True)
|
||||
part.deepCopy(part_template, bom=bom_copy, parameters=parameters_copy)
|
||||
|
||||
return self.renderJsonResponse(request, form, data, context=context)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user