fixes for sub_contracting
diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py
index be55e8a..a39df41 100644
--- a/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -518,16 +518,17 @@
def on_update(self):
pass
+
def update_raw_material_cost(self):
if self.sub_contracted_items:
for d in self.doclist.get({"parentfield": "entries"}):
- rm_cost = webnotes.conn.sql(""" select raw_material_cost / quantity
- from `tabBOM` where item = %s and is_default = 1 and docstatus = 1
- and is_active = 1 """, (d.item_code,))
- rm_cost = rm_cost and flt(rm_cost[0][0]) or 0
+ rm_cost = webnotes.conn.sql(""" select raw_material_cost / quantity
+ from `tabBOM` where item = %s and is_default = 1 and docstatus = 1
+ and is_active = 1 """, (d.item_code,))
+ rm_cost = rm_cost and flt(rm_cost[0][0]) or 0
- d.conversion_factor = d.conversion_factor or webnotes.conn.get_value(
- "UOM Conversion Detail", {"parent": d.item_code, "uom": d.uom},
- "conversion_factor") or 1
+ d.conversion_factor = d.conversion_factor or webnotes.conn.get_value(
+ "UOM Conversion Detail", {"parent": d.item_code, "uom": d.uom},
+ "conversion_factor") or 1
- d.rm_supp_cost = rm_cost * flt(d.qty) * flt(d.conversion_factor)
+ d.rm_supp_cost = rm_cost * flt(d.qty) * flt(d.conversion_factor)
diff --git a/stock/doctype/purchase_receipt/purchase_receipt.py b/stock/doctype/purchase_receipt/purchase_receipt.py
index 88003ca..c216abe 100644
--- a/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -289,7 +289,7 @@
self.make_gl_entries()
def validate_for_subcontracting(self):
- if self.sub_contracted_items and self.purchase_items and not self.doc.is_subcontracted:
+ if not self.doc.is_subcontracted and self.sub_contracted_items:
webnotes.msgprint(_("""Please enter whether Purchase Recipt is made for subcontracting
or purchasing, in 'Is Subcontracted' field"""), raise_exception=1)
@@ -299,7 +299,7 @@
def update_raw_materials_supplied(self):
self.doclist = self.doc.clear_table(self.doclist, 'pr_raw_material_details')
- if self.sub_contracted_items:
+ if self.doc.is_subcontracted=="Yes":
for item in self.doclist.get({"parentfield": "purchase_receipt_details"}):
if item.item_code in self.sub_contracted_items:
self.add_bom_items(item)