BugFix: use transfer_qty instead of actual_qty in check_duplicate_entry_for_production_order - ported webnotes/erpnext@942ff2583b3f68d921c6506179f7ee5909ba1954
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 7fc686b..2e3942e 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -30,6 +30,7 @@
 		pro_obj = self.production_order and \
 			frappe.get_doc('Production Order', self.production_order) or None
 
+		self.set_transfer_qty()
 		self.validate_item()
 		self.validate_uom_is_integer("uom", "qty")
 		self.validate_uom_is_integer("stock_uom", "transfer_qty")
@@ -68,6 +69,10 @@
 		if self.purpose not in valid_purposes:
 			frappe.throw(_("Purpose must be one of {0}").format(comma_or(valid_purposes)))
 
+	def set_transfer_qty(self):
+		for item in self.get("mtn_details"):
+			item.transfer_qty = flt(item.qty * item.conversion_factor, self.precision("transfer_qty", item))
+
 	def validate_item(self):
 		stock_items = self.get_stock_items()
 		for item in self.get("mtn_details"):
@@ -157,7 +162,7 @@
 			production_item, qty = frappe.db.get_value("Production Order",
 				self.production_order, ["production_item", "qty"])
 			args = other_ste + [production_item]
-			fg_qty_already_entered = frappe.db.sql("""select sum(actual_qty)
+			fg_qty_already_entered = frappe.db.sql("""select sum(transfer_qty)
 				from `tabStock Entry Detail`
 				where parent in (%s)
 					and item_code = %s