Merge pull request #3912 from nabinhait/jv1
[fix] payment amt against invoice outstanding
diff --git a/erpnext/__version__.py b/erpnext/__version__.py
index 90d02c9..0246af2 100644
--- a/erpnext/__version__.py
+++ b/erpnext/__version__.py
@@ -1,2 +1,2 @@
from __future__ import unicode_literals
-__version__ = '5.7.0'
+__version__ = '5.7.5'
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 2c9e7d4..c7600df 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -215,14 +215,15 @@
"""Returns list of advances against Account, Party, Reference"""
order_list = list(set([d.get(against_order_field) for d in self.get("items") if d.get(against_order_field)]))
- if not order_list:
- return
-
- in_placeholder = ', '.join(['%s'] * len(order_list))
-
# conver sales_order to "Sales Order"
reference_type = against_order_field.replace("_", " ").title()
-
+
+ condition = ""
+ if order_list:
+ in_placeholder = ', '.join(['%s'] * len(order_list))
+ condition = "or (t2.reference_type = '{0}' and ifnull(t2.reference_name, '') in ({1}))"\
+ .format(reference_type, in_placeholder)
+
res = frappe.db.sql("""
select
t1.name as jv_no, t1.remark, t2.{0} as amount, t2.name as jv_detail_no,
@@ -233,11 +234,9 @@
t1.name = t2.parent and t2.account = %s
and t2.party_type = %s and t2.party = %s
and t2.is_advance = 'Yes' and t1.docstatus = 1
- and (
- ifnull(t2.reference_type, '')=''
- or (t2.reference_type = %s and ifnull(t2.reference_name, '') in ({1})))
- order by t1.posting_date""".format(dr_or_cr, in_placeholder),
- [account_head, party_type, party, reference_type] + order_list, as_dict=1)
+ and (ifnull(t2.reference_type, '')='' {1})
+ order by t1.posting_date""".format(dr_or_cr, condition),
+ [account_head, party_type, party] + order_list, as_dict=1)
self.set(parentfield, [])
for d in res:
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 0fdbda1..2a116ca 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -27,7 +27,7 @@
"""
app_icon = "icon-th"
app_color = "#e74c3c"
-app_version = "5.7.0"
+app_version = "5.7.5"
github_link = "https://github.com/frappe/erpnext"
error_report_email = "support@erpnext.com"
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 551518e..21656c6 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -191,5 +191,5 @@
erpnext.patches.v5_4.cleanup_journal_entry #2015-08-14
execute:frappe.db.sql("update `tabProduction Order` pro set description = (select description from tabItem where name=pro.production_item) where ifnull(description, '') = ''")
erpnext.patches.v5_7.item_template_attributes
-erpnext.patches.v4_2.repost_reserved_qty #2015-08-17
+erpnext.patches.v4_2.repost_reserved_qty #2015-08-20
erpnext.patches.v5_4.update_purchase_cost_against_project
diff --git a/erpnext/patches/v4_2/repost_reserved_qty.py b/erpnext/patches/v4_2/repost_reserved_qty.py
index f91968c..a2cd4d8 100644
--- a/erpnext/patches/v4_2/repost_reserved_qty.py
+++ b/erpnext/patches/v4_2/repost_reserved_qty.py
@@ -18,10 +18,18 @@
select distinct item_code, warehouse
from `tabPacked Item` where docstatus=1 and parenttype='Sales Order'
)
- ) items
+ ) so_item
+ where
+ exists(select name from tabItem where name=so_item.item_code and ifnull(is_stock_item, 0)=1)
""")
-
+
for item_code, warehouse in repost_for:
update_bin_qty(item_code, warehouse, {
"reserved_qty": get_reserved_qty(item_code, warehouse)
- })
\ No newline at end of file
+ })
+
+ frappe.db.sql("""delete from tabBin
+ where exists(
+ select name from tabItem where name=tabBin.item_code and ifnull(is_stock_item, 0) = 0
+ )
+ """)
\ No newline at end of file
diff --git a/erpnext/patches/v5_7/item_template_attributes.py b/erpnext/patches/v5_7/item_template_attributes.py
index f001244..e93bfe4 100644
--- a/erpnext/patches/v5_7/item_template_attributes.py
+++ b/erpnext/patches/v5_7/item_template_attributes.py
@@ -39,7 +39,7 @@
frappe.rename_doc("DocType", "Variant Attribute", "Item Variant Attribute")
frappe.reload_doctype("Item")
- frappe.reload_doctype("Item Variant Attribute")
+ frappe.reload_doc("Stock", "DocType", "Item Variant Attribute")
frappe.reload_doctype("Item Attribute Value")
frappe.reload_doctype("Item Attribute")
@@ -65,6 +65,12 @@
item_attributes = frappe.db.sql("""select distinct item_attribute, item_attribute_value
from `tabItem Variant` where parent=%s""", item.name)
+ if not item_attributes and not all_variants:
+ item = frappe.get_doc("Item", item.name)
+ item.has_variants = 0
+ item.save()
+ continue
+
attribute_value_options = {}
for attribute, value in item_attributes:
attribute_value_options.setdefault(attribute, []).append(value)
diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js
index e95babe..e32080a 100644
--- a/erpnext/stock/doctype/item/item.js
+++ b/erpnext/stock/doctype/item/item.js
@@ -311,6 +311,7 @@
toggle_attributes: function(frm) {
frm.toggle_display("attributes", frm.doc.has_variants || frm.doc.variant_of);
frm.fields_dict.attributes.grid.toggle_reqd("attribute_value", frm.doc.variant_of ? 1 : 0);
+ frm.fields_dict.attributes.grid.set_column_disp("attribute_value", frm.doc.variant_of ? 1 : 0);
}
});
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index cd3d295..f9b41f1 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -64,7 +64,7 @@
self.update_item_desc()
self.synced_with_hub = 0
self.validate_has_variants()
- self.validate_stock_for_template_must_be_zero()
+ # self.validate_stock_for_template_must_be_zero()
self.validate_attributes()
self.validate_variant_attributes()
diff --git a/erpnext/stock/doctype/item/test_item.py b/erpnext/stock/doctype/item/test_item.py
index 2ba9647..f7c0f40 100644
--- a/erpnext/stock/doctype/item/test_item.py
+++ b/erpnext/stock/doctype/item/test_item.py
@@ -46,11 +46,11 @@
item = frappe.get_doc("Item", item_code)
return item
- def test_template_cannot_have_stock(self):
- item = self.get_item(10)
- make_stock_entry(item_code=item.name, target="Stores - _TC", qty=1, basic_rate=1)
- item.has_variants = 1
- self.assertRaises(ItemTemplateCannotHaveStock, item.save)
+ # def test_template_cannot_have_stock(self):
+ # item = self.get_item(10)
+ # make_stock_entry(item_code=item.name, target="Stores - _TC", qty=1, basic_rate=1)
+ # item.has_variants = 1
+ # self.assertRaises(ItemTemplateCannotHaveStock, item.save)
def test_default_warehouse(self):
item = frappe.copy_doc(test_records[0])
diff --git a/erpnext/stock/doctype/item_variant_attribute/item_variant_attribute.json b/erpnext/stock/doctype/item_variant_attribute/item_variant_attribute.json
index 7ab21e1..99988ae 100644
--- a/erpnext/stock/doctype/item_variant_attribute/item_variant_attribute.json
+++ b/erpnext/stock/doctype/item_variant_attribute/item_variant_attribute.json
@@ -1,217 +1,217 @@
{
- "allow_copy": 0,
- "allow_import": 1,
- "allow_rename": 0,
- "autoname": "",
- "creation": "2015-05-19 05:12:30.344797",
- "custom": 0,
- "docstatus": 0,
- "doctype": "DocType",
- "document_type": "Other",
+ "allow_copy": 0,
+ "allow_import": 1,
+ "allow_rename": 0,
+ "autoname": "",
+ "creation": "2015-05-19 05:12:30.344797",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "Other",
"fields": [
{
- "allow_on_submit": 0,
- "fieldname": "attribute",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 1,
- "label": "Attribute",
- "no_copy": 0,
- "options": "Item Attribute",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
+ "allow_on_submit": 0,
+ "fieldname": "attribute",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 1,
+ "label": "Attribute",
+ "no_copy": 0,
+ "options": "Item Attribute",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 0,
+ "set_only_once": 0,
"unique": 0
- },
+ },
{
- "allow_on_submit": 0,
- "fieldname": "column_break_2",
- "fieldtype": "Column Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
+ "allow_on_submit": 0,
+ "fieldname": "column_break_2",
+ "fieldtype": "Column Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
"unique": 0
- },
+ },
{
- "allow_on_submit": 0,
- "depends_on": "",
- "fieldname": "attribute_value",
- "fieldtype": "Data",
- "hidden": 1,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 1,
- "label": "Attribute Value",
- "no_copy": 0,
- "options": "",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
+ "allow_on_submit": 0,
+ "depends_on": "",
+ "fieldname": "attribute_value",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 1,
+ "label": "Attribute Value",
+ "no_copy": 0,
+ "options": "",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
"unique": 0
- },
+ },
{
- "allow_on_submit": 0,
- "depends_on": "has_variants",
- "fieldname": "numeric_values",
- "fieldtype": "Check",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Numeric Values",
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
+ "allow_on_submit": 0,
+ "depends_on": "has_variants",
+ "fieldname": "numeric_values",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Numeric Values",
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
"unique": 0
- },
+ },
{
- "allow_on_submit": 0,
- "depends_on": "numeric_values",
- "fieldname": "section_break_4",
- "fieldtype": "Section Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
+ "allow_on_submit": 0,
+ "depends_on": "numeric_values",
+ "fieldname": "section_break_4",
+ "fieldtype": "Section Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
"unique": 0
- },
+ },
{
- "allow_on_submit": 0,
- "depends_on": "",
- "fieldname": "from_range",
- "fieldtype": "Float",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "From Range",
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
+ "allow_on_submit": 0,
+ "depends_on": "",
+ "fieldname": "from_range",
+ "fieldtype": "Float",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "From Range",
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
"unique": 0
- },
+ },
{
- "allow_on_submit": 0,
- "depends_on": "",
- "fieldname": "increment",
- "fieldtype": "Float",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Increment",
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
+ "allow_on_submit": 0,
+ "depends_on": "",
+ "fieldname": "increment",
+ "fieldtype": "Float",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Increment",
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
"unique": 0
- },
+ },
{
- "allow_on_submit": 0,
- "fieldname": "column_break_8",
- "fieldtype": "Column Break",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
+ "allow_on_submit": 0,
+ "fieldname": "column_break_8",
+ "fieldtype": "Column Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
"unique": 0
- },
+ },
{
- "allow_on_submit": 0,
- "depends_on": "",
- "fieldname": "to_range",
- "fieldtype": "Float",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "To Range",
- "no_copy": 0,
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
+ "allow_on_submit": 0,
+ "depends_on": "",
+ "fieldname": "to_range",
+ "fieldtype": "Float",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "To Range",
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
"unique": 0
}
- ],
- "hide_heading": 0,
- "hide_toolbar": 0,
- "icon": "",
- "in_create": 0,
- "in_dialog": 0,
- "is_submittable": 0,
- "issingle": 0,
- "istable": 1,
- "modified": "2015-08-18 02:47:07.959104",
- "modified_by": "Administrator",
- "module": "Stock",
- "name": "Item Variant Attribute",
- "name_case": "",
- "owner": "Administrator",
- "permissions": [],
- "read_only": 0,
- "read_only_onload": 0,
- "sort_field": "modified",
+ ],
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "icon": "",
+ "in_create": 0,
+ "in_dialog": 0,
+ "is_submittable": 0,
+ "issingle": 0,
+ "istable": 1,
+ "modified": "2015-08-20 02:20:42.553048",
+ "modified_by": "Administrator",
+ "module": "Stock",
+ "name": "Item Variant Attribute",
+ "name_case": "",
+ "owner": "Administrator",
+ "permissions": [],
+ "read_only": 0,
+ "read_only_onload": 0,
+ "sort_field": "modified",
"sort_order": "DESC"
-}
+}
\ No newline at end of file
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 59a68b7..cdfdc78 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -80,7 +80,8 @@
for item in self.get("items"):
if not flt(item.qty):
frappe.throw(_("Row {0}: Qty is mandatory").format(item.idx))
-
+ if not flt(item.conversion_factor):
+ frappe.throw(_("Row {0}: UOM Conversion Factor is mandatory").format(item.idx))
item.transfer_qty = flt(item.qty * item.conversion_factor, self.precision("transfer_qty", item))
def validate_item(self):
diff --git a/setup.py b/setup.py
index 5c92ec0..9ef03d2 100644
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages
-version = "5.7.0"
+version = "5.7.5"
with open("requirements.txt", "r") as f:
install_requires = f.readlines()