def repost(self, item_code, warehouse=None): from stock.utils import get_bin self.repost_actual_qty(item_code, warehouse) bin = get_bin(item_code, warehouse) self.repost_reserved_qty(bin) self.repost_indented_qty(bin) self.repost_ordered_qty(bin) self.repost_planned_qty(bin) bin.doc.projected_qty = flt(bin.doc.actual_qty) + flt(bin.doc.planned_qty) \ + flt(bin.doc.indented_qty) + flt(bin.doc.ordered_qty) - flt(bin.doc.reserved_qty) bin.doc.save()
def update_bin(item_code, warehouse, qty_dict=None): from stock.utils import get_bin bin = get_bin(item_code, warehouse) mismatch = False for fld, val in qty_dict.items(): if flt(bin.doc.fields.get(fld)) != flt(val): bin.doc.fields[fld] = flt(val) mismatch = True if mismatch: bin.doc.projected_qty = flt(bin.doc.actual_qty) + flt(bin.doc.ordered_qty) + \ flt(bin.doc.indented_qty) + flt(bin.doc.planned_qty) - flt(bin.doc.reserved_qty) bin.doc.save()