initial prototype implementation for issue #856

This commit is contained in:
Thura Hlaing 2014-01-27 14:08:55 +06:30
parent 256c4da0a5
commit 24b26db327
2 changed files with 105 additions and 94 deletions

View File

@ -5,18 +5,23 @@
from __future__ import unicode_literals
import webnotes
from webnotes import _
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",
for key in ["item_naming_by", "item_group", "stock_uom",
"allow_negative_stock"]:
webnotes.conn.set_default(key, self.doc.fields.get(key, ""))
from setup.doctype.naming_series.naming_series import set_by_naming_series
set_by_naming_series("Item", "item_code",
set_by_naming_series("Item", "item_code",
self.doc.get("item_naming_by")=="Naming Series", hide_name_field=True)
stock_frozen_limit = 356
submitted_stock_frozen = self.doc.fields.get("stock_frozen_upto")
if submitted_stock_frozen > stock_frozen_limit:
self.doc.fields["stock_frozen_upto"] = stock_frozen_limit
webnotes.msgprint (_("Stocks cannot be freezed for days larger than %d.") %stock_frozen_limit)

View File

@ -1,128 +1,134 @@
[
{
"creation": "2013-06-24 16:37:54",
"docstatus": 0,
"modified": "2013-11-02 19:41:56",
"modified_by": "Administrator",
"creation": "2013-06-24 16:37:54",
"docstatus": 0,
"modified": "2014-01-27 13:29:56",
"modified_by": "Administrator",
"owner": "Administrator"
},
},
{
"description": "Settings",
"doctype": "DocType",
"icon": "icon-cog",
"issingle": 1,
"module": "Stock",
"description": "Settings",
"doctype": "DocType",
"icon": "icon-cog",
"issingle": 1,
"module": "Stock",
"name": "__common__"
},
},
{
"doctype": "DocField",
"name": "__common__",
"parent": "Stock Settings",
"parentfield": "fields",
"parenttype": "DocType",
"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",
"create": 1,
"doctype": "DocPerm",
"name": "__common__",
"parent": "Stock Settings",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
"read": 1,
"role": "Material Manager",
"write": 1
},
},
{
"doctype": "DocType",
"doctype": "DocType",
"name": "Stock Settings"
},
},
{
"doctype": "DocField",
"fieldname": "item_naming_by",
"fieldtype": "Select",
"label": "Item Naming By",
"doctype": "DocField",
"fieldname": "item_naming_by",
"fieldtype": "Select",
"label": "Item Naming By",
"options": "Item Code\nNaming Series"
},
},
{
"description": "<a href=\"#Sales Browser/Item Group\">Add / Edit</a>",
"doctype": "DocField",
"fieldname": "item_group",
"fieldtype": "Link",
"label": "Default Item Group",
"description": "<a href=\"#Sales Browser/Item Group\">Add / Edit</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",
"doctype": "DocField",
"fieldname": "stock_uom",
"fieldtype": "Link",
"label": "Default Stock UOM",
"options": "UOM"
},
},
{
"doctype": "DocField",
"fieldname": "column_break_4",
"doctype": "DocField",
"fieldname": "column_break_4",
"fieldtype": "Column Break"
},
},
{
"doctype": "DocField",
"fieldname": "allow_negative_stock",
"fieldtype": "Check",
"doctype": "DocField",
"fieldname": "allow_negative_stock",
"fieldtype": "Check",
"label": "Allow Negative Stock"
},
},
{
"doctype": "DocField",
"fieldname": "valuation_method",
"fieldtype": "Select",
"label": "Default Valuation Method",
"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",
"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",
"doctype": "DocField",
"fieldname": "auto_material_request",
"fieldtype": "Section Break",
"label": "Auto Material Request"
},
},
{
"doctype": "DocField",
"fieldname": "auto_indent",
"fieldtype": "Check",
"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",
"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",
"doctype": "DocField",
"fieldname": "freeze_stock_entries",
"fieldtype": "Section Break",
"label": "Freeze Stock Entries"
},
},
{
"doctype": "DocField",
"fieldname": "stock_frozen_upto",
"fieldtype": "Date",
"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",
"doctype": "DocField",
"fieldname": "stock_frozen_upto",
"fieldtype": "Int",
"label": "Stock Frozen Upto"
},
{
"doctype": "DocField",
"fieldname": "stock_auth_role",
"fieldtype": "Link",
"label": "Role Allowed to edit frozen stock",
"options": "Role"
},
},
{
"doctype": "DocPerm"
}
]
]