diff --git a/erpnext/accounts/doctype/account/account.json b/erpnext/accounts/doctype/account/account.json index 668164ca64..de28a59f8c 100644 --- a/erpnext/accounts/doctype/account/account.json +++ b/erpnext/accounts/doctype/account/account.json @@ -412,7 +412,7 @@ "no_copy": 0, "oldfieldname": "account_type", "oldfieldtype": "Select", - "options": "\nAccumulated Depreciation\nBank\nCash\nChargeable\nCost of Goods Sold\nDepreciation\nEquity\nExpense Account\nExpenses Included In Valuation\nFixed Asset\nIncome Account\nPayable\nReceivable\nRound Off\nStock\nStock Adjustment\nStock Received But Not Billed\nTax\nTemporary", + "options": "\nAccumulated Depreciation\nAsset Received But Not Billed\nBank\nCash\nChargeable\nCapital Work in Progress\nCost of Goods Sold\nDepreciation\nEquity\nExpense Account\nExpenses Included In Asset Valuation\nExpenses Included In Valuation\nFixed Asset\nIncome Account\nPayable\nReceivable\nRound Off\nStock\nStock Adjustment\nStock Received But Not Billed\nTax\nTemporary", "permlevel": 0, "print_hide": 0, "print_hide_if_no_value": 0, @@ -625,7 +625,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-05-02 11:00:34.108490", + "modified": "2018-05-07 15:37:25.962506", "modified_by": "Administrator", "module": "Accounts", "name": "Account", diff --git a/erpnext/assets/doctype/asset/asset.json b/erpnext/assets/doctype/asset/asset.json index 63b9167cc6..536b4dc522 100644 --- a/erpnext/assets/doctype/asset/asset.json +++ b/erpnext/assets/doctype/asset/asset.json @@ -3,7 +3,7 @@ "allow_guest_to_view": 0, "allow_import": 1, "allow_rename": 1, - "autoname": "field:asset_name", + "autoname": "naming_series:", "beta": 0, "creation": "2016-03-01 17:01:27.920130", "custom": 0, @@ -12,6 +12,39 @@ "document_type": "Document", "editable_grid": 0, "fields": [ + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "default": "AST", + "fieldname": "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": "Naming Series", + "length": 0, + "no_copy": 0, + "options": "AST\nAT", + "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, @@ -1354,7 +1387,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-04-19 20:03:13.669957", + "modified": "2018-05-07 15:25:06.456992", "modified_by": "Administrator", "module": "Assets", "name": "Asset", diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py index a9cc924b8f..adcc986f66 100644 --- a/erpnext/assets/doctype/asset/asset.py +++ b/erpnext/assets/doctype/asset/asset.py @@ -10,7 +10,6 @@ from frappe.model.document import Document from erpnext.accounts.doctype.purchase_invoice.purchase_invoice import get_fixed_asset_account from erpnext.assets.doctype.asset.depreciation \ import get_disposal_account_and_cost_center, get_depreciation_accounts -from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos class Asset(Document): def validate(self): @@ -34,9 +33,6 @@ class Asset(Document): self.delete_depreciation_entries() self.set_status() - def on_update(self): - self.update_serial_nos() - def validate_item(self): item = frappe.db.get_value("Item", self.item_code, ["is_fixed_asset", "is_stock_item", "disabled"], as_dict=1) @@ -258,12 +254,6 @@ class Asset(Document): status = "Cancelled" return status - def update_serial_nos(self): - if self.serial_no: - serial_nos = get_serial_nos(self.serial_no) - frappe.db.sql(""" update `tabSerial No` set asset = '%s' where - name in(%s)"""%(self.name, ','.join(['%s'] * len(serial_nos))), tuple(serial_nos)) - def update_stock_movement(self): asset_movement = frappe.db.get_value('Asset Movement', {'asset': self.name, 'reference_name': self.purchase_receipt, 'docstatus': 0}, 'name') @@ -282,6 +272,10 @@ def update_maintenance_status(): if frappe.db.exists('Asset Repair', {'asset_name': asset.name, 'repair_status': 'Pending'}): asset.set_status('Out of Order') +def get_asset_naming_series(): + meta = frappe.get_meta('Asset') + return meta.get_field("naming_series").options + @frappe.whitelist() def make_purchase_invoice(asset, item_code, gross_purchase_amount, company, posting_date): pi = frappe.new_doc("Purchase Invoice") diff --git a/erpnext/assets/doctype/location/__init__.py b/erpnext/assets/doctype/location/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/assets/doctype/location/location.js b/erpnext/assets/doctype/location/location.js new file mode 100644 index 0000000000..c3783dfae7 --- /dev/null +++ b/erpnext/assets/doctype/location/location.js @@ -0,0 +1,8 @@ +// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Location', { + refresh: function(frm) { + + } +}); diff --git a/erpnext/assets/doctype/location/location.json b/erpnext/assets/doctype/location/location.json new file mode 100644 index 0000000000..13ef66224d --- /dev/null +++ b/erpnext/assets/doctype/location/location.json @@ -0,0 +1,213 @@ +{ + "allow_copy": 0, + "allow_guest_to_view": 0, + "allow_import": 0, + "allow_rename": 0, + "autoname": "field:location_name", + "beta": 0, + "creation": "2018-05-07 12:49:22.595974", + "custom": 0, + "docstatus": 0, + "doctype": "DocType", + "document_type": "", + "editable_grid": 1, + "engine": "InnoDB", + "fields": [ + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "location_name", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "Location Name", + "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": 1, + "search_index": 0, + "set_only_once": 0, + "translatable": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "is_group", + "fieldtype": "Check", + "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": "Is Group", + "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, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "parent_location", + "fieldtype": "Link", + "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": "Parent Location", + "length": 0, + "no_copy": 0, + "options": "Location", + "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": 1, + "set_only_once": 0, + "translatable": 0, + "unique": 0 + } + ], + "has_web_view": 0, + "hide_heading": 0, + "hide_toolbar": 0, + "idx": 0, + "image_view": 0, + "in_create": 0, + "is_submittable": 0, + "issingle": 0, + "istable": 0, + "max_attachments": 0, + "modified": "2018-05-07 12:54:49.527782", + "modified_by": "Administrator", + "module": "Assets", + "name": "Location", + "name_case": "", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "if_owner": 0, + "import": 0, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "set_user_permissions": 0, + "share": 1, + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "if_owner": 0, + "import": 0, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Stock User", + "set_user_permissions": 0, + "share": 1, + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "if_owner": 0, + "import": 0, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Accounts User", + "set_user_permissions": 0, + "share": 1, + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "if_owner": 0, + "import": 0, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Stock Manager", + "set_user_permissions": 0, + "share": 1, + "submit": 0, + "write": 1 + } + ], + "quick_entry": 1, + "read_only": 0, + "read_only_onload": 0, + "show_name_in_global_search": 0, + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1, + "track_seen": 0 +} \ No newline at end of file diff --git a/erpnext/assets/doctype/location/location.py b/erpnext/assets/doctype/location/location.py new file mode 100644 index 0000000000..2483ca1b9d --- /dev/null +++ b/erpnext/assets/doctype/location/location.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe +from frappe.model.document import Document + +class Location(Document): + pass diff --git a/erpnext/assets/doctype/location/test_location.js b/erpnext/assets/doctype/location/test_location.js new file mode 100644 index 0000000000..236b5c65b0 --- /dev/null +++ b/erpnext/assets/doctype/location/test_location.js @@ -0,0 +1,23 @@ +/* eslint-disable */ +// rename this file from _test_[name] to test_[name] to activate +// and remove above this line + +QUnit.test("test: Location", function (assert) { + let done = assert.async(); + + // number of asserts + assert.expect(1); + + frappe.run_serially([ + // insert a new Location + () => frappe.tests.make('Location', [ + // values to be set + {key: 'value'} + ]), + () => { + assert.equal(cur_frm.doc.key, 'value'); + }, + () => done() + ]); + +}); diff --git a/erpnext/assets/doctype/location/test_location.py b/erpnext/assets/doctype/location/test_location.py new file mode 100644 index 0000000000..9a46fd93ef --- /dev/null +++ b/erpnext/assets/doctype/location/test_location.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt +from __future__ import unicode_literals + +import frappe +import unittest + +class TestLocation(unittest.TestCase): + pass diff --git a/erpnext/config/assets.py b/erpnext/config/assets.py index 73c1aee87a..be522469e6 100644 --- a/erpnext/config/assets.py +++ b/erpnext/config/assets.py @@ -14,6 +14,11 @@ def get_data(): "type": "doctype", "name": "Asset Category", }, + { + "type": "doctype", + "label": _("Asset Location"), + "name": "Location", + }, { "type": "doctype", "name": "Asset Settings", diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index c340901e3b..798eee2b9d 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -441,9 +441,10 @@ class BuyingController(StockController): return if self.doctype in ['Purchase Receipt', 'Purchase Invoice']: - if self.doctype == 'Purchase Receipt': - self.process_fixed_asset() - self.update_fixed_asset() + field = 'purchase_invoice' if self.doctype == 'Purchase Invoice' else 'purchase_receipt' + + self.process_fixed_asset() + self.update_fixed_asset(field) update_last_purchase_rate(self, is_submit = 1) @@ -453,12 +454,13 @@ class BuyingController(StockController): update_last_purchase_rate(self, is_submit = 0) if self.doctype in ['Purchase Receipt', 'Purchase Invoice']: - if self.doctype == 'Purchase Receipt': - self.delete_linked_asset() - self.update_fixed_asset() + field = 'purchase_invoice' if self.doctype == 'Purchase Invoice' else 'purchase_receipt' + + self.delete_linked_asset(field) + self.update_fixed_asset(field) def process_fixed_asset(self): - if not self.doctype in ['Purchase Receipt', 'Purchase Invoice']: + if self.doctype == 'Purchase Invoice' and not self.update_stock: return asset_items = [d.item_code for d in self.items if d.is_fixed_asset] @@ -471,6 +473,9 @@ class BuyingController(StockController): for d in self.items: if d.is_fixed_asset: item_data = items_data.get(d.item_code) + if not d.asset: + asset = self.make_asset(d) + d.db_set('asset', asset) if item_data.get('has_serial_no'): # If item has serial no @@ -488,14 +493,11 @@ class BuyingController(StockController): 'company': self.company, 'actual_qty': d.qty, 'purchase_document_type': self.doctype, - 'purchase_document_no': self.name + 'purchase_document_no': self.name, + 'asset': d.asset }) d.db_set('serial_no', serial_nos) - if not d.asset: - asset = self.make_asset(d) - d.db_set('asset', asset) - if d.asset: self.make_asset_movement(d) @@ -503,9 +505,9 @@ class BuyingController(StockController): asset = frappe.get_doc({ 'doctype': 'Asset', 'item_code': row.item_code, - 'asset_name': '{0} - {1}'.format(self.name, row.item_code), + 'asset_name': row.item_name, + 'naming_series': frappe.db.get_value('Item', row.item_code, 'asset_naming_series') or 'AST', 'warehouse': row.warehouse, - 'serial_no': row.serial_no, 'company': self.company, 'purchase_date': self.posting_date, 'purchase_receipt': self.name if self.doctype == 'Purchase Receipt' else None, @@ -535,9 +537,7 @@ class BuyingController(StockController): return asset_movement.name - def update_fixed_asset(self): - field = 'purchase_invoice' if self.doctype == 'Purchase Invoice' else 'purchase_receipt' - + def update_fixed_asset(self, field): for d in self.get("items"): if d.is_fixed_asset and d.asset: asset = frappe.get_doc("Asset", d.asset) @@ -555,13 +555,11 @@ class BuyingController(StockController): asset.save() - def delete_linked_asset(self): - if not self.doctype in ['Purchase Receipt', 'Purchase Invoice']: - return - - if self.doctype == 'Purchase Invoice' and self.get('update_stock'): + def delete_linked_asset(self, field): + if self.doctype == 'Purchase Invoice' and not self.get('update_stock'): return + frappe.db.sql("delete from `tabAsset` where {0} = %s and docstatus = 0".format(field), self.name) frappe.db.sql("delete from `tabAsset Movement` where reference_name=%s and docstatus = 0", self.name) frappe.db.sql("delete from `tabSerial No` where purchase_document_no=%s", self.name) diff --git a/erpnext/setup/doctype/company/company.js b/erpnext/setup/doctype/company/company.js index d4095772cd..5ca2885547 100644 --- a/erpnext/setup/doctype/company/company.js +++ b/erpnext/setup/doctype/company/company.js @@ -5,14 +5,6 @@ frappe.provide("erpnext.company"); frappe.ui.form.on("Company", { setup: function(frm) { - frm.fields_dict.fixed_asset_account.get_query = function() { - return { - filters: { - account_type: "Fixed Asset", - company: frm.doc.name - } - } - } erpnext.company.setup_queries(frm); }, @@ -215,6 +207,9 @@ erpnext.company.setup_queries = function(frm) { ["round_off_cost_center", {}], ["depreciation_cost_center", {}], ["default_employee_advance_account", {"root_type": "Asset"}], + ["expenses_included_in_asset_valuation", {"account_type": "Expenses Included In Asset Valuation"}], + ["capital_work_in_progress_account", {"account_type": "Capital Work in Progress"}], + ["asset_received_but_not_billed", {"account_type": "Asset Received But Not Billed"}] ], function(i, v) { erpnext.company.set_custom_query(frm, v); }); diff --git a/erpnext/setup/doctype/company/company.json b/erpnext/setup/doctype/company/company.json index d236dda873..07051eeba8 100644 --- a/erpnext/setup/doctype/company/company.json +++ b/erpnext/setup/doctype/company/company.json @@ -1785,6 +1785,38 @@ "translatable": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "expenses_included_in_asset_valuation", + "fieldtype": "Link", + "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": "Expenses Included In Asset Valuation", + "length": 0, + "no_copy": 0, + "options": "Account", + "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, @@ -1879,6 +1911,70 @@ "translatable": 0, "unique": 0 }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "capital_work_in_progress_account", + "fieldtype": "Link", + "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": "Capital Work In Progress Account", + "length": 0, + "no_copy": 0, + "options": "Account", + "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, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "asset_received_but_not_billed", + "fieldtype": "Link", + "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 Received But Not Billed", + "length": 0, + "no_copy": 0, + "options": "Account", + "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, @@ -2400,7 +2496,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2018-05-05 13:08:07.351655", + "modified": "2018-05-07 15:35:06.736602", "modified_by": "Administrator", "module": "Setup", "name": "Company", diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js index f98cbb6268..fbf0deddc7 100644 --- a/erpnext/stock/doctype/item/item.js +++ b/erpnext/stock/doctype/item/item.js @@ -19,7 +19,9 @@ frappe.ui.form.on("Item", { // should never check Private frm.fields_dict["website_image"].df.is_private = 0; - + if (frm.doc.is_fixed_asset) { + frm.trigger("set_asset_naming_series"); + } }, refresh: function(frm) { @@ -124,7 +126,20 @@ frappe.ui.form.on("Item", { }, is_fixed_asset: function(frm) { - frm.set_value("is_stock_item", frm.doc.is_fixed_asset ? 0 : 1); + frm.call({ + method: "set_asset_naming_series", + doc: frm.doc, + callback: function() { + frm.set_value("is_stock_item", frm.doc.is_fixed_asset ? 0 : 1); + frm.trigger("set_asset_naming_series"); + } + }) + }, + + set_asset_naming_series: function(frm) { + if (frm.doc.__onload && frm.doc.__onload.asset_naming_series) { + frm.set_df_property("asset_naming_series", "options", frm.doc.__onload.asset_naming_series); + } }, page_name: frappe.utils.warn_page_name_change, diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json index 251717e127..b8621719c4 100644 --- a/erpnext/stock/doctype/item/item.json +++ b/erpnext/stock/doctype/item/item.json @@ -395,7 +395,7 @@ "search_index": 0, "set_only_once": 0, "translatable": 0, - "unique": 0 + "unique": 0 }, { "allow_bulk_edit": 0, @@ -559,6 +559,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, @@ -3717,7 +3749,7 @@ "issingle": 0, "istable": 0, "max_attachments": 1, - "modified": "2018-04-30 12:21:48.715529", + "modified": "2018-05-07 14:54:24.479267", "modified_by": "Administrator", "module": "Stock", "name": "Item", diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py index fafdaab51f..94b907b914 100644 --- a/erpnext/stock/doctype/item/item.py +++ b/erpnext/stock/doctype/item/item.py @@ -16,6 +16,7 @@ from frappe.utils import (cint, cstr, flt, formatdate, get_timestamp, getdate, from frappe.utils.html_utils import clean_html from frappe.website.doctype.website_slideshow.website_slideshow import \ get_slideshow + from frappe.website.render import clear_cache from frappe.website.website_generator import WebsiteGenerator @@ -42,10 +43,18 @@ class Item(WebsiteGenerator): super(Item, self).onload() self.set_onload('stock_exists', self.stock_ledger_created()) + self.set_asset_naming_series() if self.is_fixed_asset: asset = frappe.db.get_all("Asset", filters={"item_code": self.name, "docstatus": 1}, limit=1) self.set_onload("asset_exists", True if asset else False) + def set_asset_naming_series(self): + if not hasattr(self, '_asset_naming_series'): + from erpnext.assets.doctype.asset.asset import get_asset_naming_series + self._asset_naming_series = get_asset_naming_series() + + self.set_onload('asset_naming_series', self._asset_naming_series) + def autoname(self): if frappe.db.get_default("item_naming_by") == "Naming Series": if self.variant_of: diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json index a7b0a03c0a..87c9a757bf 100755 --- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json +++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json @@ -1641,6 +1641,39 @@ "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_location", + "fieldtype": "Link", + "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 Location", + "length": 0, + "no_copy": 0, + "options": "Location", + "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, @@ -2459,7 +2492,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2018-04-23 14:07:48.438379", + "modified": "2018-05-07 13:42:05.061386", "modified_by": "Administrator", "module": "Stock", "name": "Purchase Receipt Item", diff --git a/erpnext/stock/doctype/serial_no/serial_no.py b/erpnext/stock/doctype/serial_no/serial_no.py index 17bf1bb1c3..6ee679ab82 100644 --- a/erpnext/stock/doctype/serial_no/serial_no.py +++ b/erpnext/stock/doctype/serial_no/serial_no.py @@ -322,6 +322,7 @@ def make_serial_no(serial_no, args): sr.item_code = args.get('item_code') sr.company = args.get('company') sr.via_stock_ledger = args.get('via_stock_ledger') or True + sr.asset = args.get('asset') sr.insert() if args.get('purchase_document_type'): diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 0d03b4d2ec..7e456dd3d3 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -287,10 +287,6 @@ def get_default_income_account(args, item): or frappe.db.get_value("Item Group", item.item_group, "default_income_account")) def get_default_expense_account(args, item): - if item and item.is_fixed_asset: - return frappe.db.get_value("Company", args.company, "fixed_asset_account") - if account: return account - return (item.expense_account or args.expense_account or frappe.db.get_value("Item Group", item.item_group, "default_expense_account"))