From 9b11d9b45db3820f73a71e82295a2520cf8c45c9 Mon Sep 17 00:00:00 2001 From: Javier Wong Date: Fri, 14 Apr 2017 18:24:04 +0800 Subject: [PATCH] [fix] Stock Entry - Change "Is Sample Item" to "Allow Zero Valuation Rate" --- .../purchase_invoice_item.json | 9 +++++---- .../sales_invoice_item/sales_invoice_item.json | 6 +++--- erpnext/controllers/stock_controller.py | 4 ++-- erpnext/patches.txt | 3 ++- ...is_sample_item_to_allow_zero_valuation_rate.py | 12 ++++++++++++ .../delivery_note_item/delivery_note_item.json | 6 +++--- .../purchase_receipt_item.json | 9 +++++---- .../stock_entry_detail/stock_entry_detail.json | 9 +++++---- erpnext/stock/stock_ledger.py | 15 ++++++++------- 9 files changed, 45 insertions(+), 28 deletions(-) create mode 100644 erpnext/patches/v8_0/rename_is_sample_item_to_allow_zero_valuation_rate.py diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json index 6102d3ea30..2a8d8559f5 100755 --- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json +++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.json @@ -1,5 +1,6 @@ { "allow_copy": 0, + "allow_guest_to_view": 0, "allow_import": 0, "allow_rename": 0, "autoname": "hash", @@ -1366,7 +1367,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "is_sample_item", + "fieldname": "allow_zero_valuation_rate", "fieldtype": "Check", "hidden": 0, "ignore_user_permissions": 0, @@ -1375,7 +1376,7 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Is Sample Item", + "label": "Allow Zero Valuation Rate", "length": 0, "no_copy": 1, "permlevel": 0, @@ -1869,17 +1870,17 @@ "unique": 0 } ], + "has_web_view": 0, "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": "2017-02-17 16:28:26.719053", + "modified": "2017-04-05 23:24:13.702820", "modified_by": "Administrator", "module": "Accounts", "name": "Purchase Invoice Item", diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json index 721785e82c..205b61e882 100644 --- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json +++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json @@ -1552,7 +1552,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "is_sample_item", + "fieldname": "allow_zero_valuation_rate", "fieldtype": "Check", "hidden": 0, "ignore_user_permissions": 0, @@ -1561,7 +1561,7 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Is Sample Item", + "label": "Allow Zero Valuation Rate", "length": 0, "no_copy": 1, "permlevel": 0, @@ -2094,7 +2094,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2017-03-30 16:26:36.507924", + "modified": "2017-04-05 23:28:13.520429", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice Item", diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index 9f0534529f..54c181ac1d 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -54,14 +54,14 @@ class StockController(AccountsController): self.check_expense_account(item_row) - # If item is not a sample item + # If the item does not have the allow zero valuation rate flag set # and ( valuation rate not mentioned in an incoming entry # or incoming entry not found while delivering the item), # try to pick valuation rate from previous sle or Item master and update in SLE # Otherwise, throw an exception if not sle.stock_value_difference and self.doctype != "Stock Reconciliation" \ - and not item_row.get("is_sample_item"): + and not item_row.get("allow_zero_valuation_rate"): sle = self.update_stock_ledger_entries(sle) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 3711bc82b2..27504c48a7 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -382,4 +382,5 @@ erpnext.patches.v7_2.make_all_assessment_group erpnext.patches.v8_0.manufacturer_childtable_migrate erpnext.patches.v8_0.repost_reserved_qty_for_multiple_sales_uom erpnext.patches.v8_0.addresses_linked_to_lead -execute:frappe.delete_doc('DocType', 'Purchase Common') \ No newline at end of file +execute:frappe.delete_doc('DocType', 'Purchase Common') +erpnext.patches.v8_0.rename_is_sample_item_to_allow_zero_valuation_rate \ No newline at end of file diff --git a/erpnext/patches/v8_0/rename_is_sample_item_to_allow_zero_valuation_rate.py b/erpnext/patches/v8_0/rename_is_sample_item_to_allow_zero_valuation_rate.py new file mode 100644 index 0000000000..744cfed998 --- /dev/null +++ b/erpnext/patches/v8_0/rename_is_sample_item_to_allow_zero_valuation_rate.py @@ -0,0 +1,12 @@ +from __future__ import unicode_literals +import frappe +from frappe.model.utils.rename_field import rename_field + +def execute(): + + doc_list = ["Purchase Invoice Item", "Stock Entry Detail", "Delivery Note Item", + "Purchase Receipt Item", "Sales Invoice Item"] + + for doctype in doc_list: + frappe.reload_doctype(doctype) + rename_field(doctype, "is_sample_item", "allow_zero_valuation_rate") \ No newline at end of file diff --git a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json index 2bae099aa1..2649c49c08 100644 --- a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json +++ b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.json @@ -1648,7 +1648,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "is_sample_item", + "fieldname": "allow_zero_valuation_rate", "fieldtype": "Check", "hidden": 0, "ignore_user_permissions": 0, @@ -1657,7 +1657,7 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Is Sample Item", + "label": "Allow Zero Valuation Rate", "length": 0, "no_copy": 1, "permlevel": 0, @@ -1894,7 +1894,7 @@ "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2017-03-30 19:34:42.305637", + "modified": "2017-04-05 23:26:03.390869", "modified_by": "Administrator", "module": "Stock", "name": "Delivery Note Item", 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 5159625700..91d1791cc7 100755 --- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json +++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json @@ -1,5 +1,6 @@ { "allow_copy": 0, + "allow_guest_to_view": 0, "allow_import": 0, "allow_rename": 0, "autoname": "hash", @@ -1633,7 +1634,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "is_sample_item", + "fieldname": "allow_zero_valuation_rate", "fieldtype": "Check", "hidden": 0, "ignore_user_permissions": 0, @@ -1642,7 +1643,7 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Is Sample Item", + "label": "Allow Zero Valuation Rate", "length": 0, "no_copy": 1, "permlevel": 0, @@ -1968,17 +1969,17 @@ "unique": 0 } ], + "has_web_view": 0, "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": "2017-02-20 13:31:59.778417", + "modified": "2017-04-05 23:27:10.785444", "modified_by": "Administrator", "module": "Stock", "name": "Purchase Receipt Item", diff --git a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json index 9b808f0435..6d99dc45c2 100644 --- a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json +++ b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json @@ -1,5 +1,6 @@ { "allow_copy": 0, + "allow_guest_to_view": 0, "allow_import": 0, "allow_rename": 0, "autoname": "hash", @@ -1043,7 +1044,7 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "is_sample_item", + "fieldname": "allow_zero_valuation_rate", "fieldtype": "Check", "hidden": 0, "ignore_user_permissions": 0, @@ -1052,7 +1053,7 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Is Sample Item", + "label": "Allow Zero Valuation Rate", "length": 0, "no_copy": 1, "permlevel": 0, @@ -1214,17 +1215,17 @@ "unique": 0 } ], + "has_web_view": 0, "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": "2017-02-20 13:31:25.233622", + "modified": "2017-04-05 23:25:26.885642", "modified_by": "Administrator", "module": "Stock", "name": "Stock Entry Detail", diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py index 82f9bf1f8b..d5f64b1298 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -259,10 +259,11 @@ class update_entries_after(object): if not self.valuation_rate and actual_qty > 0: self.valuation_rate = sle.incoming_rate - # Get valuation rate from previous SLE or Item master, if item is not a sample item + # Get valuation rate from previous SLE or Item master, if item does not have the + # allow zero valuration rate flag set if not self.valuation_rate and sle.voucher_detail_no: - is_sample_item = self.check_if_sample_item(sle.voucher_type, sle.voucher_detail_no) - if not is_sample_item: + allow_zero_valuation_rate = self.check_if_allow_zero_valuation_rate(sle.voucher_type, sle.voucher_detail_no) + if not allow_zero_valuation_rate: self.valuation_rate = get_valuation_rate(sle.item_code, sle.warehouse, sle.voucher_type, sle.voucher_no, self.allow_zero_rate, currency=erpnext.get_company_currency(sle.company)) @@ -290,8 +291,8 @@ class update_entries_after(object): while qty_to_pop: if not self.stock_queue: # Get valuation rate from last sle if exists or from valuation rate field in item master - is_sample_item = self.check_if_sample_item(sle.voucher_type, sle.voucher_detail_no) - if not is_sample_item: + allow_zero_valuation_rate = self.check_if_allow_zero_valuation_rate(sle.voucher_type, sle.voucher_detail_no) + if not allow_zero_valuation_rate: _rate = get_valuation_rate(sle.item_code, sle.warehouse, sle.voucher_type, sle.voucher_no, self.allow_zero_rate, currency=erpnext.get_company_currency(sle.company)) @@ -344,9 +345,9 @@ class update_entries_after(object): if not self.stock_queue: self.stock_queue.append([0, sle.incoming_rate or sle.outgoing_rate or self.valuation_rate]) - def check_if_sample_item(self, voucher_type, voucher_detail_no): + def check_if_allow_zero_valuation_rate(self, voucher_type, voucher_detail_no): ref_item_dt = voucher_type + (" Detail" if voucher_type == "Stock Entry" else " Item") - return frappe.db.get_value(ref_item_dt, voucher_detail_no, "is_sample_item") + return frappe.db.get_value(ref_item_dt, voucher_detail_no, "allow_zero_valuation_rate") def get_sle_before_datetime(self): """get previous stock ledger entry before current time-bucket"""