Fetch Fixed Asset property from item in Sales / Purchase Invoice

This commit is contained in:
Nabin Hait 2016-07-05 15:37:09 +05:30
parent cea353a638
commit e417000bbb
6 changed files with 64 additions and 58 deletions

View File

@ -119,6 +119,8 @@ def scrap_asset(asset_name):
frappe.db.set_value("Asset", asset_name, "disposal_date", today())
frappe.db.set_value("Asset", asset_name, "journal_entry_for_scrap", je.name)
asset.set_status("Scrapped")
frappe.msgprint(_("Asset scrapped via Journal Entry {0}").format(je.name))
@frappe.whitelist()
def restore_asset(asset_name):

View File

@ -165,7 +165,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
var row = locals[cdt][cdn];
if(row.asset) {
frappe.call({
method: erpnext.accounts.doctype.purchase_invoice.purchase_invoice.get_fixed_asset_account,
method: "erpnext.accounts.doctype.purchase_invoice.purchase_invoice.get_fixed_asset_account",
args: {
"asset": row.asset,
"account": row.expense_account

View File

@ -181,15 +181,16 @@ class PurchaseInvoice(BuyingController):
# expense account is always "Stock Received But Not Billed" for a stock item
# except epening entry, drop-ship entry and fixed asset items
if auto_accounting_for_stock and item.item_code in stock_items and self.is_opening == 'No' \
and (not item.po_detail or not item.is_fixed_asset
or not frappe.db.get_value("Purchase Order Item", item.po_detail, "delivered_by_supplier")):
if auto_accounting_for_stock and item.item_code in stock_items \
and self.is_opening == 'No' and not item.is_fixed_asset \
and (not item.po_detail or
not frappe.db.get_value("Purchase Order Item", item.po_detail, "delivered_by_supplier")):
if self.update_stock:
item.expense_account = warehouse_account[item.warehouse]["name"]
else:
item.expense_account = stock_not_billed_account
elif not item.expense_account:
throw(_("Expense account is mandatory for item {0}").format(item.item_code or item.item_name))

View File

@ -3,6 +3,7 @@
"allow_import": 0,
"allow_rename": 0,
"autoname": "hash",
"beta": 0,
"creation": "2013-05-22 12:43:10",
"custom": 0,
"docstatus": 0,
@ -1016,31 +1017,6 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "is_fixed_asset",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Is Fixed Asset",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
@ -1357,6 +1333,31 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "is_fixed_asset",
"fieldtype": "Check",
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Is Fixed Asset",
"length": 0,
"no_copy": 1,
"permlevel": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
@ -1566,13 +1567,14 @@
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 1,
"image_view": 0,
"in_create": 0,
"in_dialog": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2016-04-18 08:08:53.056819",
"modified": "2016-07-05 13:29:00.829144",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice Item",

View File

@ -975,31 +975,6 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "is_fixed_asset",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Is Fixed Asset",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
@ -1574,6 +1549,31 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "is_fixed_asset",
"fieldtype": "Check",
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Is Fixed Asset",
"length": 0,
"no_copy": 1,
"permlevel": 0,
"precision": "",
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
@ -1659,7 +1659,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2016-06-24 16:01:59.719026",
"modified": "2016-07-05 13:28:51.981000",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice Item",

View File

@ -173,7 +173,8 @@ def get_basic_details(args, item):
"net_amount": 0.0,
"discount_percentage": 0.0,
"supplier": item.default_supplier,
"delivered_by_supplier": item.delivered_by_supplier
"delivered_by_supplier": item.delivered_by_supplier,
"is_fixed_asset": item.is_fixed_asset
})
# if default specified in item is for another company, fetch from company