2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-21 06:16:29 +00:00

Add forms / views for creating a new build output, and completing the build

- Also some refactoring of how forms are handled and saved
This commit is contained in:
Oliver Walters
2020-11-02 22:56:26 +11:00
parent b02c87ea50
commit 500da8099b
18 changed files with 495 additions and 521 deletions

View File

@ -905,6 +905,7 @@ class Part(MPTTModel):
def has_bom(self):
return self.bom_count > 0
@property
def has_trackable_parts(self):
"""
Return True if any parts linked in the Bill of Materials are trackable.

View File

@ -82,10 +82,14 @@ class PartAttachmentCreate(AjaxCreateView):
role_required = 'part.add'
def post_save(self):
""" Record the user that uploaded the attachment """
self.object.user = self.request.user
self.object.save()
def save(self, form, **kwargs):
"""
Record the user that uploaded this attachment
"""
attachment = form.save(commit=False)
attachment.user = self.request.user
attachment.save()
def get_data(self):
return {
@ -874,7 +878,10 @@ class BomDuplicate(AjaxUpdateView):
if not confirm:
form.add_error('confirm', _('Confirm duplication of BOM from parent'))
def post_save(self, part, form):
def save(self, part, form):
"""
Duplicate BOM from the specified parent
"""
parent = form.cleaned_data.get('parent', None)
@ -915,7 +922,10 @@ class BomValidate(AjaxUpdateView):
if not confirm:
form.add_error('validate', _('Confirm that the BOM is valid'))
def post_save(self, part, form, **kwargs):
def save(self, part, form, **kwargs):
"""
Mark the BOM as validated
"""
part.validate_bom(self.request.user)