2013-03-25 11:07:12 +05:30
|
|
|
import webnotes
|
|
|
|
|
|
|
|
def execute():
|
2013-03-26 14:49:25 +05:30
|
|
|
for purchase_invoice in webnotes.conn.sql_list("""select distinct parent
|
2013-03-25 11:07:12 +05:30
|
|
|
from `tabPurchase Invoice Item` where docstatus = 1 and ifnull(valuation_rate, 0)=0"""):
|
|
|
|
pi = webnotes.get_obj("Purchase Invoice", purchase_invoice)
|
|
|
|
pi.calculate_taxes_and_totals()
|
|
|
|
pi.update_raw_material_cost()
|
|
|
|
pi.update_valuation_rate("entries")
|
|
|
|
for item in pi.doclist.get({"parentfield": "entries"}):
|
2013-04-01 17:23:43 +05:30
|
|
|
webnotes.conn.sql("""update `tabPurchase Invoice Item` set valuation_rate = %s
|
|
|
|
where name = %s""", (item.valuation_rate, item.name))
|
2013-03-25 11:07:12 +05:30
|
|
|
|