'Update qty reserved for production from Production Item tables
in open production orders'

def update_reserved_qty_for_production(self):

    self.reserved_qty_for_production = frappe.db.sql(u'select    sum(required_qty    -    transferred_qty)\n DCTB  DCTB  DCTB from    `tabProduction    Order`    pro,    `tabProduction    Order    Item`    item\n DCTB  DCTB  DCTB where\n DCTB  DCTB  DCTB  DCTB item.item_code    =    %s\n DCTB  DCTB  DCTB  DCTB and    item.parent    =    pro.name\n DCTB  DCTB  DCTB  DCTB and    pro.docstatus    =    1\n DCTB  DCTB  DCTB  DCTB and    item.source_warehouse    =    %s\n DCTB  DCTB  DCTB  DCTB and    pro.status    not    in    ("Stopped",    "Completed")', (self.item_code, self.warehouse))[0][0]
    self.set_projected_qty()
    self.db_set(u'reserved_qty_for_production', self.reserved_qty_for_production)
    self.db_set(u'projected_qty', self.projected_qty)
