Merge pull request #4312 from nabinhait/delete_uom_replace_utility
Deleted Stock UOM Replace Utility
diff --git a/erpnext/docs/current/models/stock/stock_uom_replace_utility.html b/erpnext/docs/current/models/stock/stock_uom_replace_utility.html
deleted file mode 100644
index 5d3b9fa..0000000
--- a/erpnext/docs/current/models/stock/stock_uom_replace_utility.html
+++ /dev/null
@@ -1,284 +0,0 @@
-<!-- title: Stock UOM Replace Utility -->
-
-
-
-
-
-<div class="dev-header">
-
-<a class="btn btn-default btn-sm" disabled style="margin-bottom: 10px;">
- Version 6.7.7</a>
-
-
- <a class="btn btn-default btn-sm" href="https://github.com/frappe/erpnext/tree/develop/erpnext/stock/doctype/stock_uom_replace_utility"
- target="_blank" style="margin-left: 10px; margin-bottom: 10px;"><i class="octicon octicon-mark-github"></i> Source</a>
-
-</div>
-
-<span class="label label-info">Single</span>
-
-
-
-
-
-
-<h3>Fields</h3>
-
-<table class="table table-bordered" style="table-layout: fixed;">
- <thead>
- <tr>
- <th style="width: 5%">Sr</th>
- <th style="width: 25%">Fieldname</th>
- <th style="width: 20%">Type</th>
- <th style="width: 25%">Label</th>
- <th style="width: 25%">Options</th>
- </tr>
- </thead>
- <tbody>
-
- <tr >
- <td>1</td>
- <td ><code>item_code</code></td>
- <td >
- Link</td>
- <td >
- Item
-
- </td>
- <td>
-
-
-
-
-<a href="https://frappe.github.io/erpnext/current/models/stock/item">Item</a>
-
-
-
- </td>
- </tr>
-
- <tr >
- <td>2</td>
- <td ><code>current_stock_uom</code></td>
- <td >
- Link</td>
- <td >
- Current Stock UOM
-
- </td>
- <td>
-
-
-
-
-<a href="https://frappe.github.io/erpnext/current/models/setup/uom">UOM</a>
-
-
-
- </td>
- </tr>
-
- <tr >
- <td>3</td>
- <td ><code>new_stock_uom</code></td>
- <td >
- Link</td>
- <td >
- New Stock UOM
-
- </td>
- <td>
-
-
-
-
-<a href="https://frappe.github.io/erpnext/current/models/setup/uom">UOM</a>
-
-
-
- </td>
- </tr>
-
- <tr >
- <td>4</td>
- <td ><code>conversion_factor</code></td>
- <td >
- Float</td>
- <td >
- Conversion Factor
-
- </td>
- <td></td>
- </tr>
-
- <tr >
- <td>5</td>
- <td ><code>update</code></td>
- <td >
- Button</td>
- <td >
- Update
-
- </td>
- <td>
- <pre>update_stock_uom</pre>
- </td>
- </tr>
-
- </tbody>
-</table>
-
-
- <hr>
- <h3>Controller</h3>
- <h4>erpnext.stock.doctype.stock_uom_replace_utility.stock_uom_replace_utility</h4>
-
-
-
-
-
-
-
- <h3 style="font-weight: normal;">Class <b>StockUOMReplaceUtility</b></h3>
-
- <p style="padding-left: 30px;"><i>Inherits from frappe.model.document.Document</i></h4>
-
- <div class="docs-attr-desc"><p></p>
-</div>
- <div style="padding-left: 30px;">
-
-
-
-
- <p class="docs-attr-name">
- <a name="update_stock_uom" href="#update_stock_uom" class="text-muted small">
- <i class="icon-link small" style="color: #ccc;"></i></a>
- <b>update_stock_uom</b>
- <i class="text-muted">(self)</i>
- </p>
- <div class="docs-attr-desc"><p><span class="text-muted">No docs</span></p>
-</div>
- <br>
-
-
-
-
-
- <p class="docs-attr-name">
- <a name="validate_item" href="#validate_item" class="text-muted small">
- <i class="icon-link small" style="color: #ccc;"></i></a>
- <b>validate_item</b>
- <i class="text-muted">(self)</i>
- </p>
- <div class="docs-attr-desc"><p><span class="text-muted">No docs</span></p>
-</div>
- <br>
-
-
-
-
-
- <p class="docs-attr-name">
- <a name="validate_mandatory" href="#validate_mandatory" class="text-muted small">
- <i class="icon-link small" style="color: #ccc;"></i></a>
- <b>validate_mandatory</b>
- <i class="text-muted">(self)</i>
- </p>
- <div class="docs-attr-desc"><p><span class="text-muted">No docs</span></p>
-</div>
- <br>
-
-
-
-
-
- <p class="docs-attr-name">
- <a name="validate_uom_integer_type" href="#validate_uom_integer_type" class="text-muted small">
- <i class="icon-link small" style="color: #ccc;"></i></a>
- <b>validate_uom_integer_type</b>
- <i class="text-muted">(self)</i>
- </p>
- <div class="docs-attr-desc"><p><span class="text-muted">No docs</span></p>
-</div>
- <br>
-
-
- </div>
- <hr>
-
-
-
-
-
-
- <p><span class="label label-info">Public API</span>
- <br><code>/api/method/erpnext.stock.doctype.stock_uom_replace_utility.stock_uom_replace_utility.get_stock_uom</code>
- </p>
- <p class="docs-attr-name">
- <a name="erpnext.stock.doctype.stock_uom_replace_utility.stock_uom_replace_utility.get_stock_uom" href="#erpnext.stock.doctype.stock_uom_replace_utility.stock_uom_replace_utility.get_stock_uom" class="text-muted small">
- <i class="icon-link small" style="color: #ccc;"></i></a>
- erpnext.stock.doctype.stock_uom_replace_utility.stock_uom_replace_utility.<b>get_stock_uom</b>
- <i class="text-muted">(item_code)</i>
- </p>
- <div class="docs-attr-desc"><p><span class="text-muted">No docs</span></p>
-</div>
- <br>
-
-
-
-
-
-
-
- <p class="docs-attr-name">
- <a name="erpnext.stock.doctype.stock_uom_replace_utility.stock_uom_replace_utility.update_bin" href="#erpnext.stock.doctype.stock_uom_replace_utility.stock_uom_replace_utility.update_bin" class="text-muted small">
- <i class="icon-link small" style="color: #ccc;"></i></a>
- erpnext.stock.doctype.stock_uom_replace_utility.stock_uom_replace_utility.<b>update_bin</b>
- <i class="text-muted">(item_code, new_stock_uom, conversion_factor)</i>
- </p>
- <div class="docs-attr-desc"><p><span class="text-muted">No docs</span></p>
-</div>
- <br>
-
-
-
-
-
-
-
- <p class="docs-attr-name">
- <a name="erpnext.stock.doctype.stock_uom_replace_utility.stock_uom_replace_utility.update_item_master" href="#erpnext.stock.doctype.stock_uom_replace_utility.stock_uom_replace_utility.update_item_master" class="text-muted small">
- <i class="icon-link small" style="color: #ccc;"></i></a>
- erpnext.stock.doctype.stock_uom_replace_utility.stock_uom_replace_utility.<b>update_item_master</b>
- <i class="text-muted">(item_code, new_stock_uom, conversion_factor)</i>
- </p>
- <div class="docs-attr-desc"><p><span class="text-muted">No docs</span></p>
-</div>
- <br>
-
-
-
-
-
-
-
- <p class="docs-attr-name">
- <a name="erpnext.stock.doctype.stock_uom_replace_utility.stock_uom_replace_utility.update_stock_ledger_entry" href="#erpnext.stock.doctype.stock_uom_replace_utility.stock_uom_replace_utility.update_stock_ledger_entry" class="text-muted small">
- <i class="icon-link small" style="color: #ccc;"></i></a>
- erpnext.stock.doctype.stock_uom_replace_utility.stock_uom_replace_utility.<b>update_stock_ledger_entry</b>
- <i class="text-muted">(item_code, new_stock_uom, conversion_factor)</i>
- </p>
- <div class="docs-attr-desc"><p><span class="text-muted">No docs</span></p>
-</div>
- <br>
-
-
-
-
-
-
-
-
-<!-- autodoc -->
-<!-- jinja -->
-<!-- static -->
\ No newline at end of file
diff --git a/erpnext/docs/user/guides/stock/tools/index.txt b/erpnext/docs/user/guides/stock/tools/index.txt
index d6a5816..3aca9b7 100644
--- a/erpnext/docs/user/guides/stock/tools/index.txt
+++ b/erpnext/docs/user/guides/stock/tools/index.txt
@@ -1,4 +1,3 @@
packing-slip
quality-inspection
landed-cost-voucher
-stock-uom-replace-utility
\ No newline at end of file
diff --git a/erpnext/docs/user/guides/stock/tools/stock-uom-replace-utility.md b/erpnext/docs/user/guides/stock/tools/stock-uom-replace-utility.md
deleted file mode 100644
index 3c5428a..0000000
--- a/erpnext/docs/user/guides/stock/tools/stock-uom-replace-utility.md
+++ /dev/null
@@ -1,10 +0,0 @@
-#Stock UOM Replace Utility
-
-This tool will help you to change the UOM (Unit of measurement) of an existing Item.
-
-You need to select an Item, system fetches the Existing UOM of that item. You can then select the new UOM for that item
-and specify the conversion factor.
-
-<img class="screenshot" alt="Stock Uom Replace" src="{{url_prefix}}/assets/img/stock/uom-replace.png">
-
-{next}
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 3ad735a..37a6b27 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -231,3 +231,4 @@
execute:frappe.delete_doc_if_exists("Report", "Item-wise Last Purchase Rate")
erpnext.patches.v6_6.fix_website_image
erpnext.patches.v6_6.remove_fiscal_year_from_leave_allocation
+execute:frappe.delete_doc_if_exists("DocType", "Stock UOM Replace Utility")
\ No newline at end of file
diff --git a/erpnext/stock/doctype/stock_uom_replace_utility/README.md b/erpnext/stock/doctype/stock_uom_replace_utility/README.md
deleted file mode 100644
index 6db95a6..0000000
--- a/erpnext/stock/doctype/stock_uom_replace_utility/README.md
+++ /dev/null
@@ -1 +0,0 @@
-Tool to replace unit of measure (UoM) of an Item.
\ No newline at end of file
diff --git a/erpnext/stock/doctype/stock_uom_replace_utility/__init__.py b/erpnext/stock/doctype/stock_uom_replace_utility/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/erpnext/stock/doctype/stock_uom_replace_utility/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.js b/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.js
deleted file mode 100644
index eb45ade..0000000
--- a/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.js
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-// License: GNU General Public License v3. See license.txt
-
-$.extend(cur_frm.cscript, {
- onload: function() {
- cur_frm.set_query("item_code", function() {
- return erpnext.queries.item({"is_stock_item": 1});
- });
- },
-
- item_code: function() {
- if(cur_frm.doc.item_code) {
- return cur_frm.call({
- method: "get_stock_uom",
- args: { item_code: cur_frm.doc.item_code }
- });
- }
- }
-});
diff --git a/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.json b/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.json
deleted file mode 100644
index 6cadd6a..0000000
--- a/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.json
+++ /dev/null
@@ -1,178 +0,0 @@
-{
- "allow_copy": 0,
- "allow_import": 0,
- "allow_rename": 0,
- "creation": "2013-01-10 16:34:30",
- "custom": 0,
- "docstatus": 0,
- "doctype": "DocType",
- "fields": [
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "item_code",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Item",
- "no_copy": 0,
- "options": "Item",
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "current_stock_uom",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Current Stock UOM",
- "no_copy": 0,
- "options": "UOM",
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 1,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "new_stock_uom",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "New Stock UOM",
- "no_copy": 0,
- "options": "UOM",
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "conversion_factor",
- "fieldtype": "Float",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Conversion Factor",
- "no_copy": 0,
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "fieldname": "update",
- "fieldtype": "Button",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 0,
- "in_list_view": 0,
- "label": "Update",
- "no_copy": 0,
- "options": "update_stock_uom",
- "permlevel": 0,
- "print_hide": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 0,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- }
- ],
- "hide_heading": 0,
- "hide_toolbar": 0,
- "icon": "icon-magic",
- "idx": 1,
- "in_create": 0,
- "in_dialog": 0,
- "is_submittable": 0,
- "issingle": 1,
- "istable": 0,
- "modified": "2015-08-12 08:52:09.322664",
- "modified_by": "Administrator",
- "module": "Stock",
- "name": "Stock UOM Replace Utility",
- "owner": "Administrator",
- "permissions": [
- {
- "amend": 0,
- "apply_user_permissions": 0,
- "cancel": 0,
- "create": 1,
- "delete": 0,
- "email": 1,
- "export": 0,
- "if_owner": 0,
- "import": 0,
- "permlevel": 0,
- "print": 1,
- "read": 1,
- "report": 0,
- "role": "Item Manager",
- "set_user_permissions": 0,
- "share": 1,
- "submit": 0,
- "write": 1
- },
- {
- "amend": 0,
- "apply_user_permissions": 0,
- "cancel": 0,
- "create": 1,
- "delete": 0,
- "email": 1,
- "export": 0,
- "if_owner": 0,
- "import": 0,
- "permlevel": 0,
- "print": 1,
- "read": 1,
- "report": 0,
- "role": "Stock Manager",
- "set_user_permissions": 0,
- "share": 1,
- "submit": 0,
- "write": 1
- }
- ],
- "read_only": 0,
- "read_only_onload": 0
-}
\ No newline at end of file
diff --git a/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py b/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py
deleted file mode 100644
index 2676493..0000000
--- a/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py
+++ /dev/null
@@ -1,116 +0,0 @@
-# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-from frappe.utils import cstr, flt, cint
-from frappe import _
-
-
-from frappe.model.document import Document
-
-class StockUOMReplaceUtility(Document):
-
- # Update Stock UOM
- def update_stock_uom(self):
- self.validate_item()
- self.validate_mandatory()
- self.validate_uom_integer_type()
-
- update_stock_ledger_entry(self.item_code, self.new_stock_uom, self.conversion_factor)
- update_bin(self.item_code, self.new_stock_uom, self.conversion_factor)
- update_item_master(self.item_code, self.new_stock_uom, self.conversion_factor)
-
- #if item is template change UOM for all associated variants
- if frappe.db.get_value("Item", self.item_code, "has_variants"):
- for d in frappe.db.get_all("Item", filters= {"variant_of": self.item_code}):
- update_stock_ledger_entry(d.name, self.new_stock_uom, self.conversion_factor)
- update_bin(d.name, self.new_stock_uom, self.conversion_factor)
- update_item_master(d.name, self.new_stock_uom, self.conversion_factor)
-
- def validate_item(self):
- if frappe.db.get_value("Item", self.item_code, "variant_of"):
- frappe.throw(_("You cannot change default UOM of Variant. To change default UOM for Variant change default UOM of the Template"))
-
- def validate_mandatory(self):
- if not cstr(self.item_code):
- frappe.throw(_("Item is required"))
-
- if not cstr(self.new_stock_uom):
- frappe.throw(_("New Stock UOM is required"))
-
- if cstr(self.current_stock_uom) == cstr(self.new_stock_uom):
- frappe.throw(_("New Stock UOM must be different from current stock UOM"))
-
- # check conversion factor
- if not flt(self.conversion_factor):
- frappe.throw(_("Conversion Factor is required"))
-
- stock_uom = frappe.db.get_value("Item", self.item_code, "stock_uom")
- if cstr(self.new_stock_uom) == cstr(stock_uom):
- frappe.throw(_("Item is updated"))
-
- def validate_uom_integer_type(self):
- current_is_integer = frappe.db.get_value("UOM", self.current_stock_uom, "must_be_whole_number")
- new_is_integer = frappe.db.get_value("UOM", self.new_stock_uom, "must_be_whole_number")
-
- if not current_is_integer and new_is_integer:
- frappe.throw(_("New UOM must NOT be of type Whole Number"))
-
- if current_is_integer and new_is_integer and cint(self.conversion_factor)!=self.conversion_factor:
- frappe.throw(_("Conversion factor cannot be in fractions"))
-
-def update_item_master(item_code, new_stock_uom, conversion_factor):
- frappe.db.set_value("Item", item_code, "stock_uom", new_stock_uom)
- frappe.msgprint(_("Stock UOM updated for Item {0}").format(item_code))
-
-def update_bin(item_code, new_stock_uom, conversion_factor):
- # update bin
- if flt(conversion_factor) != flt(1):
- frappe.db.sql("""update `tabBin`
- set stock_uom = %s,
- indented_qty = ifnull(indented_qty,0) * %s,
- ordered_qty = ifnull(ordered_qty,0) * %s,
- reserved_qty = ifnull(reserved_qty,0) * %s,
- planned_qty = ifnull(planned_qty,0) * %s,
- projected_qty = actual_qty + ordered_qty + indented_qty +
- planned_qty - reserved_qty
- where item_code = %s""", (new_stock_uom, conversion_factor,
- conversion_factor, conversion_factor,
- conversion_factor, item_code))
- else:
- frappe.db.sql("update `tabBin` set stock_uom = %s where item_code = %s",
- (new_stock_uom, item_code) )
-
-def update_stock_ledger_entry(item_code, new_stock_uom, conversion_factor):
- # update stock ledger entry
- from erpnext.stock.stock_ledger import update_entries_after
-
- if flt(conversion_factor) != flt(1):
- frappe.db.sql("""update `tabStock Ledger Entry`
- set
- stock_uom = %s,
- actual_qty = ifnull(actual_qty,0) * %s,
- qty_after_transaction = ifnull(qty_after_transaction, 0) * %s
- where item_code = %s""",
- (new_stock_uom, conversion_factor, conversion_factor, item_code))
- else:
- frappe.db.sql("""update `tabStock Ledger Entry` set stock_uom=%s
- where item_code=%s""", (new_stock_uom, item_code))
-
- # acknowledge user
- frappe.msgprint(_("Stock Ledger entries balances updated"))
-
- # update item valuation
- if flt(conversion_factor) != flt(1):
- wh = frappe.db.sql("select name from `tabWarehouse`")
- for w in wh:
- update_entries_after({"item_code": item_code, "warehouse": w[0]})
-
- # acknowledge user
- frappe.msgprint(_("Item valuation updated"))
-
-@frappe.whitelist()
-def get_stock_uom(item_code):
- return { 'current_stock_uom': cstr(frappe.db.get_value('Item', item_code, 'stock_uom')) }
-