[patch][serial no] for striped serial nos
This commit is contained in:
parent
94d1622691
commit
2a8b2c1356
@ -3,6 +3,8 @@ from webnotes.utils import cstr
|
||||
from stock.stock_ledger import update_entries_after
|
||||
|
||||
def execute():
|
||||
webnotes.conn.auto_commit_on_many_writes = 1
|
||||
|
||||
pr_items = webnotes.conn.sql("""select item_code, warehouse, serial_no, valuation_rate, name
|
||||
from `tabPurchase Receipt Item` where ifnull(serial_no, '') != '' and docstatus = 1""",
|
||||
as_dict=True)
|
||||
@ -13,14 +15,21 @@ def execute():
|
||||
serial_nos = cstr(item.serial_no).strip().split("\n")
|
||||
serial_nos = map(lambda x: x.strip(), serial_nos)
|
||||
|
||||
webnotes.conn.sql("""update `tabPurchase Receipt Item` set serial_no = %s
|
||||
where name = %s""", ("\n".join(serial_nos), item.name))
|
||||
if cstr(item.serial_no) != "\n".join(serial_nos):
|
||||
webnotes.conn.sql("""update `tabPurchase Receipt Item` set serial_no = %s
|
||||
where name = %s""", ("\n".join(serial_nos), item.name))
|
||||
|
||||
if [item.item_code, item.warehouse] not in item_warehouse:
|
||||
item_warehouse.append([item.item_code, item.warehouse])
|
||||
|
||||
webnotes.conn.sql("""update `tabSerial No` set purchase_rate = %s where name in (%s)""" %
|
||||
('%s', ', '.join(['%s']*len(serial_nos))), tuple([item.valuation_rate] + serial_nos))
|
||||
|
||||
if [item.item_code, item.warehouse] not in item_warehouse:
|
||||
item_warehouse.append([item.item_code, item.warehouse])
|
||||
webnotes.conn.sql("""update `tabSerial No` set purchase_rate = %s
|
||||
where name in (%s)""" % ('%s', ', '.join(['%s']*len(serial_nos))),
|
||||
tuple([item.valuation_rate] + serial_nos))
|
||||
|
||||
for d in item_warehouse:
|
||||
update_entries_after({"item_code": d[0], "warehouse": d[1] })
|
||||
try:
|
||||
update_entries_after({"item_code": d[0], "warehouse": d[1] })
|
||||
except:
|
||||
continue
|
||||
|
||||
webnotes.conn.auto_commit_on_many_writes = 0
|
Loading…
x
Reference in New Issue
Block a user