Tuesday, 1 May 2018

How to add only one row in child table using python

mycheck = False
for i in doc.deductions:
if i.salary_component == "Attendance Violation":
mycheck = True
i.amount = doc.deduction_amount
if mycheck:
pass
else:
row = doc.append('deductions', {})
row.salary_component = "Attendance Violation"
row.amount =doc.deduction_amount
doc.reload()

No comments:

Post a Comment

Django rest api - filter

views.py from django_filters.rest_framework import DjangoFilterBackend class PollList(viewsets.ModelViewSet):     queryset = X.objects...