Merge branch 'master' into edge
This commit is contained in:
commit
96e4de3aac
@ -367,13 +367,13 @@ class BuyingController(StockController):
|
||||
if d.item_code and d.qty:
|
||||
# if no item code, which is sometimes the case in purchase invoice,
|
||||
# then it is not possible to track valuation against it
|
||||
d.valuation_rate = flt((flt(d.purchase_rate, self.precision.item.purchase_rate) or
|
||||
flt(d.rate, self.precision.item.rate) +
|
||||
d.valuation_rate = flt(((flt(d.purchase_rate, self.precision.item.purchase_rate) or
|
||||
flt(d.rate, self.precision.item.rate)) +
|
||||
(flt(d.item_tax_amount, self.precision.item.item_tax_amount) +
|
||||
flt(d.rm_supp_cost, self.precision.item.rm_supp_cost)) /
|
||||
flt(d.qty, self.precision.item.qty)) /
|
||||
flt(d.conversion_factor, self.precision.item.conversion_factor),
|
||||
self.precision.item.valuation_rate)
|
||||
self.precision.item.valuation_rate)
|
||||
else:
|
||||
d.valuation_rate = 0.0
|
||||
|
||||
|
47
patches/may_2013/p02_update_valuation_rate.py
Normal file
47
patches/may_2013/p02_update_valuation_rate.py
Normal file
@ -0,0 +1,47 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
def execute():
|
||||
from stock.stock_ledger import update_entries_after
|
||||
item_warehouse = []
|
||||
# update valuation_rate in transaction
|
||||
doctypes = {"Purchase Receipt": "purchase_receipt_details", "Purchase Invoice": "entries"}
|
||||
|
||||
for dt in doctypes:
|
||||
for d in webnotes.conn.sql("""select name from `tab%s`
|
||||
where modified >= '2013-05-09' and docstatus=1""" % dt):
|
||||
rec = webnotes.get_obj(dt, d[0])
|
||||
rec.update_valuation_rate(doctypes[dt])
|
||||
|
||||
for item in rec.doclist.get({"parentfield": doctypes[dt]}):
|
||||
webnotes.conn.sql("""update `tab%s Item` set valuation_rate = %s
|
||||
where name = %s"""% (dt, '%s', '%s'), tuple([item.valuation_rate, item.name]))
|
||||
|
||||
if dt == "Purchase Receipt":
|
||||
webnotes.conn.sql("""update `tabStock Ledger Entry` set incoming_rate = %s
|
||||
where voucher_detail_no = %s""", (item.valuation_rate, item.name))
|
||||
if [item.item_code, item.warehouse] not in item_warehouse:
|
||||
item_warehouse.append([item.item_code, item.warehouse])
|
||||
|
||||
for d in item_warehouse:
|
||||
try:
|
||||
update_entries_after({"item_code": d[0], "warehouse": d[1],
|
||||
"posting_date": "2013-01-01", "posting_time": "00:05:00"})
|
||||
webnotes.conn.commit()
|
||||
except:
|
||||
pass
|
@ -248,4 +248,5 @@ patch_list = [
|
||||
"patches.april_2013.p08_price_list_country",
|
||||
"patches.may_2013.repost_stock_for_no_posting_time",
|
||||
"patches.may_2013.p01_conversion_factor_and_aii",
|
||||
"patches.may_2013.p02_update_valuation_rate",
|
||||
]
|
@ -33,3 +33,6 @@ class DocType:
|
||||
msgprint(_("""Please check "Valid For All Countries" or \
|
||||
enter atlease one row in the "Countries" table."""), raise_exception=True)
|
||||
|
||||
def on_trash(self):
|
||||
webnotes.conn.sql("""delete from `tabItem Price` where price_list_name = %s""",
|
||||
self.doc.name)
|
Loading…
Reference in New Issue
Block a user