brotherton-erpnext/patches/november_2012/customer_issue_allocated_to_assigned.py
2012-11-15 16:58:27 +05:30

20 lines
709 B
Python

from __future__ import unicode_literals
import webnotes
def execute():
from webnotes.widgets.form.assign_to import add
# clear old customer issue todos
webnotes.conn.sql("""delete from tabToDo where reference_type='Customer Issue'""")
webnotes.conn.sql("""delete from tabComment where comment like '%Form/Customer Issue%'""")
for t in webnotes.conn.sql("""select * from `tabCustomer Issue`
where ifnull(allocated_to, '')!='' and ifnull(status, "")="Open" """, as_dict=1):
print t
add({
'doctype': "Customer Issue",
'name': t['name'],
'assign_to': t['allocated_to'],
'assigned_by': t['owner'],
'description': t['complaint'],
'date': t['creation'],
'no_notification': True
})