Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/accounts/doctype/gl_entry/gl_entry.py b/accounts/doctype/gl_entry/gl_entry.py
index 1d0ec8e..60c37a4 100644
--- a/accounts/doctype/gl_entry/gl_entry.py
+++ b/accounts/doctype/gl_entry/gl_entry.py
@@ -151,7 +151,7 @@
balance = webnotes.conn.sql("""select sum(debit) - sum(credit) from `tabGL Entry`
where account = %s and ifnull(is_cancelled, 'No') = 'No'""", self.doc.account)
balance = account["debit_or_credit"] == "Debit" and \
- balance[0][0] or -1*balance[0][0]
+ flt(balance[0][0]) or -1*flt(balance[0][0])
if flt(balance) < 0:
msgprint(_("Negative balance is not allowed for account ") + self.doc.account,
diff --git a/buying/doctype/purchase_common/purchase_common.py b/buying/doctype/purchase_common/purchase_common.py
index e14b1ca..d1da223 100644
--- a/buying/doctype/purchase_common/purchase_common.py
+++ b/buying/doctype/purchase_common/purchase_common.py
@@ -76,7 +76,11 @@
elif is_submit == 1:
# even if this transaction is the latest one, it should be submitted
# for it to be considered for latest purchase rate
- last_purchase_rate = flt(d.purchase_rate) / flt(d.conversion_factor)
+ if flt(d.conversion_factor):
+ last_purchase_rate = flt(d.purchase_rate) / flt(d.conversion_factor)
+ else:
+ msgprint(_("Row ") + cstr(d.idx) + ": " +
+ _("UOM Conversion Factor is mandatory"), raise_exception=1)
# update last purchsae rate
if last_purchase_rate:
diff --git a/selling/doctype/sales_order/sales_order.py b/selling/doctype/sales_order/sales_order.py
index 55abf9d..d578a43 100644
--- a/selling/doctype/sales_order/sales_order.py
+++ b/selling/doctype/sales_order/sales_order.py
@@ -375,7 +375,7 @@
target.amount = (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.basic_rate)
target.export_amount = (flt(obj.qty) - flt(obj.delivered_qty)) * flt(obj.export_rate)
target.qty = flt(obj.qty) - flt(obj.delivered_qty)
-
+
doclist = get_mapped_doclist("Sales Order", source_name, {
"Sales Order": {
"doctype": "Delivery Note",
@@ -396,7 +396,8 @@
"parenttype": "prevdoc_doctype",
"reserved_warehouse": "warehouse"
},
- "postprocess": update_item
+ "postprocess": update_item,
+ "condition": lambda doc: doc.delivered_qty < doc.qty
},
"Sales Taxes and Charges": {
"doctype": "Sales Taxes and Charges",
@@ -416,7 +417,7 @@
target.export_amount = flt(obj.export_amount) - flt(obj.billed_amt)
target.amount = target.export_amount * flt(source_parent.conversion_rate)
target.qty = obj.export_rate and target.export_amount / flt(obj.export_rate) or obj.qty
-
+
doclist = get_mapped_doclist("Sales Order", source_name, {
"Sales Order": {
"doctype": "Sales Invoice",
diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py
index 58f17c7..afa3eb4 100644
--- a/stock/doctype/stock_entry/stock_entry.py
+++ b/stock/doctype/stock_entry/stock_entry.py
@@ -554,7 +554,7 @@
`tabBOM Item`, `tabItem`
where
`tabBOM Item`.parent = %s and
- `tabBOM Item`.item_code = tabItem.name
+ `tabBOM Item`.item_code = tabItem.name and
`tabBOM Item`.docstatus < 2
group by item_code""", (qty, self.doc.bom_no), as_dict=1)