Deleted Stock UOM Replace Utility
This commit is contained in:
parent
f71ecbba2c
commit
61fb7ee5b8
@ -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 -->
|
|
@ -1,4 +1,3 @@
|
|||||||
packing-slip
|
packing-slip
|
||||||
quality-inspection
|
quality-inspection
|
||||||
landed-cost-voucher
|
landed-cost-voucher
|
||||||
stock-uom-replace-utility
|
|
@ -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}
|
|
@ -231,3 +231,4 @@ erpnext.patches.v6_4.fix_expense_included_in_valuation
|
|||||||
execute:frappe.delete_doc_if_exists("Report", "Item-wise Last Purchase Rate")
|
execute:frappe.delete_doc_if_exists("Report", "Item-wise Last Purchase Rate")
|
||||||
erpnext.patches.v6_6.fix_website_image
|
erpnext.patches.v6_6.fix_website_image
|
||||||
erpnext.patches.v6_6.remove_fiscal_year_from_leave_allocation
|
erpnext.patches.v6_6.remove_fiscal_year_from_leave_allocation
|
||||||
|
execute:frappe.delete_doc_if_exists("DocType", "Stock UOM Replace Utility")
|
@ -1 +0,0 @@
|
|||||||
Tool to replace unit of measure (UoM) of an Item.
|
|
@ -1 +0,0 @@
|
|||||||
from __future__ import unicode_literals
|
|
@ -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 }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
@ -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
|
|
||||||
}
|
|
@ -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')) }
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user