Merge pull request #3718 from rmehta/item-cleanup
[cleanup] yes/no selects changed to checks in Item
diff --git a/erpnext/hr/doctype/offer_letter/offer_letter.json b/erpnext/hr/doctype/offer_letter/offer_letter.json
index ec93bb0..6f60a33 100644
--- a/erpnext/hr/doctype/offer_letter/offer_letter.json
+++ b/erpnext/hr/doctype/offer_letter/offer_letter.json
@@ -1,193 +1,193 @@
{
- "allow_copy": 0,
- "allow_import": 1,
- "allow_rename": 0,
- "autoname": "Offer-.#####",
- "creation": "2015-03-04 14:20:17.662207",
- "custom": 0,
- "default_print_format": "Offer Letter",
- "docstatus": 0,
- "doctype": "DocType",
- "document_type": "Transaction",
+ "allow_copy": 0,
+ "allow_import": 1,
+ "allow_rename": 0,
+ "autoname": "Offer-.#####",
+ "creation": "2015-03-04 14:20:17.662207",
+ "custom": 0,
+ "default_print_format": "Offer Letter",
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "Transaction",
"fields": [
{
- "allow_on_submit": 0,
- "fieldname": "job_applicant",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Job Applicant",
- "no_copy": 0,
- "options": "Job Applicant",
- "permlevel": 0,
- "precision": "",
- "print_hide": 1,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
+ "allow_on_submit": 0,
+ "fieldname": "job_applicant",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Job Applicant",
+ "no_copy": 0,
+ "options": "Job Applicant",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 0,
"set_only_once": 0
- },
+ },
{
- "fieldname": "applicant_name",
- "fieldtype": "Data",
- "label": "Applicant Name",
- "options": "job_applicant.applicant_name",
- "permlevel": 0,
- "precision": "",
- "read_only": 1,
+ "fieldname": "applicant_name",
+ "fieldtype": "Data",
+ "label": "Applicant Name",
+ "options": "job_applicant.applicant_name",
+ "permlevel": 0,
+ "precision": "",
+ "read_only": 1,
"reqd": 1
- },
+ },
{
- "fieldname": "column_break_3",
- "fieldtype": "Column Break",
- "permlevel": 0,
+ "fieldname": "column_break_3",
+ "fieldtype": "Column Break",
+ "permlevel": 0,
"precision": ""
- },
+ },
{
- "allow_on_submit": 1,
- "fieldname": "status",
- "fieldtype": "Select",
- "label": "Status",
- "options": "Awaiting Response\nAccepted\nRejected ",
- "permlevel": 0,
- "precision": "",
+ "allow_on_submit": 1,
+ "fieldname": "status",
+ "fieldtype": "Select",
+ "label": "Status",
+ "options": "Awaiting Response\nAccepted\nRejected",
+ "permlevel": 0,
+ "precision": "",
"print_hide": 1
- },
+ },
{
- "default": "",
- "fieldname": "offer_date",
- "fieldtype": "Date",
- "label": "Offer Date",
- "permlevel": 0,
+ "default": "",
+ "fieldname": "offer_date",
+ "fieldtype": "Date",
+ "label": "Offer Date",
+ "permlevel": 0,
"precision": ""
- },
+ },
{
- "allow_on_submit": 0,
- "fieldname": "designation",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Designation",
- "no_copy": 0,
- "options": "Designation",
- "permlevel": 0,
- "precision": "",
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
+ "allow_on_submit": 0,
+ "fieldname": "designation",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Designation",
+ "no_copy": 0,
+ "options": "Designation",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 0,
"set_only_once": 0
- },
+ },
{
- "fieldname": "company",
- "fieldtype": "Link",
- "label": "Company",
- "options": "Company",
- "permlevel": 0,
- "precision": "",
- "print_hide": 1,
+ "fieldname": "company",
+ "fieldtype": "Link",
+ "label": "Company",
+ "options": "Company",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
"reqd": 1
- },
+ },
{
- "fieldname": "section_break_4",
- "fieldtype": "Section Break",
- "permlevel": 0,
+ "fieldname": "section_break_4",
+ "fieldtype": "Section Break",
+ "permlevel": 0,
"precision": ""
- },
+ },
{
- "fieldname": "offer_terms",
- "fieldtype": "Table",
- "label": "Offer Letter Terms",
- "options": "Offer Letter Term",
- "permlevel": 0,
+ "fieldname": "offer_terms",
+ "fieldtype": "Table",
+ "label": "Offer Letter Terms",
+ "options": "Offer Letter Term",
+ "permlevel": 0,
"precision": ""
- },
+ },
{
- "fieldname": "section_break_14",
- "fieldtype": "Section Break",
- "permlevel": 0,
+ "fieldname": "section_break_14",
+ "fieldtype": "Section Break",
+ "permlevel": 0,
"precision": ""
- },
+ },
{
- "allow_on_submit": 0,
- "fieldname": "select_terms",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Select Terms and Conditions",
- "no_copy": 0,
- "options": "Terms and Conditions",
- "permlevel": 0,
- "precision": "",
- "print_hide": 1,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
+ "allow_on_submit": 0,
+ "fieldname": "select_terms",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 0,
+ "in_list_view": 0,
+ "label": "Select Terms and Conditions",
+ "no_copy": 0,
+ "options": "Terms and Conditions",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "read_only": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
"set_only_once": 0
- },
+ },
{
- "fieldname": "terms",
- "fieldtype": "Text Editor",
- "label": "Terms and Conditions",
- "options": "",
- "permlevel": 0,
+ "fieldname": "terms",
+ "fieldtype": "Text Editor",
+ "label": "Terms and Conditions",
+ "options": "",
+ "permlevel": 0,
"precision": ""
- },
+ },
{
- "fieldname": "amended_from",
- "fieldtype": "Link",
- "label": "Amended From",
- "no_copy": 1,
- "options": "Offer Letter",
- "permlevel": 0,
- "print_hide": 1,
+ "fieldname": "amended_from",
+ "fieldtype": "Link",
+ "label": "Amended From",
+ "no_copy": 1,
+ "options": "Offer Letter",
+ "permlevel": 0,
+ "print_hide": 1,
"read_only": 1
}
- ],
- "hide_heading": 0,
- "hide_toolbar": 0,
- "in_create": 0,
- "in_dialog": 0,
- "is_submittable": 1,
- "issingle": 0,
- "istable": 0,
- "modified": "2015-04-01 05:51:39.841591",
- "modified_by": "Administrator",
- "module": "HR",
- "name": "Offer Letter",
- "name_case": "",
- "owner": "Administrator",
+ ],
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "in_create": 0,
+ "in_dialog": 0,
+ "is_submittable": 1,
+ "issingle": 0,
+ "istable": 0,
+ "modified": "2015-07-29 05:51:39.841591",
+ "modified_by": "Administrator",
+ "module": "HR",
+ "name": "Offer Letter",
+ "name_case": "",
+ "owner": "Administrator",
"permissions": [
{
- "amend": 1,
- "cancel": 1,
- "create": 1,
- "delete": 1,
- "email": 1,
- "export": 1,
- "import": 1,
- "permlevel": 0,
- "print": 1,
- "read": 1,
- "report": 1,
- "role": "HR User",
- "share": 1,
- "submit": 1,
+ "amend": 1,
+ "cancel": 1,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "import": 1,
+ "permlevel": 0,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "HR User",
+ "share": 1,
+ "submit": 1,
"write": 1
}
- ],
- "read_only": 0,
- "read_only_onload": 0,
- "sort_field": "modified",
- "sort_order": "DESC",
+ ],
+ "read_only": 0,
+ "read_only_onload": 0,
+ "sort_field": "modified",
+ "sort_order": "DESC",
"title_field": "applicant_name"
-}
\ No newline at end of file
+}
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index ccbba15..9aab96d 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -364,7 +364,7 @@
if self.with_operations and not self.get('operations'):
frappe.throw(_("Operations cannot be left blank."))
-def get_bom_items_as_dict(bom, qty=1, fetch_exploded=1):
+def get_bom_items_as_dict(bom, company, qty=1, fetch_exploded=1):
item_dict = {}
# Did not use qty_consumed_per_unit in the query, as it leads to rounding loss
@@ -405,11 +405,18 @@
else:
item_dict[item.item_code] = item
+ for item, item_details in item_dict.items():
+ for d in [["Account", "expense_account", "default_expense_account"],
+ ["Cost Center", "cost_center", "cost_center"], ["Warehouse", "default_warehouse", ""]]:
+ company_in_record = frappe.db.get_value(d[0], item_details.get(d[1]), "company")
+ if not item_details.get(d[1]) or (company_in_record and company != company_in_record):
+ item_dict[item][d[1]] = frappe.db.get_value("Company", company, d[2]) if d[2] else None
+
return item_dict
@frappe.whitelist()
-def get_bom_items(bom, qty=1, fetch_exploded=1):
- items = get_bom_items_as_dict(bom, qty, fetch_exploded).values()
+def get_bom_items(bom, company, qty=1, fetch_exploded=1):
+ items = get_bom_items_as_dict(bom, company, qty, fetch_exploded).values()
items.sort(lambda a, b: a.item_code > b.item_code and 1 or -1)
return items
diff --git a/erpnext/manufacturing/doctype/bom/test_bom.py b/erpnext/manufacturing/doctype/bom/test_bom.py
index 528c626..4e520ef 100644
--- a/erpnext/manufacturing/doctype/bom/test_bom.py
+++ b/erpnext/manufacturing/doctype/bom/test_bom.py
@@ -12,14 +12,14 @@
class TestBOM(unittest.TestCase):
def test_get_items(self):
from erpnext.manufacturing.doctype.bom.bom import get_bom_items_as_dict
- items_dict = get_bom_items_as_dict(bom=get_default_bom(), qty=1, fetch_exploded=0)
+ items_dict = get_bom_items_as_dict(bom=get_default_bom(), company="_Test Company", qty=1, fetch_exploded=0)
self.assertTrue(test_records[2]["items"][0]["item_code"] in items_dict)
self.assertTrue(test_records[2]["items"][1]["item_code"] in items_dict)
self.assertEquals(len(items_dict.values()), 2)
def test_get_items_exploded(self):
from erpnext.manufacturing.doctype.bom.bom import get_bom_items_as_dict
- items_dict = get_bom_items_as_dict(bom=get_default_bom(), qty=1, fetch_exploded=1)
+ items_dict = get_bom_items_as_dict(bom=get_default_bom(), company="_Test Company", qty=1, fetch_exploded=1)
self.assertTrue(test_records[2]["items"][0]["item_code"] in items_dict)
self.assertFalse(test_records[2]["items"][1]["item_code"] in items_dict)
self.assertTrue(test_records[0]["items"][0]["item_code"] in items_dict)
@@ -28,7 +28,7 @@
def test_get_items_list(self):
from erpnext.manufacturing.doctype.bom.bom import get_bom_items
- self.assertEquals(len(get_bom_items(bom=get_default_bom())), 3)
+ self.assertEquals(len(get_bom_items(bom=get_default_bom(), company="_Test Company")), 3)
def test_default_bom(self):
def _get_default_bom_in_item():
diff --git a/erpnext/setup/doctype/naming_series/naming_series.js b/erpnext/setup/doctype/naming_series/naming_series.js
index e781754..5917f52 100644
--- a/erpnext/setup/doctype/naming_series/naming_series.js
+++ b/erpnext/setup/doctype/naming_series/naming_series.js
@@ -1,7 +1,10 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
+
cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
+ cur_frm.disable_save();
+ cur_frm.toolbar.print_icon.addClass("hide");
return cur_frm.call({
doc: cur_frm.doc,
method: 'get_transactions',
@@ -18,7 +21,7 @@
}
cur_frm.cscript.select_doc_for_series = function(doc, cdt, cdn) {
- cur_frm.toggle_display(['help_html','set_options', 'user_must_always_select', 'update'],
+ cur_frm.toggle_display(['help_html','set_options', 'user_must_always_select', 'update'],
doc.select_doc_for_series);
var callback = function(r, rt){
@@ -40,4 +43,4 @@
return cur_frm.call_server('get_current', '', function(r) {
refresh_field('current_value');
});
-}
\ No newline at end of file
+}
diff --git a/erpnext/stock/doctype/item_price/item_price.json b/erpnext/stock/doctype/item_price/item_price.json
index b4e84f1..546723a 100644
--- a/erpnext/stock/doctype/item_price/item_price.json
+++ b/erpnext/stock/doctype/item_price/item_price.json
@@ -1,157 +1,158 @@
{
- "allow_import": 1,
- "autoname": "ITEM-PRICE-.#####",
- "creation": "2013-05-02 16:29:48",
- "description": "Multiple Item prices.",
- "docstatus": 0,
- "doctype": "DocType",
+ "allow_import": 1,
+ "autoname": "ITEM-PRICE-.#####",
+ "creation": "2013-05-02 16:29:48",
+ "description": "Multiple Item prices.",
+ "docstatus": 0,
+ "doctype": "DocType",
"document_type": "Master",
"fields": [
{
- "fieldname": "price_list_details",
- "fieldtype": "Section Break",
- "label": "Price List",
- "options": "icon-tags",
+ "fieldname": "price_list_details",
+ "fieldtype": "Section Break",
+ "label": "Price List",
+ "options": "icon-tags",
"permlevel": 0
- },
+ },
{
- "fieldname": "price_list",
- "fieldtype": "Link",
- "in_filter": 1,
- "in_list_view": 1,
- "label": "Price List",
- "options": "Price List",
- "permlevel": 0,
+ "fieldname": "price_list",
+ "fieldtype": "Link",
+ "in_filter": 1,
+ "in_list_view": 1,
+ "label": "Price List",
+ "options": "Price List",
+ "permlevel": 0,
"reqd": 1
- },
+ },
{
- "fieldname": "buying",
- "fieldtype": "Check",
- "in_list_view": 0,
- "label": "Buying",
- "permlevel": 0,
+ "fieldname": "buying",
+ "fieldtype": "Check",
+ "in_list_view": 0,
+ "label": "Buying",
+ "permlevel": 0,
"read_only": 1
- },
+ },
{
- "fieldname": "selling",
- "fieldtype": "Check",
- "in_list_view": 0,
- "label": "Selling",
- "permlevel": 0,
+ "fieldname": "selling",
+ "fieldtype": "Check",
+ "in_list_view": 0,
+ "label": "Selling",
+ "permlevel": 0,
"read_only": 1
- },
+ },
{
- "fieldname": "item_details",
- "fieldtype": "Section Break",
- "label": "",
- "options": "icon-tag",
+ "fieldname": "item_details",
+ "fieldtype": "Section Break",
+ "label": "",
+ "options": "icon-tag",
"permlevel": 0
- },
+ },
{
- "fieldname": "item_code",
- "fieldtype": "Link",
- "in_filter": 1,
- "in_list_view": 0,
- "label": "Item Code",
- "oldfieldname": "price_list_name",
- "oldfieldtype": "Select",
- "options": "Item",
- "permlevel": 0,
- "reqd": 1,
+ "fieldname": "item_code",
+ "fieldtype": "Link",
+ "in_filter": 1,
+ "in_list_view": 0,
+ "label": "Item Code",
+ "oldfieldname": "price_list_name",
+ "oldfieldtype": "Select",
+ "options": "Item",
+ "permlevel": 0,
+ "reqd": 1,
"search_index": 1
- },
+ },
{
- "fieldname": "price_list_rate",
- "fieldtype": "Currency",
- "in_filter": 1,
- "in_list_view": 1,
- "label": "Rate",
- "oldfieldname": "ref_rate",
- "oldfieldtype": "Currency",
- "options": "currency",
- "permlevel": 0,
- "reqd": 1,
+ "fieldname": "price_list_rate",
+ "fieldtype": "Currency",
+ "in_filter": 1,
+ "in_list_view": 1,
+ "label": "Rate",
+ "oldfieldname": "ref_rate",
+ "oldfieldtype": "Currency",
+ "options": "currency",
+ "permlevel": 0,
+ "reqd": 1,
"search_index": 0
- },
+ },
{
- "fieldname": "currency",
- "fieldtype": "Link",
- "hidden": 0,
- "label": "Currency",
- "options": "Currency",
- "permlevel": 0,
+ "fieldname": "currency",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "in_list_view": 1,
+ "label": "Currency",
+ "options": "Currency",
+ "permlevel": 0,
"read_only": 1
- },
+ },
{
- "fieldname": "col_br_1",
- "fieldtype": "Column Break",
+ "fieldname": "col_br_1",
+ "fieldtype": "Column Break",
"permlevel": 0
- },
+ },
{
- "fieldname": "item_name",
- "fieldtype": "Data",
- "label": "Item Name",
- "permlevel": 0,
+ "fieldname": "item_name",
+ "fieldtype": "Data",
+ "label": "Item Name",
+ "permlevel": 0,
"read_only": 1
- },
+ },
{
- "fieldname": "item_description",
- "fieldtype": "Text",
- "label": "Item Description",
- "permlevel": 0,
+ "fieldname": "item_description",
+ "fieldtype": "Text",
+ "label": "Item Description",
+ "permlevel": 0,
"read_only": 1
- },
+ },
{
- "fieldname": "section_break_12",
- "fieldtype": "Section Break",
- "permlevel": 0,
+ "fieldname": "section_break_12",
+ "fieldtype": "Section Break",
+ "permlevel": 0,
"precision": ""
- },
+ },
{
- "fieldname": "bulk_import_help",
- "fieldtype": "HTML",
- "label": "Bulk Import Help",
- "permlevel": 0,
+ "fieldname": "bulk_import_help",
+ "fieldtype": "HTML",
+ "label": "Bulk Import Help",
+ "permlevel": 0,
"precision": ""
}
- ],
- "icon": "icon-flag",
- "idx": 1,
- "in_create": 0,
- "istable": 0,
- "modified": "2015-05-26 03:15:02.324161",
- "modified_by": "Administrator",
- "module": "Stock",
- "name": "Item Price",
- "owner": "Administrator",
+ ],
+ "icon": "icon-flag",
+ "idx": 1,
+ "in_create": 0,
+ "istable": 0,
+ "modified": "2015-07-29 14:53:58.851413",
+ "modified_by": "Administrator",
+ "module": "Stock",
+ "name": "Item Price",
+ "owner": "Administrator",
"permissions": [
{
- "cancel": 0,
- "create": 1,
- "delete": 1,
- "email": 1,
- "permlevel": 0,
- "print": 1,
- "read": 1,
- "report": 1,
- "role": "Sales Master Manager",
- "share": 1,
+ "cancel": 0,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "permlevel": 0,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Sales Master Manager",
+ "share": 1,
"write": 1
- },
+ },
{
- "cancel": 0,
- "create": 1,
- "delete": 1,
- "email": 1,
- "permlevel": 0,
- "print": 1,
- "read": 1,
- "report": 1,
- "role": "Purchase Master Manager",
- "share": 1,
+ "cancel": 0,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "permlevel": 0,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Purchase Master Manager",
+ "share": 1,
"write": 1
}
- ],
- "read_only": 0,
+ ],
+ "read_only": 0,
"title_field": "item_code"
-}
\ 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 4f1e1a8..babe671 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -553,7 +553,7 @@
from erpnext.manufacturing.doctype.bom.bom import get_bom_items_as_dict
# item dict = { item_code: {qty, description, stock_uom} }
- item_dict = get_bom_items_as_dict(self.bom_no, qty=qty, fetch_exploded = self.use_multi_level_bom)
+ item_dict = get_bom_items_as_dict(self.bom_no, self.company, qty=qty, fetch_exploded = self.use_multi_level_bom)
for item in item_dict.values():
item.from_warehouse = self.from_warehouse or item.default_warehouse
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
index 5d5b1f0..e178f28 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
@@ -163,16 +163,17 @@
})
if previous_sle:
if row.qty in ("", None):
- row.qty = previous_sle.get("qty_after_transaction")
+ row.qty = previous_sle.get("qty_after_transaction", 0)
if row.valuation_rate in ("", None):
- row.valuation_rate = previous_sle.get("valuation_rate")
+ row.valuation_rate = previous_sle.get("valuation_rate", 0)
if row.qty and not row.valuation_rate:
frappe.throw(_("Valuation Rate required for Item {0}").format(row.item_code))
- if previous_sle and row.qty == previous_sle.get("qty_after_transaction") \
- and row.valuation_rate == previous_sle.get("valuation_rate"):
+ if ((previous_sle and row.qty == previous_sle.get("qty_after_transaction")
+ and row.valuation_rate == previous_sle.get("valuation_rate"))
+ or (not previous_sle and not row.qty)):
continue
self.insert_entries(row)