feat: 固定资产入库流程apply
This commit is contained in:
parent
29f4edccb8
commit
aa07c041fb
|
|
@ -12,6 +12,9 @@ class AssetCateSerializer(CustomModelSerializer):
|
||||||
read_only_fields = EXCLUDE_FIELDS
|
read_only_fields = EXCLUDE_FIELDS
|
||||||
|
|
||||||
class AssetSerializer(CustomModelSerializer):
|
class AssetSerializer(CustomModelSerializer):
|
||||||
|
keep_dept_name = serializers.CharField(source="keep_dept.name", read_only=True)
|
||||||
|
keeper_name = serializers.CharField(source="keeper.name", read_only=True)
|
||||||
|
cate_name = serializers.CharField(source="cate.name", read_only=True)
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Asset
|
model = Asset
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
|
||||||
|
|
@ -61,4 +61,11 @@ class AssetLogViewSet(TicketMixin, CustomModelViewSet):
|
||||||
def gen_other_ticket_data(self, instance:AssetLog):
|
def gen_other_ticket_data(self, instance:AssetLog):
|
||||||
return {"keep_dept_name": instance.keep_dept.name}
|
return {"keep_dept_name": instance.keep_dept.name}
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def apply(ticket: Ticket, transition, new_ticket_data: dict):
|
||||||
|
assetlog:AssetLog = ticket.assetlog_ticket
|
||||||
|
items = assetlog.items
|
||||||
|
sr = AssetSerializer(data=items, many=True)
|
||||||
|
sr.is_valid(raise_exception=True)
|
||||||
|
sr.save(create_by=ticket.create_by)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue