From 5a4c7d3b62ca8edb42d07a78656d0aa42ac5e207 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 29 Feb 2016 12:01:44 +0530 Subject: [PATCH] [patch] repost valuation rate for serialized items --- erpnext/patches.txt | 3 +- erpnext/patches/v6_24/__init__.py | 0 ...ost_valuation_rate_for_serialized_items.py | 28 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 erpnext/patches/v6_24/__init__.py create mode 100644 erpnext/patches/v6_24/repost_valuation_rate_for_serialized_items.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 1ecd440054..7c9da34d14 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -249,4 +249,5 @@ erpnext.patches.v6_20.set_party_account_currency_in_orders erpnext.patches.v6_19.comment_feed_communication erpnext.patches.v6_21.fix_reorder_level erpnext.patches.v6_21.rename_material_request_fields -erpnext.patches.v6_23.update_stopped_status_to_closed \ No newline at end of file +erpnext.patches.v6_23.update_stopped_status_to_closed +erpnext.patches.v6_24.repost_valuation_rate_for_serialized_items \ No newline at end of file diff --git a/erpnext/patches/v6_24/__init__.py b/erpnext/patches/v6_24/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/patches/v6_24/repost_valuation_rate_for_serialized_items.py b/erpnext/patches/v6_24/repost_valuation_rate_for_serialized_items.py new file mode 100644 index 0000000000..3b157a3e36 --- /dev/null +++ b/erpnext/patches/v6_24/repost_valuation_rate_for_serialized_items.py @@ -0,0 +1,28 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import frappe +from frappe.utils import today +from erpnext.accounts.utils import get_fiscal_year +from erpnext.stock.stock_ledger import update_entries_after + +def execute(): + try: + year_start_date = get_fiscal_year(today())[1] + except: + return + + if year_start_date: + items = frappe.db.sql("""select distinct item_code, warehouse from `tabStock Ledger Entry` + where ifnull(serial_no, '') != '' and actual_qty > 0 and incoming_rate=0""", as_dict=1) + + for d in items: + try: + update_entries_after({ + "item_code": d.item_code, + "warehouse": d.warehouse, + "posting_date": year_start_date + }, allow_zero_rate=True) + except: + pass \ No newline at end of file