def update(self, instance, validated_data):
     val_data = validated_data.pop('data')
     user = validated_data['user']  
     order = validated_data.pop('order')
     order.order_draft = val_data['order_draft'] 
     order.order_modified_by = user
     order.save()
     instance.req_item_modified_by = user
     instance.item_details = val_data.get('item_details', instance.item_details) 
     for item in val_data['req_product']:
         req_product = ReqProduct(id=item['id'], prod_title=item['prod_title'], prod_details=item['prod_details'], req_item=instance)
         req_product.save()
     instance.save()
     log(
         user=user,
         company=order.order_company,
         not_action='request item updated',
         obj=order,
         notification=False,
         extra={
             'order_id':order.id,
             'order_number':order.order_number,
             'order_version':order.order_version,
             'request_item_id':instance.id,
             'request_item_subfam':instance.item_subfam,
             'order_status':order.order_status,
             'order_status_full':order.get_order_status_display(),
         }
     )
     return instance
Beispiel #2
0
 def update(self, instance, validated_data):
     val_data = validated_data.pop("data")
     user = validated_data["user"]
     order = validated_data.pop("order")
     order.order_draft = val_data["order_draft"]
     order.order_modified_by = user
     order.save()
     instance.req_item_modified_by = user
     instance.item_details = val_data.get("item_details", instance.item_details)
     for item in val_data["req_product"]:
         req_product = ReqProduct(
             id=item["id"], prod_title=item["prod_title"], prod_details=item["prod_details"], req_item=instance
         )
         req_product.save()
     instance.save()
     log(
         user=user,
         company=order.order_company,
         not_action="request item updated",
         obj=order,
         notification=False,
         extra={
             "order_id": order.id,
             "order_number": order.order_number,
             "order_version": order.order_version,
             "request_item_id": instance.id,
             "request_item_subfam": instance.item_subfam,
             "order_status": order.order_status,
             "order_status_full": order.get_order_status_display(),
         },
     )
     return instance
 def create(self, validated_data):
     order = validated_data.pop('order')
     goods = validated_data.pop('good')
     user = validated_data['user']
     good = Good.objects.get(id=validated_data['good_id'])
     if 'item_details' in validated_data:
         item_details = validated_data.pop('item_details')
     else:
         item_details = ''
     order.order_draft = validated_data['order_draft']
     order.save()
     req_item = ReqItem.objects.create(order=order, good=good, req_domain=goods[0], item_fam=goods[1], item_subfam=goods[2], item_details=item_details)
     req_item.req_item_created_by = user
     req_item.save()
     for k, v in validated_data['prod_details'].iteritems():
         req_product = ReqProduct(req_item=req_item, prod_fam=goods[1], prod_subfam=goods[2], prod_title=k, prod_details=v)
         req_product.save()
     log(
         user=user,
         company=order.order_company,
         not_action='request item created',
         obj=order,
         notification=False,
         extra={
             'order_id':order.id,
             'order_number':order.order_number,
             'order_version':order.order_version,
             'request_item_id':req_item.id,
             'request_item_subfam':req_item.item_subfam,
             'order_status':order.order_status,
             'order_status_full':order.get_order_status_display(),
         }
     )
     return req_item
Beispiel #4
0
 def create(self, validated_data):
     order = validated_data.pop("order")
     goods = validated_data.pop("good")
     user = validated_data["user"]
     good = Good.objects.get(id=validated_data["good_id"])
     if "item_details" in validated_data:
         item_details = validated_data.pop("item_details")
     else:
         item_details = ""
     order.order_draft = validated_data["order_draft"]
     order.save()
     req_item = ReqItem.objects.create(
         order=order,
         good=good,
         req_domain=goods[0],
         item_fam=goods[1],
         item_subfam=goods[2],
         item_details=item_details,
     )
     req_item.req_item_created_by = user
     req_item.save()
     for k, v in validated_data["prod_details"].iteritems():
         req_product = ReqProduct(
             req_item=req_item, prod_fam=goods[1], prod_subfam=goods[2], prod_title=k, prod_details=v
         )
         req_product.save()
     log(
         user=user,
         company=order.order_company,
         not_action="request item created",
         obj=order,
         notification=False,
         extra={
             "order_id": order.id,
             "order_number": order.order_number,
             "order_version": order.order_version,
             "request_item_id": req_item.id,
             "request_item_subfam": req_item.item_subfam,
             "order_status": order.order_status,
             "order_status_full": order.get_order_status_display(),
         },
     )
     return req_item