'update transferred qty from submitted stock entries for that item against
the production order'

def update_transaferred_qty_for_required_items(self):

    for d in self.required_items:
        transferred_qty = frappe.db.sql(u'select    sum(qty)\n DCTB  DCTB  DCTB  DCTB from    `tabStock    Entry`    entry,    `tabStock    Entry    Detail`    detail\n DCTB  DCTB  DCTB  DCTB where\n DCTB  DCTB  DCTB  DCTB  DCTB entry.production_order    =    %s\n DCTB  DCTB  DCTB  DCTB  DCTB and    entry.purpose    =    "Material    Transfer    for    Manufacture"\n DCTB  DCTB  DCTB  DCTB  DCTB and    entry.docstatus    =    1\n DCTB  DCTB  DCTB  DCTB  DCTB and    detail.parent    =    entry.name\n DCTB  DCTB  DCTB  DCTB  DCTB and    detail.item_code    =    %s', (self.name, d.item_code))[0][0]
        d.db_set(u'transferred_qty', transferred_qty, update_modified=False)
