diff --git a/selling/doctype/sales_common/sales_common.py b/selling/doctype/sales_common/sales_common.py index 82acaa1bed..4f883b2e84 100644 --- a/selling/doctype/sales_common/sales_common.py +++ b/selling/doctype/sales_common/sales_common.py @@ -415,8 +415,8 @@ class DocType(TransactionBase): 'qty': flt(p.qty), 'reserved_qty': (flt(p.qty)/qty)*(reserved_qty), 'uom': p.uom, - 'batch_no': p.batch_no, - 'serial_no': p.serial_no, + 'batch_no': cstr(p.batch_no).strip(), + 'serial_no': cstr(p.serial_no).strip(), 'name': d.name }) else: @@ -427,8 +427,8 @@ class DocType(TransactionBase): 'qty': qty, 'reserved_qty': reserved_qty, 'uom': d.stock_uom, - 'batch_no': d.batch_no, - 'serial_no': d.serial_no, + 'batch_no': cstr(d.batch_no).strip(), + 'serial_no': cstr(d.serial_no).strip(), 'name': d.name }) return il diff --git a/stock/doctype/purchase_receipt/purchase_receipt.py b/stock/doctype/purchase_receipt/purchase_receipt.py index 46484e042e..5bc0776fb9 100644 --- a/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/stock/doctype/purchase_receipt/purchase_receipt.py @@ -154,15 +154,9 @@ class DocType(BuyingController): def scrub_rejected_serial_nos(self): for d in getlist(self.doclist, 'purchase_receipt_details'): if d.rejected_serial_no: - d.rejected_serial_no = d.rejected_serial_no.replace(',', '\n') + d.rejected_serial_no = cstr(d.rejected_serial_no).strip().replace(',', '\n') d.save() - - - # On Submit - # ----------------------------------------------------------------------------------------------------- - - # Update Stock def update_stock(self, is_submit): pc_obj = get_obj('Purchase Common') self.values = [] @@ -211,9 +205,9 @@ class DocType(BuyingController): # make Stock Entry def make_sl_entry(self, d, wh, qty, in_value, is_submit, rejected = 0): if rejected: - serial_no = d.rejected_serial_no + serial_no = cstr(d.rejected_serial_no).strip() else: - serial_no = d.serial_no + serial_no = cstr(d.serial_no).strip() self.values.append({ 'item_code' : d.fields.has_key('item_code') and d.item_code or d.rm_item_code, @@ -229,7 +223,7 @@ class DocType(BuyingController): 'company' : self.doc.company, 'fiscal_year' : self.doc.fiscal_year, 'is_cancelled' : (is_submit==1) and 'No' or 'Yes', - 'batch_no' : d.batch_no, + 'batch_no' : cstr(d.batch_no).strip(), 'serial_no' : serial_no }) diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py index 6d09045d8c..73af2bfdf7 100644 --- a/stock/doctype/stock_entry/stock_entry.py +++ b/stock/doctype/stock_entry/stock_entry.py @@ -166,7 +166,7 @@ class DocType(TransactionBase): "posting_date": self.doc.posting_date, "posting_time": self.doc.posting_time, "qty": d.s_warehouse and -1*d.transfer_qty or d.transfer_qty, - "serial_no": d.serial_no, + "serial_no": cstr(d.serial_no).strip(), "bom_no": d.bom_no, }) # get actual stock at source warehouse @@ -257,7 +257,7 @@ class DocType(TransactionBase): sl_obj.validate_serial_no_warehouse(self, 'mtn_details') for d in getlist(self.doclist, 'mtn_details'): - if d.serial_no: + if cstr(d.serial_no).strip(): for x in get_valid_serial_nos(d.serial_no): serial_no = x.strip() if d.s_warehouse: @@ -536,8 +536,8 @@ class DocType(TransactionBase): 'stock_uom': d.stock_uom, 'company': self.doc.company, 'is_cancelled': (is_cancelled ==1) and 'Yes' or 'No', - 'batch_no': d.batch_no, - 'serial_no': d.serial_no + 'batch_no': cstr(d.batch_no).strip(), + 'serial_no': cstr(d.serial_no).strip() }) def get_cust_values(self): diff --git a/stock/doctype/stock_ledger/stock_ledger.py b/stock/doctype/stock_ledger/stock_ledger.py index 86a8663635..9f498d27e2 100644 --- a/stock/doctype/stock_ledger/stock_ledger.py +++ b/stock/doctype/stock_ledger/stock_ledger.py @@ -38,14 +38,14 @@ class DocType: for d in getlist(obj.doclist, table_name): if d.serial_no: - d.serial_no = d.serial_no.replace(',', '\n') + d.serial_no = cstr(d.serial_no).strip().replace(',', '\n') d.save() def validate_serial_no_warehouse(self, obj, fname): for d in getlist(obj.doclist, fname): wh = d.warehouse or d.s_warehouse - if d.serial_no and wh: + if cstr(d.serial_no).strip() and wh: serial_nos = get_valid_serial_nos(d.serial_no) for s in serial_nos: s = s.strip() @@ -172,7 +172,6 @@ class DocType: def update_serial_record(self, obj, fname, is_submit = 1, is_incoming = 0): - import datetime for d in getlist(obj.doclist, fname): if d.serial_no: serial_nos = get_valid_serial_nos(d.serial_no) @@ -191,10 +190,12 @@ class DocType: def update_stock(self, values, is_amended = 'No'): for v in values: - sle_id, serial_nos = '', '' + sle_id, valid_serial_nos = '', '' # get serial nos - if v.get("serial_no"): - serial_nos = get_valid_serial_nos(v["serial_no"], v['actual_qty'], v['item_code']) + if v.get("serial_no", "").strip(): + valid_serial_nos = get_valid_serial_nos(v["serial_no"], + v['actual_qty'], v['item_code']) + v["serial_no"] = valid_serial_nos and "\n".join(valid_serial_nos) or "" # reverse quantities for cancel if v.get('is_cancelled') == 'Yes':