[Fix] Cleanup supplied items if supply raw material is set as No

This commit is contained in:
Rohit Waghchaure 2017-02-16 15:53:40 +05:30
parent b280398626
commit 4b9d2f2733
3 changed files with 19 additions and 1 deletions

View File

@ -178,6 +178,9 @@ class BuyingController(StockController):
for item in self.get("items"):
item.rm_supp_cost = 0.0
if self.is_subcontracted == "No" and self.get("supplied_items"):
self.set('supplied_items', [])
def update_raw_materials_supplied(self, item, raw_material_table):
bom_items = self.get_items_from_bom(item.item_code, item.bom)
raw_materials_cost = 0

View File

@ -364,3 +364,4 @@ erpnext.patches.v7_2.update_doctype_status
erpnext.patches.v7_2.update_salary_slips
erpnext.patches.v7_2.set_null_value_to_fields
erpnext.patches.v7_2.update_abbr_in_salary_slips
erpnext.patches.v7_2.empty_supplied_items_for_non_subcontracted

View File

@ -0,0 +1,14 @@
# 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
def execute():
for doctype in ["Purchase Order", "Purchase Invoice", "Purchase Receipt"]:
child_table = 'Purchase Receipt Item Supplied' if doctype != 'Purchase Order' else 'Purchase Order Item Supplied'
for data in frappe.db.sql(""" select distinct `tab{doctype}`.name from `tab{doctype}` , `tab{child_table}`
where `tab{doctype}`.name = `tab{child_table}`.parent and `tab{doctype}`.docstatus != 2
and `tab{doctype}`.is_subcontracted = 'No' """.format(doctype = doctype, child_table = child_table), as_dict=1):
frappe.db.sql(""" delete from `tab{child_table}`
where parent = %s and parenttype = %s""".format(child_table= child_table), (data.name, doctype))