blob: a19494cc5e534c753bf1134d2c9a812c4236e620 [file] [log] [blame]
Nabin Haitb28d6dc2011-12-06 15:11:14 +05301def execute():
2 import webnotes
3 sql = webnotes.conn.sql
4 from webnotes.model.code import get_obj
Nabin Hait53ef4002011-12-21 11:22:32 +05305 from webnotes.utils import flt
Nabin Haitb28d6dc2011-12-06 15:11:14 +05306
7 # update incoming rate in serial nos
8 sr = sql("""select name, item_code, purchase_document_no from `tabSerial No`
9 where docstatus = 1 and purchase_document_type = 'Purchase Receipt'""")
10 for d in sr:
11 val_rate = sql("""select valuation_rate from `tabPurchase Receipt Detail`
12 where item_code = %s and parent = %s""", (d[1], d[2]))
13 sql("""update `tabSerial No` set purchase_rate = %s where name = %s""",
14 (val_rate and flt(val_rate[0][0]) or 0, d[0]))
15
16
17 # repost for all serialized item
18 bin = sql("""select t1.name from `tabBin` t1, tabItem t2 where t1.item_code = t2.name and ifnull(has_serial_no, 'No') = 'Yes'""")
19 for d in bin:
20 get_obj('Bin', d[0]).update_entries_after(posting_date = '2000-01-01', posting_time = '12:00')
21 sql("commit")
22 sql("start transaction")
23