mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 20:29:09 +00:00
[patch][serial no] for striped serial nos
This commit is contained in:
0
patches/april_2013/__init__.py
Normal file
0
patches/april_2013/__init__.py
Normal file
26
patches/april_2013/p01_update_serial_no_valuation_rate.py
Normal file
26
patches/april_2013/p01_update_serial_no_valuation_rate.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import webnotes
|
||||
from webnotes.utils import cstr
|
||||
from stock.stock_ledger import update_entries_after
|
||||
|
||||
def execute():
|
||||
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)
|
||||
|
||||
item_warehouse = []
|
||||
|
||||
for item in pr_items:
|
||||
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))
|
||||
|
||||
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])
|
||||
|
||||
for d in item_warehouse:
|
||||
update_entries_after({"item_code": d[0], "warehouse": d[1] })
|
||||
@@ -8,6 +8,6 @@ def execute():
|
||||
pi.update_raw_material_cost()
|
||||
pi.update_valuation_rate("entries")
|
||||
for item in pi.doclist.get({"parentfield": "entries"}):
|
||||
webnotes.conn.set_value("Purchase Invoice Item", item.name, "valuation_rate",
|
||||
item.valuation_rate)
|
||||
webnotes.conn.sql("""update `tabPurchase Invoice Item` set valuation_rate = %s
|
||||
where name = %s""", (item.valuation_rate, item.name))
|
||||
|
||||
@@ -5,7 +5,7 @@ def execute():
|
||||
where docstatus = 1 and ifnull(against_expense_account, '') = ''""")
|
||||
|
||||
for pi in pi_list:
|
||||
pi_obj = get_obj("Purchase Invoice", pi[0], with_children=1)
|
||||
pi_obj.set_against_expense_account()
|
||||
webnotes.conn.set_value("Purchase Invoice", pi[0],
|
||||
"against_expense_account", pi_obj.doc.against_expense_account)
|
||||
pi_obj = get_obj("Purchase Invoice", pi[0], with_children=1)
|
||||
pi_obj.set_against_expense_account()
|
||||
webnotes.conn.sql("""update `tabPurchase Invoice` set against_expense_account = %s
|
||||
where name = %s""", (pi_obj.doc.against_expense_account, pi[0]))
|
||||
@@ -227,4 +227,5 @@ patch_list = [
|
||||
"patches.march_2013.p10_update_against_expense_account",
|
||||
"patches.march_2013.p11_update_attach_files",
|
||||
"patches.march_2013.p12_set_item_tax_rate_in_json",
|
||||
"patches.april_2013.p01_update_serial_no_valuation_rate",
|
||||
]
|
||||
Reference in New Issue
Block a user