Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index c4ed73c..af9de92 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -421,8 +421,8 @@
 				raise Exception
 
 	def validate_pos(self):
-		if not self.doc.cash_bank_account:
-			msgprint("Cash/Bank Account is mandatory for POS entry")
+		if not self.doc.cash_bank_account and flt(self.doc.paid_amount):
+			msgprint("Cash/Bank Account is mandatory for POS, for making payment entry")
 			raise Exception
 		if (flt(self.doc.paid_amount) + flt(self.doc.write_off_amount) - round(flt(self.doc.grand_total), 2))>0.001:
 			msgprint("(Paid amount + Write Off Amount) can not be greater than Grand Total")
@@ -676,8 +676,14 @@
 					if not d.warehouse:
 						d.warehouse = cstr(w)
 
-			if flt(self.doc.paid_amount) == 0: 
-				webnotes.conn.set(self.doc,'paid_amount',(flt(self.doc.grand_total) - flt(self.doc.write_off_amount)))
+			if flt(self.doc.paid_amount) == 0:
+				if self.doc.cash_bank_account: 
+					webnotes.conn.set(self.doc, 'paid_amount', 
+						(flt(self.doc.grand_total) - flt(self.doc.write_off_amount)))
+				else:
+					# show message that the amount is not paid
+					webnotes.conn.set(self.doc,'paid_amount',0)
+					webnotes.msgprint("Note: Payment Entry not created since 'Cash/Bank Account' was not specified.")
 
 		else:
 			webnotes.conn.set(self.doc,'paid_amount',0)
diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.py b/erpnext/buying/doctype/purchase_common/purchase_common.py
index 5157f7c..e230e0f 100644
--- a/erpnext/buying/doctype/purchase_common/purchase_common.py
+++ b/erpnext/buying/doctype/purchase_common/purchase_common.py
@@ -407,9 +407,21 @@
 		if not default_currency:
 			msgprint('Message: Please enter default currency in Company Master')
 			raise Exception
-		if (obj.doc.currency == default_currency and flt(obj.doc.conversion_rate) != 1.00) or not obj.doc.conversion_rate or (obj.doc.currency != default_currency and flt(obj.doc.conversion_rate) == 1.00):
-			msgprint("Message: Please Enter Appropriate Conversion Rate.")
-			raise Exception
+			
+		if obj.doc.conversion_rate == 0:
+			msgprint('Conversion Rate cannot be 0', raise_exception=1)
+		elif not obj.doc.conversion_rate:
+			msgprint('Please specify Conversion Rate', raise_exception=1)
+		elif obj.doc.currency == default_currency and \
+				flt(obj.doc.conversion_rate) != 1.00:
+			msgprint("""Conversion Rate should be equal to 1.00, \
+						since the specified Currency and the company's currency \
+						are same""", raise_exception=1)
+		elif obj.doc.currency != default_currency and \
+				flt(obj.doc.conversion_rate) == 1.00:
+			msgprint("""Conversion Rate should not be equal to 1.00, \
+						since the specified Currency and the company's currency \
+						are different""", raise_exception=1)
 
 	def validate_doc(self, obj, prevdoc_doctype, prevdoc_docname):
 		if prevdoc_docname :
diff --git a/erpnext/production/doctype/production_order/production_order.txt b/erpnext/production/doctype/production_order/production_order.txt
index 62aa610..c244399 100644
--- a/erpnext/production/doctype/production_order/production_order.txt
+++ b/erpnext/production/doctype/production_order/production_order.txt
@@ -3,9 +3,9 @@
 
 	# These values are common in all dictionaries
 	{
-		'creation': '2012-03-27 14:36:05',
+		'creation': '2012-05-15 12:14:48',
 		'docstatus': 0,
-		'modified': '2012-03-27 14:45:50',
+		'modified': '2012-05-28 19:03:56',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -23,7 +23,7 @@
 		'section_style': u'Tabbed',
 		'server_code_error': u' ',
 		'show_in_menu': 0,
-		'version': 190
+		'version': 1
 	},
 
 	# These values are common for all DocField
@@ -323,6 +323,7 @@
 		'fieldname': u'produced_qty',
 		'fieldtype': u'Currency',
 		'label': u'Produced Qty',
+		'no_copy': 1,
 		'oldfieldname': u'produced_qty',
 		'oldfieldtype': u'Currency',
 		'permlevel': 1
diff --git a/erpnext/selling/doctype/sales_common/sales_common.py b/erpnext/selling/doctype/sales_common/sales_common.py
index 5975e32..7c5bfad 100644
--- a/erpnext/selling/doctype/sales_common/sales_common.py
+++ b/erpnext/selling/doctype/sales_common/sales_common.py
@@ -207,21 +207,32 @@
 			if default: add_cond = 'ifnull(t2.is_default,0) = 1'
 			else: add_cond = 't1.parent = "'+cstr(obj.doc.charge)+'"'
 			idx = 0
-			other_charge = webnotes.conn.sql("select t1.charge_type,t1.row_id,t1.description,t1.account_head,t1.rate,t1.tax_amount,t1.included_in_print_rate, t1.cost_center_other_charges from `tabSales Taxes and Charges` t1, `tabSales Taxes and Charges Master` t2 where t1.parent = t2.name and t2.company = '%s' and %s order by t1.idx" % (obj.doc.company, add_cond), as_dict = 1)
+			other_charge = webnotes.conn.sql("""\
+				select t1.*
+				from
+					`tabSales Taxes and Charges` t1,
+					`tabSales Taxes and Charges Master` t2
+				where
+					t1.parent = t2.name and
+					t2.company = '%s' and
+					%s
+				order by t1.idx""" % (obj.doc.company, add_cond), as_dict=1)
+			from webnotes.model import default_fields
 			for other in other_charge:
-				d =	addchild(obj.doc, 'other_charges', 'Sales Taxes and Charges', 1, obj.doclist)
-				d.charge_type = other['charge_type']
-				d.row_id = other['row_id']
-				d.description = other['description']
-				d.account_head = other['account_head']
-				d.cost_center_other_charges = other['cost_center_other_charges']
-				d.rate = flt(other['rate'])
-				d.tax_amount = flt(other['tax_amount'])
-				d.included_in_print_rate = cint(other['included_in_print_rate'])
+				# remove default fields like parent, parenttype etc.
+				# from query results
+				for field in default_fields:
+					if field in other: del other[field]
+
+				d = addchild(obj.doc, 'other_charges', 'Sales Taxes and Charges', 1,
+						obj.doclist)
+				d.fields.update(other)
+				d.rate = flt(d.rate)
+				d.tax_amount = flt(d.tax_rate)
+				d.included_in_print_rate = cint(d.included_in_print_rate)
 				d.idx = idx
 				idx += 1
 			
-			
 	# Get TERMS AND CONDITIONS
 	# =======================================================================================
 	def get_tc_details(self,obj):