stripped serial nos before processing

This commit is contained in:
Nabin Hait 2013-01-24 11:02:48 +05:30
parent 7c833af873
commit 8df3f125e5
4 changed files with 19 additions and 24 deletions

View File

@ -415,8 +415,8 @@ class DocType(TransactionBase):
'qty': flt(p.qty), 'qty': flt(p.qty),
'reserved_qty': (flt(p.qty)/qty)*(reserved_qty), 'reserved_qty': (flt(p.qty)/qty)*(reserved_qty),
'uom': p.uom, 'uom': p.uom,
'batch_no': p.batch_no, 'batch_no': cstr(p.batch_no).strip(),
'serial_no': p.serial_no, 'serial_no': cstr(p.serial_no).strip(),
'name': d.name 'name': d.name
}) })
else: else:
@ -427,8 +427,8 @@ class DocType(TransactionBase):
'qty': qty, 'qty': qty,
'reserved_qty': reserved_qty, 'reserved_qty': reserved_qty,
'uom': d.stock_uom, 'uom': d.stock_uom,
'batch_no': d.batch_no, 'batch_no': cstr(d.batch_no).strip(),
'serial_no': d.serial_no, 'serial_no': cstr(d.serial_no).strip(),
'name': d.name 'name': d.name
}) })
return il return il

View File

@ -154,15 +154,9 @@ class DocType(BuyingController):
def scrub_rejected_serial_nos(self): def scrub_rejected_serial_nos(self):
for d in getlist(self.doclist, 'purchase_receipt_details'): for d in getlist(self.doclist, 'purchase_receipt_details'):
if d.rejected_serial_no: 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() d.save()
# On Submit
# -----------------------------------------------------------------------------------------------------
# Update Stock
def update_stock(self, is_submit): def update_stock(self, is_submit):
pc_obj = get_obj('Purchase Common') pc_obj = get_obj('Purchase Common')
self.values = [] self.values = []
@ -211,9 +205,9 @@ class DocType(BuyingController):
# make Stock Entry # make Stock Entry
def make_sl_entry(self, d, wh, qty, in_value, is_submit, rejected = 0): def make_sl_entry(self, d, wh, qty, in_value, is_submit, rejected = 0):
if rejected: if rejected:
serial_no = d.rejected_serial_no serial_no = cstr(d.rejected_serial_no).strip()
else: else:
serial_no = d.serial_no serial_no = cstr(d.serial_no).strip()
self.values.append({ self.values.append({
'item_code' : d.fields.has_key('item_code') and d.item_code or d.rm_item_code, '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, 'company' : self.doc.company,
'fiscal_year' : self.doc.fiscal_year, 'fiscal_year' : self.doc.fiscal_year,
'is_cancelled' : (is_submit==1) and 'No' or 'Yes', '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 'serial_no' : serial_no
}) })

View File

@ -166,7 +166,7 @@ class DocType(TransactionBase):
"posting_date": self.doc.posting_date, "posting_date": self.doc.posting_date,
"posting_time": self.doc.posting_time, "posting_time": self.doc.posting_time,
"qty": d.s_warehouse and -1*d.transfer_qty or d.transfer_qty, "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, "bom_no": d.bom_no,
}) })
# get actual stock at source warehouse # get actual stock at source warehouse
@ -257,7 +257,7 @@ class DocType(TransactionBase):
sl_obj.validate_serial_no_warehouse(self, 'mtn_details') sl_obj.validate_serial_no_warehouse(self, 'mtn_details')
for d in getlist(self.doclist, '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): for x in get_valid_serial_nos(d.serial_no):
serial_no = x.strip() serial_no = x.strip()
if d.s_warehouse: if d.s_warehouse:
@ -536,8 +536,8 @@ class DocType(TransactionBase):
'stock_uom': d.stock_uom, 'stock_uom': d.stock_uom,
'company': self.doc.company, 'company': self.doc.company,
'is_cancelled': (is_cancelled ==1) and 'Yes' or 'No', 'is_cancelled': (is_cancelled ==1) and 'Yes' or 'No',
'batch_no': d.batch_no, 'batch_no': cstr(d.batch_no).strip(),
'serial_no': d.serial_no 'serial_no': cstr(d.serial_no).strip()
}) })
def get_cust_values(self): def get_cust_values(self):

View File

@ -38,14 +38,14 @@ class DocType:
for d in getlist(obj.doclist, table_name): for d in getlist(obj.doclist, table_name):
if d.serial_no: if d.serial_no:
d.serial_no = d.serial_no.replace(',', '\n') d.serial_no = cstr(d.serial_no).strip().replace(',', '\n')
d.save() d.save()
def validate_serial_no_warehouse(self, obj, fname): def validate_serial_no_warehouse(self, obj, fname):
for d in getlist(obj.doclist, fname): for d in getlist(obj.doclist, fname):
wh = d.warehouse or d.s_warehouse 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) serial_nos = get_valid_serial_nos(d.serial_no)
for s in serial_nos: for s in serial_nos:
s = s.strip() s = s.strip()
@ -172,7 +172,6 @@ class DocType:
def update_serial_record(self, obj, fname, is_submit = 1, is_incoming = 0): def update_serial_record(self, obj, fname, is_submit = 1, is_incoming = 0):
import datetime
for d in getlist(obj.doclist, fname): for d in getlist(obj.doclist, fname):
if d.serial_no: if d.serial_no:
serial_nos = get_valid_serial_nos(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'): def update_stock(self, values, is_amended = 'No'):
for v in values: for v in values:
sle_id, serial_nos = '', '' sle_id, valid_serial_nos = '', ''
# get serial nos # get serial nos
if v.get("serial_no"): if v.get("serial_no", "").strip():
serial_nos = get_valid_serial_nos(v["serial_no"], v['actual_qty'], v['item_code']) 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 # reverse quantities for cancel
if v.get('is_cancelled') == 'Yes': if v.get('is_cancelled') == 'Yes':