'Remove items if qty or rate is not changed'

def remove_items_with_no_change(self):

    self.difference_amount = 0.0
    def _changed(item):
        (qty, rate) = get_stock_balance(item.item_code, item.warehouse, self.posting_date, self.posting_time, with_valuation_rate=True)
        if (((item.qty == None) or (item.qty == qty)) and ((item.valuation_rate == None) or (item.valuation_rate == rate))):
            return False
        else:
            if (item.qty == None):
                item.qty = qty
            if (item.valuation_rate == None):
                item.valuation_rate = rate
            item.current_qty = qty
            item.current_valuation_rate = rate
            self.difference_amount += ((flt((item.qty or qty)) * flt((item.valuation_rate or rate))) - (flt(qty) * flt(rate)))
            return True
    items = filter((lambda d: _changed(d)), self.items)
    if (not items):
        frappe.throw(_(u'None    of    the    items    have    any    change    in    quantity    or    value.'), EmptyStockReconciliationItemsError)
    elif (len(items) != len(self.items)):
        self.items = items
        for (i, item) in enumerate(self.items):
            item.idx = (i + 1)
        frappe.msgprint(_(u'Removed    items    with    no    change    in    quantity    or    value.'))
