Merge pull request #3927 from neilLasrado/default-warehouse
Fetch default WIP Warehouse and FG Warehouse on load of Production Order
diff --git a/erpnext/__version__.py b/erpnext/__version__.py
index 084a388..cfdd2f7 100644
--- a/erpnext/__version__.py
+++ b/erpnext/__version__.py
@@ -1,2 +1,2 @@
from __future__ import unicode_literals
-__version__ = '5.7.6'
+__version__ = '5.7.7'
diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py
index 35c839f..1cc9f4f 100644
--- a/erpnext/accounts/report/general_ledger/general_ledger.py
+++ b/erpnext/accounts/report/general_ledger/general_ledger.py
@@ -61,7 +61,7 @@
return result
def get_gl_entries(filters):
- group_by_condition = "group by voucher_type, voucher_no, account" \
+ group_by_condition = "group by voucher_type, voucher_no, account, cost_center" \
if filters.get("group_by_voucher") else "group by name"
gl_entries = frappe.db.sql("""select posting_date, account, party_type, party,
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 3ae43fa..2a2d7c1 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -27,7 +27,7 @@
"""
app_icon = "icon-th"
app_color = "#e74c3c"
-app_version = "5.7.6"
+app_version = "5.7.7"
github_link = "https://github.com/frappe/erpnext"
error_report_email = "support@erpnext.com"
diff --git a/erpnext/patches/v5_4/stock_entry_additional_costs.py b/erpnext/patches/v5_4/stock_entry_additional_costs.py
index 325d6cf..3a98deb 100644
--- a/erpnext/patches/v5_4/stock_entry_additional_costs.py
+++ b/erpnext/patches/v5_4/stock_entry_additional_costs.py
@@ -10,12 +10,6 @@
frappe.reload_doctype("Stock Entry Detail")
frappe.reload_doctype("Landed Cost Taxes and Charges")
- frappe.db.sql("""update `tabStock Entry Detail` sed, `tabStock Entry` se
- set sed.valuation_rate=sed.incoming_rate, sed.basic_rate=sed.incoming_rate, sed.basic_amount=sed.amount
- where sed.parent = se.name
- and (se.purpose not in ('Manufacture', 'Repack') or ifnull(additional_operating_cost, 0)=0)
- """)
-
stock_entry_db_columns = frappe.db.get_table_columns("Stock Entry")
if "additional_operating_cost" in stock_entry_db_columns:
operating_cost_fieldname = "additional_operating_cost"
@@ -25,6 +19,13 @@
return
+ frappe.db.sql("""update `tabStock Entry Detail` sed, `tabStock Entry` se
+ set sed.valuation_rate=sed.incoming_rate, sed.basic_rate=sed.incoming_rate, sed.basic_amount=sed.amount
+ where sed.parent = se.name
+ and (se.purpose not in ('Manufacture', 'Repack') or ifnull({0}, 0)=0)
+ """.format(operating_cost_fieldname))
+
+
stock_entries = frappe.db.sql_list("""select name from `tabStock Entry`
where purpose in ('Manufacture', 'Repack') and ifnull({0}, 0)!=0
and docstatus < 2""".format(operating_cost_fieldname))
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index f9b41f1..659fb1b 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -513,12 +513,10 @@
filters={"parent": ["in", args.keys()]}):
(attribute_values.setdefault(t.parent, [])).append(t.attribute_value)
- numeric_attributes = frappe._dict((t.name, t) for t in frappe.get_list("Item Attribute", filters={"numeric_values":1,
- "name": ["in", args.keys()]}, fields=["name", "from_range", "to_range", "increment"]))
-
- template_item = frappe.get_doc("Item", item)
- template_item_attributes = frappe._dict((d.attribute, d) for d in template_item.attributes)
-
+ numeric_attributes = frappe._dict((t.attribute, t) for t in \
+ frappe.db.sql("""select attribute, from_range, to_range, increment from `tabItem Variant Attribute`
+ where parent = %s and numeric_values=1""", (item), as_dict=1))
+
for attribute, value in args.items():
if attribute in numeric_attributes:
@@ -531,10 +529,17 @@
if increment == 0:
# defensive validation to prevent ZeroDivisionError
frappe.throw(_("Increment for Attribute {0} cannot be 0").format(attribute))
+
+ is_in_range = from_range <= flt(value) <= to_range
+ precision = len(cstr(increment).split(".")[-1].rstrip("0"))
+ #avoid precision error by rounding the remainder
+ remainder = flt((flt(value) - from_range) % increment, precision)
+ is_incremental = remainder==0 or remainder==0 or remainder==increment
- if not ( (from_range <= flt(value) <= to_range) and (flt(value) - from_range) % increment == 0 ):
- frappe.throw(_("Value for Attribute {0} must be within the range of {1} to {2} in the increments of {3}").format(attribute, from_range, to_range, increment), InvalidItemAttributeValueError)
+ if not (is_in_range and is_incremental):
+ frappe.throw(_("Value for Attribute {0} must be within the range of {1} to {2} in the increments of {3}")\
+ .format(attribute, from_range, to_range, increment), InvalidItemAttributeValueError)
elif value not in attribute_values[attribute]:
frappe.throw(_("Value {0} for Attribute {1} does not exist in the list of valid Item Attribute Values").format(
diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py
index f7c0f40..9161015 100644
--- a/erpnext/stock/doctype/item/test_item.py
+++ b/erpnext/stock/doctype/item/test_item.py
@@ -6,9 +6,8 @@
import frappe
from frappe.test_runner import make_test_records
-from erpnext.stock.doctype.item.item import (WarehouseNotSet, ItemTemplateCannotHaveStock, create_variant,
+from erpnext.stock.doctype.item.item import (WarehouseNotSet, create_variant,
ItemVariantExistsError, InvalidItemAttributeValueError)
-from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
test_ignore = ["BOM"]
test_dependencies = ["Warehouse"]
@@ -129,8 +128,16 @@
# make template item
make_item("_Test Numeric Template Item", {
"attributes": [
- {"attribute": "Test Size"},
- {"attribute": "Test Item Length"}
+ {
+ "attribute": "Test Size"
+ },
+ {
+ "attribute": "Test Item Length",
+ "numeric_values": 1,
+ "from_range": 0.0,
+ "to_range": 100.0,
+ "increment": 0.5
+ }
],
"default_warehouse": "_Test Warehouse - _TC"
})
diff --git a/setup.py b/setup.py
index 7d4b20b..9ed46de 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages
-version = "5.7.6"
+version = "5.7.7"
with open("requirements.txt", "r") as f:
install_requires = f.readlines()