mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Record the user when updating stock items
This commit is contained in:
parent
30ff48d803
commit
3b252b8409
@ -366,10 +366,7 @@ class StockTrackingSerializer(InvenTreeModelSerializer):
|
||||
'date',
|
||||
'deltas',
|
||||
'label',
|
||||
'link',
|
||||
'notes',
|
||||
'quantity',
|
||||
'title',
|
||||
'tracking_type',
|
||||
'user',
|
||||
'user_detail',
|
||||
@ -378,8 +375,6 @@ class StockTrackingSerializer(InvenTreeModelSerializer):
|
||||
read_only_fields = [
|
||||
'date',
|
||||
'user',
|
||||
'system',
|
||||
'quantity',
|
||||
'label',
|
||||
'tracking_type',
|
||||
]
|
||||
|
@ -1221,6 +1221,17 @@ class StockItemEditStatus(AjaxUpdateView):
|
||||
form_class = StockForms.EditStockItemStatusForm
|
||||
ajax_form_title = _('Edit Stock Item Status')
|
||||
|
||||
def save(self, object, form, **kwargs):
|
||||
"""
|
||||
Override the save method, to track the user who updated the model
|
||||
"""
|
||||
|
||||
item = form.save(commit=False)
|
||||
|
||||
item.save(user=self.request.user)
|
||||
|
||||
return item
|
||||
|
||||
|
||||
class StockItemEdit(AjaxUpdateView):
|
||||
"""
|
||||
@ -1331,6 +1342,17 @@ class StockItemEdit(AjaxUpdateView):
|
||||
if not owner and not self.request.user.is_superuser:
|
||||
form.add_error('owner', _('Owner is required (ownership control is enabled)'))
|
||||
|
||||
def save(self, object, form, **kwargs):
|
||||
"""
|
||||
Override the save method, to track the user who updated the model
|
||||
"""
|
||||
|
||||
item = form.save(commit=False)
|
||||
|
||||
item.save(user=self.request.user)
|
||||
|
||||
return item
|
||||
|
||||
|
||||
class StockItemConvert(AjaxUpdateView):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user