mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-12 17:51:20 +00:00
[trends analyzer] cleanup completed
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
[
|
||||
{
|
||||
"creation": "2013-01-29 19:25:41",
|
||||
"creation": "2013-05-16 10:59:15",
|
||||
"docstatus": 0,
|
||||
"modified": "2013-01-29 16:27:57",
|
||||
"modified": "2013-06-20 11:23:01",
|
||||
"modified_by": "Administrator",
|
||||
"owner": "Administrator"
|
||||
},
|
||||
{
|
||||
"allow_attach": 1,
|
||||
"allow_rename": 1,
|
||||
"allow_rename": 0,
|
||||
"autoname": "field:serial_no",
|
||||
"description": "Distinct unit of an Item",
|
||||
"doctype": "DocType",
|
||||
@@ -31,7 +31,9 @@
|
||||
"parent": "Serial No",
|
||||
"parentfield": "permissions",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"read": 1,
|
||||
"report": 1,
|
||||
"submit": 0
|
||||
},
|
||||
{
|
||||
@@ -43,12 +45,14 @@
|
||||
"fieldname": "details",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Details",
|
||||
"oldfieldtype": "Section Break"
|
||||
"oldfieldtype": "Section Break",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break0",
|
||||
"fieldtype": "Column Break"
|
||||
"fieldtype": "Column Break",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"default": "In Store",
|
||||
@@ -75,6 +79,7 @@
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "serial_no",
|
||||
"oldfieldtype": "Data",
|
||||
"read_only": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 1
|
||||
},
|
||||
@@ -88,13 +93,15 @@
|
||||
"oldfieldname": "item_code",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Item",
|
||||
"read_only": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break1",
|
||||
"fieldtype": "Column Break"
|
||||
"fieldtype": "Column Break",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -146,12 +153,14 @@
|
||||
"doctype": "DocField",
|
||||
"fieldname": "purchase_details",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Purchase Details"
|
||||
"label": "Purchase Details",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break2",
|
||||
"fieldtype": "Column Break",
|
||||
"read_only": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
@@ -160,7 +169,8 @@
|
||||
"fieldtype": "Select",
|
||||
"label": "Purchase Document Type",
|
||||
"no_copy": 1,
|
||||
"options": "\nPurchase Receipt\nStock Entry"
|
||||
"options": "\nPurchase Receipt\nStock Entry",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -168,7 +178,8 @@
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"label": "Purchase Document No",
|
||||
"no_copy": 1
|
||||
"no_copy": 1,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -179,6 +190,7 @@
|
||||
"no_copy": 1,
|
||||
"oldfieldname": "purchase_date",
|
||||
"oldfieldtype": "Date",
|
||||
"read_only": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0
|
||||
},
|
||||
@@ -188,6 +200,7 @@
|
||||
"fieldtype": "Time",
|
||||
"label": "Incoming Time",
|
||||
"no_copy": 1,
|
||||
"read_only": 0,
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
@@ -200,6 +213,7 @@
|
||||
"oldfieldname": "purchase_rate",
|
||||
"oldfieldtype": "Currency",
|
||||
"options": "Company:company:default_currency",
|
||||
"read_only": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0
|
||||
},
|
||||
@@ -207,6 +221,7 @@
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break3",
|
||||
"fieldtype": "Column Break",
|
||||
"read_only": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
@@ -220,6 +235,7 @@
|
||||
"oldfieldname": "warehouse",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Warehouse",
|
||||
"read_only": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 1
|
||||
},
|
||||
@@ -230,7 +246,8 @@
|
||||
"in_filter": 1,
|
||||
"label": "Supplier",
|
||||
"no_copy": 1,
|
||||
"options": "Supplier"
|
||||
"options": "Supplier",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -254,12 +271,14 @@
|
||||
"fieldname": "delivery_details",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Delivery Details",
|
||||
"oldfieldtype": "Column Break"
|
||||
"oldfieldtype": "Column Break",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break4",
|
||||
"fieldtype": "Column Break",
|
||||
"read_only": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
@@ -318,12 +337,14 @@
|
||||
"oldfieldname": "is_cancelled",
|
||||
"oldfieldtype": "Select",
|
||||
"options": "\nYes\nNo",
|
||||
"read_only": 0,
|
||||
"report_hide": 1
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break5",
|
||||
"fieldtype": "Column Break",
|
||||
"read_only": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
@@ -378,12 +399,14 @@
|
||||
"doctype": "DocField",
|
||||
"fieldname": "warranty_amc_details",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Warranty / AMC Details"
|
||||
"label": "Warranty / AMC Details",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break6",
|
||||
"fieldtype": "Column Break",
|
||||
"read_only": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
@@ -396,6 +419,7 @@
|
||||
"oldfieldname": "maintenance_status",
|
||||
"oldfieldtype": "Select",
|
||||
"options": "\nUnder Warranty\nOut of Warranty\nUnder AMC\nOut of AMC",
|
||||
"read_only": 0,
|
||||
"search_index": 1,
|
||||
"width": "150px"
|
||||
},
|
||||
@@ -406,12 +430,14 @@
|
||||
"label": "Warranty Period (Days)",
|
||||
"oldfieldname": "warranty_period",
|
||||
"oldfieldtype": "Int",
|
||||
"read_only": 0,
|
||||
"width": "150px"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "column_break7",
|
||||
"fieldtype": "Column Break",
|
||||
"read_only": 0,
|
||||
"width": "50%"
|
||||
},
|
||||
{
|
||||
@@ -422,6 +448,7 @@
|
||||
"label": "Warranty Expiry Date",
|
||||
"oldfieldname": "warranty_expiry_date",
|
||||
"oldfieldtype": "Date",
|
||||
"read_only": 0,
|
||||
"width": "150px"
|
||||
},
|
||||
{
|
||||
@@ -432,6 +459,7 @@
|
||||
"label": "AMC Expiry Date",
|
||||
"oldfieldname": "amc_expiry_date",
|
||||
"oldfieldtype": "Date",
|
||||
"read_only": 0,
|
||||
"search_index": 0,
|
||||
"width": "150px"
|
||||
},
|
||||
@@ -439,13 +467,15 @@
|
||||
"doctype": "DocField",
|
||||
"fieldname": "more_info",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "More Info"
|
||||
"label": "More Info",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"fieldname": "serial_no_details",
|
||||
"fieldtype": "Text Editor",
|
||||
"label": "Serial No Details"
|
||||
"label": "Serial No Details",
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
@@ -454,6 +484,7 @@
|
||||
"in_filter": 1,
|
||||
"label": "Company",
|
||||
"options": "link:Company",
|
||||
"read_only": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 1
|
||||
},
|
||||
@@ -464,6 +495,7 @@
|
||||
"in_filter": 1,
|
||||
"label": "Fiscal Year",
|
||||
"options": "link:Fiscal Year",
|
||||
"read_only": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 1
|
||||
},
|
||||
@@ -487,54 +519,10 @@
|
||||
"read_only": 1,
|
||||
"report_hide": 1
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"match": "",
|
||||
"permlevel": 1,
|
||||
"report": 0,
|
||||
"role": "Material Manager",
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"report": 1,
|
||||
"role": "Material Manager",
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"match": "",
|
||||
"permlevel": 1,
|
||||
"report": 0,
|
||||
"role": "Material User",
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"report": 1,
|
||||
"role": "Material User",
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"report": 1,
|
||||
"role": "System Manager",
|
||||
"write": 1
|
||||
},
|
||||
@@ -542,8 +530,6 @@
|
||||
"cancel": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"permlevel": 0,
|
||||
"report": 1,
|
||||
"role": "Material Master Manager",
|
||||
"write": 1
|
||||
},
|
||||
@@ -552,17 +538,15 @@
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"match": "",
|
||||
"permlevel": 1,
|
||||
"role": "System Manager"
|
||||
"role": "Material Manager",
|
||||
"write": 0
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"cancel": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"match": "",
|
||||
"permlevel": 1,
|
||||
"role": "Sales Master Manager"
|
||||
"role": "Material User",
|
||||
"write": 0
|
||||
}
|
||||
]
|
||||
@@ -21,6 +21,9 @@ class TestStockEntry(unittest.TestCase):
|
||||
st2.insert()
|
||||
st2.submit()
|
||||
|
||||
from stock.utils import reorder_item
|
||||
reorder_item()
|
||||
|
||||
mr_name = webnotes.conn.sql("""select parent from `tabMaterial Request Item`
|
||||
where item_code='_Test Item'""")
|
||||
|
||||
|
||||
@@ -21,14 +21,8 @@ from controllers.trends import get_columns,get_data
|
||||
def execute(filters=None):
|
||||
if not filters: filters ={}
|
||||
data = []
|
||||
|
||||
trans = "Delivery Note"
|
||||
tab = ["tabDelivery Note","tabDelivery Note Item"]
|
||||
conditions = get_columns(filters, trans)
|
||||
data = get_data(filters, conditions)
|
||||
|
||||
details = get_columns(filters, trans)
|
||||
data = get_data(filters, tab, details)
|
||||
|
||||
if not data :
|
||||
webnotes.msgprint("Data not found for selected criterias")
|
||||
|
||||
return details["columns"], data
|
||||
return conditions["columns"], data
|
||||
@@ -69,10 +69,11 @@ def get_price_list():
|
||||
from `tabItem Price` where docstatus<2""", as_dict=1)
|
||||
|
||||
for j in price_list:
|
||||
if j.selling:
|
||||
rate.setdefault(j.parent, {}).setdefault("selling", []).append(j.price)
|
||||
if j.buying:
|
||||
rate.setdefault(j.parent, {}).setdefault("buying", []).append(j.price)
|
||||
if j.price:
|
||||
if j.selling:
|
||||
rate.setdefault(j.parent, {}).setdefault("selling", []).append(j.price)
|
||||
if j.buying:
|
||||
rate.setdefault(j.parent, {}).setdefault("buying", []).append(j.price)
|
||||
|
||||
item_rate_map = {}
|
||||
|
||||
|
||||
@@ -21,14 +21,11 @@ from controllers.trends import get_columns,get_data
|
||||
def execute(filters=None):
|
||||
if not filters: filters ={}
|
||||
data = []
|
||||
|
||||
trans = "Purchase Receipt"
|
||||
tab = ["tabPurchase Receipt","tabPurchase Receipt Item"]
|
||||
|
||||
details = get_columns(filters, trans)
|
||||
data = get_data(filters, tab, details)
|
||||
conditions = get_columns(filters, trans)
|
||||
data = get_data(filters, tab, conditions)
|
||||
|
||||
if not data :
|
||||
webnotes.msgprint("Data not found for selected criterias")
|
||||
|
||||
return details["columns"], data
|
||||
return conditions["columns"], data
|
||||
@@ -19,13 +19,14 @@ from webnotes import msgprint, _
|
||||
import json
|
||||
from webnotes.utils import flt, cstr, nowdate, add_days, cint
|
||||
from webnotes.defaults import get_global_default
|
||||
from webnotes.utils.email_lib import sendmail
|
||||
|
||||
def validate_end_of_life(item_code, end_of_life=None, verbose=1):
|
||||
if not end_of_life:
|
||||
end_of_life = webnotes.conn.get_value("Item", item_code, "end_of_life")
|
||||
|
||||
from webnotes.utils import getdate, now_datetime, formatdate
|
||||
if end_of_life and getdate(end_of_life) > now_datetime().date():
|
||||
if end_of_life and getdate(end_of_life) <= now_datetime().date():
|
||||
msg = (_("Item") + " %(item_code)s: " + _("reached its end of life on") + \
|
||||
" %(date)s. " + _("Please check") + ": %(end_of_life_label)s " + \
|
||||
"in Item master") % {
|
||||
@@ -205,7 +206,11 @@ def reorder_item():
|
||||
if webnotes.auto_indent:
|
||||
material_requests = {}
|
||||
bin_list = webnotes.conn.sql("""select item_code, warehouse, projected_qty
|
||||
from tabBin where ifnull(item_code, '') != '' and ifnull(warehouse, '') != ''""",
|
||||
from tabBin where ifnull(item_code, '') != '' and ifnull(warehouse, '') != ''
|
||||
and exists (select name from `tabItem`
|
||||
where `tabItem`.name = `tabBin`.item_code and
|
||||
is_stock_item='Yes' and (is_purchase_item='Yes' or is_sub_contracted_item='Yes') and
|
||||
(ifnull(end_of_life, '')='') or end_of_life > now())""",
|
||||
as_dict=True)
|
||||
for bin in bin_list:
|
||||
#check if re-order is required
|
||||
@@ -220,7 +225,7 @@ def reorder_item():
|
||||
["re_order_level", "re_order_qty"])
|
||||
material_request_type = "Purchase"
|
||||
|
||||
if reorder_level and flt(bin.projected_qty) < flt(reorder_level):
|
||||
if flt(reorder_level) and flt(bin.projected_qty) < flt(reorder_level):
|
||||
if flt(reorder_level) - flt(bin.projected_qty) > flt(reorder_qty):
|
||||
reorder_qty = flt(reorder_level) - flt(bin.projected_qty)
|
||||
|
||||
@@ -242,10 +247,14 @@ def create_material_request(material_requests):
|
||||
""" Create indent on reaching reorder level """
|
||||
mr_list = []
|
||||
defaults = webnotes.defaults.get_defaults()
|
||||
exceptions_list = []
|
||||
for request_type in material_requests:
|
||||
for company in material_requests[request_type]:
|
||||
items = material_requests[request_type][company]
|
||||
if items:
|
||||
try:
|
||||
items = material_requests[request_type][company]
|
||||
if not items:
|
||||
continue
|
||||
|
||||
mr = [{
|
||||
"doctype": "Material Request",
|
||||
"company": company,
|
||||
@@ -257,27 +266,34 @@ def create_material_request(material_requests):
|
||||
quantity reaches re-order level when the following record was created""")
|
||||
}]
|
||||
|
||||
for d in items:
|
||||
item = webnotes.doc("Item", d.item_code)
|
||||
mr.append({
|
||||
"doctype": "Material Request Item",
|
||||
"parenttype": "Material Request",
|
||||
"parentfield": "indent_details",
|
||||
"item_code": d.item_code,
|
||||
"schedule_date": add_days(nowdate(),cint(item.lead_time_days)),
|
||||
"uom": item.stock_uom,
|
||||
"warehouse": d.warehouse,
|
||||
"item_name": item.item_name,
|
||||
"description": item.description,
|
||||
"item_group": item.item_group,
|
||||
"qty": d.reorder_qty,
|
||||
"brand": item.brand,
|
||||
})
|
||||
for d in items:
|
||||
item = webnotes.doc("Item", d.item_code)
|
||||
mr.append({
|
||||
"doctype": "Material Request Item",
|
||||
"parenttype": "Material Request",
|
||||
"parentfield": "indent_details",
|
||||
"item_code": d.item_code,
|
||||
"schedule_date": add_days(nowdate(),cint(item.lead_time_days)),
|
||||
"uom": item.stock_uom,
|
||||
"warehouse": d.warehouse,
|
||||
"item_name": item.item_name,
|
||||
"description": item.description,
|
||||
"item_group": item.item_group,
|
||||
"qty": d.reorder_qty,
|
||||
"brand": item.brand,
|
||||
})
|
||||
|
||||
mr_bean = webnotes.bean(mr)
|
||||
mr_bean.insert()
|
||||
mr_bean.submit()
|
||||
mr_list.append(mr_bean)
|
||||
mr_bean = webnotes.bean(mr)
|
||||
mr_bean.insert()
|
||||
mr_bean.submit()
|
||||
mr_list.append(mr_bean)
|
||||
|
||||
except:
|
||||
if webnotes.message_log:
|
||||
exceptions_list.append([] + webnotes.message_log)
|
||||
webnotes.message_log = []
|
||||
else:
|
||||
exceptions_list.append(webnotes.getTraceback())
|
||||
|
||||
if mr_list:
|
||||
if not hasattr(webnotes, "reorder_email_notify"):
|
||||
@@ -286,11 +302,13 @@ def create_material_request(material_requests):
|
||||
|
||||
if(webnotes.reorder_email_notify):
|
||||
send_email_notification(mr_list)
|
||||
|
||||
if exceptions_list:
|
||||
notify_errors(exceptions_list)
|
||||
|
||||
def send_email_notification(mr_list):
|
||||
""" Notify user about auto creation of indent"""
|
||||
|
||||
from webnotes.utils.email_lib import sendmail
|
||||
email_list = webnotes.conn.sql_list("""select distinct r.parent
|
||||
from tabUserRole r, tabProfile p
|
||||
where p.name = r.parent and p.enabled = 1 and p.docstatus < 2
|
||||
@@ -307,4 +325,22 @@ def send_email_notification(mr_list):
|
||||
cstr(item.qty) + "</td><td>" + cstr(item.uom) + "</td></tr>"
|
||||
msg += "</table>"
|
||||
|
||||
sendmail(email_list, subject='Auto Material Request Generation Notification', msg = msg)
|
||||
sendmail(email_list, subject='Auto Material Request Generation Notification', msg = msg)
|
||||
|
||||
def notify_errors(exceptions_list):
|
||||
subject = "[Important] [ERPNext] Error(s) while creating Material Requests based on Re-order Levels"
|
||||
msg = """Dear System Manager,
|
||||
|
||||
An error occured for certain Items while creating Material Requests based on Re-order level.
|
||||
|
||||
Please rectify these issues:
|
||||
---
|
||||
|
||||
%s
|
||||
|
||||
---
|
||||
Regards,
|
||||
Administrator""" % ("\n\n".join(["\n".join(msg) for msg in exceptions_list]),)
|
||||
|
||||
from webnotes.profile import get_system_managers
|
||||
sendmail(get_system_managers(), subject=subject, msg=msg)
|
||||
|
||||
Reference in New Issue
Block a user