mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 19:59:12 +00:00
[bug fixes] [global defaults] [cleanup]
This commit is contained in:
@@ -11,7 +11,7 @@ class TestStockEntry(unittest.TestCase):
|
||||
webnotes.conn.sql("""delete from `tabMaterial Request`""")
|
||||
self._clear_stock()
|
||||
|
||||
webnotes.conn.set_value("Global Defaults", None, "auto_indent", True)
|
||||
webnotes.conn.set_value("Stock Settings", None, "auto_indent", True)
|
||||
|
||||
st1 = webnotes.bean(copy=test_records[0])
|
||||
st1.insert()
|
||||
|
||||
@@ -110,9 +110,9 @@ class DocType(DocListController):
|
||||
# Nobody can do SL Entries where posting date is before freezing date except authorized person
|
||||
#----------------------------------------------------------------------------------------------
|
||||
def check_stock_frozen_date(self):
|
||||
stock_frozen_upto = webnotes.conn.get_value('Global Defaults', None, 'stock_frozen_upto') or ''
|
||||
stock_frozen_upto = webnotes.conn.get_value('Stock Settings', None, 'stock_frozen_upto') or ''
|
||||
if stock_frozen_upto:
|
||||
stock_auth_role = webnotes.conn.get_value('Global Defaults', None,'stock_auth_role')
|
||||
stock_auth_role = webnotes.conn.get_value('Stock Settings', None,'stock_auth_role')
|
||||
if getdate(self.doc.posting_date) <= getdate(stock_frozen_upto) and not stock_auth_role in webnotes.user.get_roles():
|
||||
msgprint("You are not authorized to do / modify back dated stock entries before %s" % getdate(stock_frozen_upto).strftime('%d-%m-%Y'), raise_exception=1)
|
||||
|
||||
|
||||
0
stock/doctype/stock_settings/__init__.py
Normal file
0
stock/doctype/stock_settings/__init__.py
Normal file
13
stock/doctype/stock_settings/stock_settings.py
Normal file
13
stock/doctype/stock_settings/stock_settings.py
Normal file
@@ -0,0 +1,13 @@
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def validate(self):
|
||||
for key in ["item_naming_by", "item_group", "stock_uom",
|
||||
"allow_negative_stock"]:
|
||||
webnotes.conn.set_default(key, self.doc.fields.get(key, ""))
|
||||
127
stock/doctype/stock_settings/stock_settings.txt
Normal file
127
stock/doctype/stock_settings/stock_settings.txt
Normal file
@@ -0,0 +1,127 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-06-24 16:37:54",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-06-24 17:41:02",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"description": "Settings",
|
||||
"doctype": "DocType",
|
||||
"issingle": 1,
|
||||
"module": "Stock",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"name": "__common__",
|
||||
"parent": "Stock Settings",
|
||||
"parentfield": "fields",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"name": "__common__",
|
||||
"parent": "Stock Settings",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"role": "Material Manager",
|
||||
"write": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocType",
|
||||
"name": "Stock Settings"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "item_naming_by",
|
||||
"fieldtype": "Select",
|
||||
"label": "Item Naming By",
|
||||
"options": "Item Code\nNaming Series"
|
||||
},
|
||||
{
|
||||
"description": "<a href=\"#Sales Browser/Item Group\">Manage Item Groups</a>",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "item_group",
|
||||
"fieldtype": "Link",
|
||||
"label": "Default Item Group",
|
||||
"options": "Item Group"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "stock_uom",
|
||||
"fieldtype": "Link",
|
||||
"label": "Default Stock UOM",
|
||||
"options": "UOM"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break_4",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "allow_negative_stock",
|
||||
"fieldtype": "Check",
|
||||
"label": "Allow Negative Stock"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "valuation_method",
|
||||
"fieldtype": "Select",
|
||||
"label": "Default Valuation Method",
|
||||
"options": "FIFO\nMoving Average"
|
||||
},
|
||||
{
|
||||
"description": "Percentage you are allowed to receive or deliver more against the quantity ordered. For example: If you have ordered 100 units. and your Allowance is 10% then you are allowed to receive 110 units.",
|
||||
"doctype": "DocField",
|
||||
"fieldname": "tolerance",
|
||||
"fieldtype": "Float",
|
||||
"label": "Allowance Percent"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "auto_material_request",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Auto Material Request"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "auto_indent",
|
||||
"fieldtype": "Check",
|
||||
"label": "Raise Material Request when stock reaches re-order level"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "reorder_email_notify",
|
||||
"fieldtype": "Check",
|
||||
"label": "Notify by Email on creation of automatic Material Request"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "freeze_stock_entries",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Freeze Stock Entries"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "stock_frozen_upto",
|
||||
"fieldtype": "Date",
|
||||
"label": "Stock Frozen Upto"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "stock_auth_role",
|
||||
"fieldtype": "Link",
|
||||
"label": "Role Allowed to edit frozen stock",
|
||||
"options": "Role"
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm"
|
||||
}
|
||||
]
|
||||
@@ -101,6 +101,12 @@ wn.module_page["Stock"] = [
|
||||
title: wn._("Setup"),
|
||||
icon: "icon-cog",
|
||||
items: [
|
||||
{
|
||||
"label": wn._("Stock Settings"),
|
||||
"route": "Form/Stock Settings",
|
||||
"doctype":"Stock Settings",
|
||||
"description": "Settings for Stock"
|
||||
},
|
||||
{
|
||||
"route":"Sales Browser/Item Group",
|
||||
"label": wn._("Item Group"),
|
||||
|
||||
@@ -201,7 +201,7 @@ def _get_buying_amount(voucher_type, voucher_no, item_row, item_code, warehouse,
|
||||
def reorder_item():
|
||||
""" Reorder item if stock reaches reorder level"""
|
||||
if not hasattr(webnotes, "auto_indent"):
|
||||
webnotes.auto_indent = webnotes.conn.get_value('Global Defaults', None, 'auto_indent')
|
||||
webnotes.auto_indent = webnotes.conn.get_value('Stock Settings', None, 'auto_indent')
|
||||
|
||||
if webnotes.auto_indent:
|
||||
material_requests = {}
|
||||
@@ -297,7 +297,7 @@ def create_material_request(material_requests):
|
||||
|
||||
if mr_list:
|
||||
if not hasattr(webnotes, "reorder_email_notify"):
|
||||
webnotes.reorder_email_notify = webnotes.conn.get_value('Global Defaults', None,
|
||||
webnotes.reorder_email_notify = webnotes.conn.get_value('Stock Settings', None,
|
||||
'reorder_email_notify')
|
||||
|
||||
if(webnotes.reorder_email_notify):
|
||||
|
||||
Reference in New Issue
Block a user