From b233e9d643da55ddc5ebd1f55ccef06087bb8e9a Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 16 May 2018 16:41:34 +0530 Subject: [PATCH] [Fix] Multiple fixes --- .../doctype/asset_movement/asset_movement.py | 5 +- erpnext/stock/doctype/item/item.js | 10 +-- erpnext/stock/doctype/item/item.json | 72 +++++++++---------- 3 files changed, 42 insertions(+), 45 deletions(-) diff --git a/erpnext/assets/doctype/asset_movement/asset_movement.py b/erpnext/assets/doctype/asset_movement/asset_movement.py index 32fc663837..e34d2a3066 100644 --- a/erpnext/assets/doctype/asset_movement/asset_movement.py +++ b/erpnext/assets/doctype/asset_movement/asset_movement.py @@ -14,16 +14,13 @@ class AssetMovement(Document): self.validate_warehouses() def validate_asset(self): - status, company, serial_no = frappe.db.get_value("Asset", self.asset, ["status", "company", "serial_no"]) + status, company = frappe.db.get_value("Asset", self.asset, ["status", "company"]) if self.purpose == 'Transfer' and status in ("Draft", "Scrapped", "Sold"): frappe.throw(_("{0} asset cannot be transferred").format(status)) if company != self.company: frappe.throw(_("Asset {0} does not belong to company {1}").format(self.asset, self.company)) - if serial_no and not self.serial_no: - self.serial_no = serial_no - if self.serial_no and len(get_serial_nos(self.serial_no)) != self.quantity: frappe.throw(_("Number of serial nos and quantity must be the same")) diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js index 4f0bd0da14..cdfbcaeb4a 100644 --- a/erpnext/stock/doctype/item/item.js +++ b/erpnext/stock/doctype/item/item.js @@ -216,25 +216,25 @@ var set_customer_group = function(frm, cdt, cdn) { $.extend(erpnext.item, { setup_queries: function(frm) { - frm.fields_dict['expense_account'].get_query = function(doc) { + frm.fields_dict["item_defaults"].grid.get_field("expense_account").get_query = function(doc) { return { query: "erpnext.controllers.queries.get_expense_account", } } - frm.fields_dict['income_account'].get_query = function(doc) { + frm.fields_dict["item_defaults"].grid.get_field("income_account").get_query = function(doc) { return { query: "erpnext.controllers.queries.get_income_account" } } - frm.fields_dict['buying_cost_center'].get_query = function(doc) { + frm.fields_dict["item_defaults"].grid.get_field("buying_cost_center").get_query = function(doc) { return { filters: { "is_group": 0 } } } - frm.fields_dict['selling_cost_center'].get_query = function(doc) { + frm.fields_dict["item_defaults"].grid.get_field("selling_cost_center").get_query = function(doc) { return { filters: { "is_group": 0 } } @@ -267,7 +267,7 @@ $.extend(erpnext.item, { return { query: "erpnext.controllers.queries.supplier_query" } } - frm.fields_dict['default_warehouse'].get_query = function(doc) { + frm.fields_dict["item_defaults"].grid.get_field("default_warehouse").get_query = function(doc) { return { filters: { "is_group": 0 } } diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json index 9b57edc311..c4a3fc1b4f 100644 --- a/erpnext/stock/doctype/item/item.json +++ b/erpnext/stock/doctype/item/item.json @@ -496,6 +496,38 @@ "translatable": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "depends_on": "is_fixed_asset", + "fieldname": "asset_naming_series", + "fieldtype": "Select", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Asset Naming Series", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, + "unique": 0 + }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -1152,7 +1184,7 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 1, - "collapsible_depends_on": "eval:doc.has_batch_no || doc.has_serial_no", + "collapsible_depends_on": "eval:doc.has_batch_no || doc.has_serial_no || doc.is_fixed_asset", "columns": 0, "depends_on": "is_stock_item", "fieldname": "serial_nos_and_batches", @@ -1382,7 +1414,7 @@ "collapsible": 0, "columns": 0, "default": "", - "depends_on": "eval:doc.is_stock_item", + "depends_on": "eval:doc.is_stock_item || doc.is_fixed_asset", "description": "", "fieldname": "has_serial_no", "fieldtype": "Check", @@ -1417,7 +1449,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "depends_on": "has_serial_no", + "depends_on": "eval:doc.is_stock_item || doc.is_fixed_asset", "description": "Example: ABCD.#####\nIf series is set and Serial No is not mentioned in transactions, then automatic serial number will be created based on this series. If you always want to explicitly mention Serial Nos for this item. leave this blank.", "fieldname": "serial_no_series", "fieldtype": "Data", @@ -3626,38 +3658,6 @@ "translatable": 0, "unique": 0 }, - { - "allow_bulk_edit": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "depends_on": "is_fixed_asset", - "fieldname": "asset_naming_series", - "fieldtype": "Select", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Asset Naming Series", - "length": 0, - "no_copy": 0, - "permlevel": 0, - "precision": "", - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, { "allow_bulk_edit": 0, "allow_on_submit": 0, @@ -3768,7 +3768,7 @@ "issingle": 0, "istable": 0, "max_attachments": 1, - "modified": "2018-05-16 06:35:12.204616", + "modified": "2018-05-16 16:35:09.518294", "modified_by": "Administrator", "module": "Stock", "name": "Item",