rename Purchase Request to Material Request

This commit is contained in:
Anand Doshi
2013-02-18 13:49:15 +05:30
parent de46f43dc1
commit 236cc173ad
50 changed files with 1769 additions and 323 deletions

View File

@@ -119,17 +119,17 @@ class DocType:
def create_auto_indent(self, i , doc_type, doc_name, cur_qty):
""" Create indent on reaching reorder level """
indent = Document('Purchase Request')
indent = Document('Material Request')
indent.transaction_date = nowdate()
indent.naming_series = 'IDT'
indent.company = get_defaults()['company']
indent.fiscal_year = get_defaults()['fiscal_year']
indent.remark = """This is an auto generated Purchase Request.
indent.remark = """This is an auto generated Material Request.
It was raised because the (actual + ordered + indented - reserved) quantity
reaches re-order level when %s %s was created""" % (doc_type,doc_name)
indent.save(1)
indent_obj = get_obj('Purchase Request',indent.name,with_children=1)
indent_details_child = addchild(indent_obj.doc,'indent_details','Purchase Request Item')
indent_obj = get_obj('Material Request',indent.name,with_children=1)
indent_details_child = addchild(indent_obj.doc,'indent_details','Material Request Item')
indent_details_child.item_code = self.doc.item_code
indent_details_child.uom = self.doc.stock_uom
indent_details_child.warehouse = self.doc.warehouse
@@ -140,11 +140,11 @@ class DocType:
indent_details_child.qty = i['re_order_qty'] or (flt(i['re_order_level']) - flt(cur_qty))
indent_details_child.brand = i['brand']
indent_details_child.save()
indent_obj = get_obj('Purchase Request',indent.name,with_children=1)
indent_obj = get_obj('Material Request',indent.name,with_children=1)
indent_obj.validate()
webnotes.conn.set(indent_obj.doc,'docstatus',1)
indent_obj.on_submit()
msgprint("""Item: %s is to be re-ordered. Purchase Request %s raised.
msgprint("""Item: %s is to be re-ordered. Material Request %s raised.
It was generated from %s: %s""" %
(self.doc.item_code, indent.name, doc_type, doc_name ))
if(i['email_notify']):
@@ -158,6 +158,6 @@ class DocType:
where p.name = r.parent and p.enabled = 1 and p.docstatus < 2
and r.role in ('Purchase Manager','Material Manager')
and p.name not in ('Administrator', 'All', 'Guest')""")]
msg="""A Purchase Request has been raised
msg="""A Material Request has been raised
for item %s: %s on %s """ % (doc_type, doc_name, nowdate())
sendmail(email_list, subject='Auto Purchase Request Generation Notification', msg = msg)
sendmail(email_list, subject='Auto Material Request Generation Notification', msg = msg)

View File

@@ -1,8 +1,8 @@
[
{
"creation": "2013-01-21 18:19:22",
"creation": "2013-02-18 13:36:21",
"docstatus": 0,
"modified": "2013-01-29 13:32:21",
"modified": "2013-02-18 13:46:29",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -28,14 +28,13 @@
"permlevel": 0
},
{
"amend": 0,
"doctype": "DocPerm",
"name": "__common__",
"parent": "Item",
"parentfield": "permissions",
"parenttype": "DocType",
"permlevel": 0,
"read": 1,
"report": 1,
"submit": 0
},
{
@@ -200,32 +199,6 @@
"oldfieldname": "tolerance",
"oldfieldtype": "Currency"
},
{
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
"description": "The system will generate a Purchase Request automatically when stock quantity goes below re-order level in warehouse of type \"Stores\" or \"Reserved Warehouse\".",
"doctype": "DocField",
"fieldname": "re_order_level",
"fieldtype": "Float",
"label": "Re-Order Level",
"oldfieldname": "re_order_level",
"oldfieldtype": "Currency"
},
{
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
"description": "The quantity for the Purchase Request when the stock goes below re-order level.",
"doctype": "DocField",
"fieldname": "re_order_qty",
"fieldtype": "Float",
"label": "Re-Order Qty"
},
{
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
"description": "Send an email to users of role \"Material Manager\" and \"Purchase Manager\" when re-order level is crossed.",
"doctype": "DocField",
"fieldname": "email_notify",
"fieldtype": "Check",
"label": "Notify by Email on Re-order"
},
{
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
"doctype": "DocField",
@@ -327,6 +300,54 @@
"label": "Weight UOM",
"options": "UOM"
},
{
"doctype": "DocField",
"fieldname": "reorder_section",
"fieldtype": "Section Break",
"label": "Re-order"
},
{
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
"doctype": "DocField",
"fieldname": "re_order_level",
"fieldtype": "Float",
"label": "Re-Order Level",
"oldfieldname": "re_order_level",
"oldfieldtype": "Currency"
},
{
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
"doctype": "DocField",
"fieldname": "re_order_qty",
"fieldtype": "Float",
"label": "Re-Order Qty"
},
{
"doctype": "DocField",
"fieldname": "column_break_31",
"fieldtype": "Column Break"
},
{
"depends_on": "eval:doc.is_stock_item==\"Yes\"",
"description": "Send an email to users of role \"Material Manager\" and \"Purchase Manager\" when re-order level is crossed.",
"doctype": "DocField",
"fieldname": "email_notify",
"fieldtype": "Check",
"label": "Notify by Email on Re-order"
},
{
"doctype": "DocField",
"fieldname": "section_break_31",
"fieldtype": "Section Break",
"options": "Simple"
},
{
"doctype": "DocField",
"fieldname": "item_reorder",
"fieldtype": "Table",
"label": "Warehouse-wise Item Reorder",
"options": "Item Reorder"
},
{
"doctype": "DocField",
"fieldname": "purchase_details",
@@ -348,7 +369,7 @@
},
{
"depends_on": "eval:doc.is_purchase_item==\"Yes\"",
"description": "Lead Time days is number of days by which this item is expected in your warehouse. This days is fetched in Purchase Request when you select this item.",
"description": "Lead Time days is number of days by which this item is expected in your warehouse. This days is fetched in Material Request when you select this item.",
"doctype": "DocField",
"fieldname": "lead_time_days",
"fieldtype": "Int",
@@ -791,18 +812,38 @@
"label": "Website Description"
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"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
},
{
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 1,
"report": 0,
"role": "Material User",
"write": 0
},
{
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 0,
"report": 1,
"role": "Material User",
"write": 0
},
@@ -810,7 +851,36 @@
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"permlevel": 0,
"report": 1,
"role": "Material Master Manager",
"write": 1
},
{
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 1,
"report": 0,
"role": "Material Master Manager",
"write": 0
},
{
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"permlevel": 0,
"report": 1,
"role": "System Manager",
"write": 1
},
{
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 1,
"report": 0,
"role": "System Manager",
"write": 0
}
]

View File

View File

@@ -0,0 +1,8 @@
# 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

View File

@@ -0,0 +1,56 @@
[
{
"creation": "2013-02-18 12:48:07",
"docstatus": 0,
"modified": "2013-02-18 12:54:46",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"autoname": "REORD-.#####",
"doctype": "DocType",
"in_create": 1,
"istable": 1,
"module": "Stock",
"name": "__common__"
},
{
"doctype": "DocField",
"name": "__common__",
"parent": "Item Reorder",
"parentfield": "fields",
"parenttype": "DocType",
"permlevel": 0
},
{
"doctype": "DocType",
"name": "Item Reorder"
},
{
"doctype": "DocField",
"fieldname": "warehouse",
"fieldtype": "Link",
"label": "Warehouse",
"options": "Warehouse",
"reqd": 1
},
{
"doctype": "DocField",
"fieldname": "warehouse_reorder_level",
"fieldtype": "Float",
"label": "Re-order Level"
},
{
"doctype": "DocField",
"fieldname": "warehouse_reorder_qty",
"fieldtype": "Float",
"label": "Re-order Qty"
},
{
"doctype": "DocField",
"fieldname": "material_request_type",
"fieldtype": "Select",
"label": "Material Request Type",
"options": "Purchase\nTransfer"
}
]

View File

@@ -0,0 +1,141 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
cur_frm.cscript.tname = "Material Request Item";
cur_frm.cscript.fname = "indent_details";
wn.require('app/buying/doctype/purchase_common/purchase_common.js');
wn.require('app/utilities/doctype/sms_control/sms_control.js');
erpnext.buying.PurchaseRequestController = erpnext.buying.BuyingController.extend({
refresh: function(doc) {
this._super();
if(doc.docstatus == 1 && doc.status != 'Stopped'){
cur_frm.add_custom_button("Make Supplier Quotation", cur_frm.cscript.make_supplier_quotation);
if(flt(doc.per_ordered, 2) < 100) {
cur_frm.add_custom_button('Make Purchase Order', cur_frm.cscript['Make Purchase Order']);
cur_frm.add_custom_button('Stop Material Request', cur_frm.cscript['Stop Material Request']);
}
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
}
if(doc.docstatus == 1 && doc.status == 'Stopped')
cur_frm.add_custom_button('Unstop Material Request', cur_frm.cscript['Unstop Material Request'])
}
});
var new_cscript = new erpnext.buying.PurchaseRequestController({frm: cur_frm});
// for backward compatibility: combine new and previous states
$.extend(cur_frm.cscript, new_cscript);
//========================== On Load =================================================
cur_frm.cscript.onload = function(doc, cdt, cdn) {
if (!doc.transaction_date) doc.transaction_date = dateutil.obj_to_str(new Date())
if (!doc.status) doc.status = 'Draft';
// defined in purchase_common.js
//cur_frm.cscript.update_item_details(doc, cdt, cdn);
}
cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
// second call
if(doc.__islocal){
cur_frm.cscript.get_item_defaults(doc);
}
}
cur_frm.cscript.get_item_defaults = function(doc) {
var ch = getchildren( 'Material Request Item', doc.name, 'indent_details');
if (flt(ch.length) > 0){
$c_obj(make_doclist(doc.doctype, doc.name), 'get_item_defaults', '', function(r, rt) {refresh_field('indent_details'); });
}
}
//======================= transaction date =============================
cur_frm.cscript.transaction_date = function(doc,cdt,cdn){
if(doc.__islocal){
cur_frm.cscript.get_default_schedule_date(doc);
}
}
//=================== Quantity ===================================================================
cur_frm.cscript.qty = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if (flt(d.qty) < flt(d.min_order_qty))
alert("Warning: Material Requested Qty is less than Minimum Order Qty");
}
// On Button Click Functions
// ------------------------------------------------------------------------------
// Make Purchase Order
cur_frm.cscript['Make Purchase Order'] = function() {
var doc = cur_frm.doc;
n = wn.model.make_new_doc_and_get_name('Purchase Order');
$c('dt_map', args={
'docs':wn.model.compress([locals['Purchase Order'][n]]),
'from_doctype':doc.doctype,
'to_doctype':'Purchase Order',
'from_docname':doc.name,
'from_to_list':"[['Material Request','Purchase Order'],['Material Request Item','Purchase Order Item']]"
}, function(r,rt) {
loaddoc('Purchase Order', n);
}
);
}
// Stop INDENT
// ==================================================================================================
cur_frm.cscript['Stop Material Request'] = function() {
var doc = cur_frm.doc;
var check = confirm("Do you really want to STOP this Material Request?");
if (check) {
$c('runserverobj', args={'method':'update_status', 'arg': 'Stopped', 'docs': wn.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
cur_frm.refresh();
});
}
}
// Un Stop INDENT
//====================================================================================================
cur_frm.cscript['Unstop Material Request'] = function(){
var doc = cur_frm.doc
var check = confirm("Do you really want to UNSTOP this Material Request?");
if (check) {
$c('runserverobj', args={'method':'update_status', 'arg': 'Submitted','docs': wn.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
cur_frm.refresh();
});
}
}
cur_frm.cscript.make_supplier_quotation = function() {
var new_sq_name = wn.model.make_new_doc_and_get_name("Supplier Quotation");
$c("dt_map", {
"docs": wn.model.compress([locals['Supplier Quotation'][new_sq_name]]),
"from_doctype": cur_frm.doc.doctype,
"to_doctype": "Supplier Quotation",
"from_docname": cur_frm.doc.name,
"from_to_list": JSON.stringify([['Material Request', 'Supplier Quotation'],
['Material Request Item', 'Supplier Quotation Item']]),
}, function(r, rt) { loaddoc("Supplier Quotation", new_sq_name) });
}

View File

@@ -0,0 +1,181 @@
# ERPNext - web based ERP (http://erpnext.com)
# For license information, please see license.txt
from __future__ import unicode_literals
import webnotes
from webnotes.utils import cstr, flt, get_defaults
from webnotes.model.wrapper import getlist
from webnotes.model.code import get_obj
from webnotes import msgprint
from controllers.buying_controller import BuyingController
class DocType(BuyingController):
def __init__(self, doc, doclist=[]):
self.doc = doc
self.doclist = doclist
self.defaults = get_defaults()
self.tname = 'Material Request Item'
self.fname = 'indent_details'
def get_default_schedule_date(self):
get_obj(dt = 'Purchase Common').get_default_schedule_date(self)
# get available qty at warehouse
def get_bin_details(self, arg = ''):
return get_obj(dt='Purchase Common').get_bin_details(arg)
# Pull Sales Order Items
# -------------------------
def pull_so_details(self):
self.check_if_already_pulled()
if self.doc.sales_order_no:
get_obj('DocType Mapper', 'Sales Order-Material Request', with_children=1).dt_map('Sales Order', 'Material Request', self.doc.sales_order_no, self.doc, self.doclist, "[['Sales Order', 'Material Request'],['Sales Order Item', 'Material Request Item']]")
self.get_item_defaults()
else:
msgprint("Please select Sales Order whose details need to pull")
def check_if_already_pulled(self):
pass#if self.[d.sales_order_no for d in getlist(self.doclist, 'indent_details')]
# Get item's other details
#- ------------------------
def get_item_defaults(self):
self.get_default_schedule_date()
for d in getlist(self.doclist, 'indent_details'):
det = webnotes.conn.sql("select min_order_qty from tabItem where name = '%s'" % d.item_code)
d.min_order_qty = det and flt(det[0][0]) or 0
# Validate so items
# ----------------------------
def validate_qty_against_so(self):
so_items = {} # Format --> {'SO/00001': {'Item/001': 120, 'Item/002': 24}}
for d in getlist(self.doclist, 'indent_details'):
if d.sales_order_no:
if not so_items.has_key(d.sales_order_no):
so_items[d.sales_order_no] = {d.item_code: flt(d.qty)}
else:
if not so_items[d.sales_order_no].has_key(d.item_code):
so_items[d.sales_order_no][d.item_code] = flt(d.qty)
else:
so_items[d.sales_order_no][d.item_code] += flt(d.qty)
for so_no in so_items.keys():
for item in so_items[so_no].keys():
already_indented = webnotes.conn.sql("select sum(qty) from `tabMaterial Request Item` where item_code = '%s' and sales_order_no = '%s' and docstatus = 1 and parent != '%s'" % (item, so_no, self.doc.name))
already_indented = already_indented and flt(already_indented[0][0]) or 0
actual_so_qty = webnotes.conn.sql("select sum(qty) from `tabSales Order Item` where parent = '%s' and item_code = '%s' and docstatus = 1 group by parent" % (so_no, item))
actual_so_qty = actual_so_qty and flt(actual_so_qty[0][0]) or 0
if flt(so_items[so_no][item]) + already_indented > actual_so_qty:
msgprint("You can raise indent of maximum qty: %s for item: %s against sales order: %s\n Anyway, you can add more qty in new row for the same item." % (actual_so_qty - already_indented, item, so_no), raise_exception=1)
# Validate fiscal year
# ----------------------------
def validate_fiscal_year(self):
get_obj(dt = 'Purchase Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.transaction_date,'Material Request Date')
# GET TERMS & CONDITIONS
#-----------------------------
def get_tc_details(self):
return get_obj('Purchase Common').get_tc_details(self)
# Validate Schedule Date
#--------------------------------
def validate_schedule_date(self):
#:::::::: validate schedule date v/s indent date ::::::::::::
for d in getlist(self.doclist, 'indent_details'):
if d.schedule_date < self.doc.transaction_date:
msgprint("Expected Schedule Date cannot be before Material Request Date")
raise Exception
# Validate
# ---------------------
def validate(self):
super(DocType, self).validate()
self.validate_schedule_date()
self.validate_fiscal_year()
if not self.doc.status:
self.doc.status = "Draft"
import utilities
utilities.validate_status(self.doc.status, ["Draft", "Submitted", "Stopped",
"Cancelled"])
# Get Purchase Common Obj
pc_obj = get_obj(dt='Purchase Common')
# Validate for items
pc_obj.validate_for_items(self)
# Validate qty against SO
self.validate_qty_against_so()
def update_bin(self, is_submit, is_stopped):
""" Update Quantity Requested for Purchase in Bin"""
for d in getlist(self.doclist, 'indent_details'):
if webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == "Yes":
if not d.warehouse:
msgprint("Please Enter Warehouse for Item %s as it is stock item"
% cstr(d.item_code), raise_exception=1)
qty =flt(d.qty)
if is_stopped:
qty = (d.qty > d.ordered_qty) and flt(flt(d.qty) - flt(d.ordered_qty)) or 0
args = {
"item_code": d.item_code,
"indented_qty": (is_submit and 1 or -1) * flt(qty),
"posting_date": self.doc.transaction_date
}
get_obj('Warehouse', d.warehouse).update_bin(args)
def on_submit(self):
purchase_controller = webnotes.get_obj("Purchase Common")
purchase_controller.is_item_table_empty(self)
webnotes.conn.set(self.doc,'status','Submitted')
self.update_bin(is_submit = 1, is_stopped = 0)
def check_modified_date(self):
mod_db = webnotes.conn.sql("select modified from `tabMaterial Request` where name = '%s'" % self.doc.name)
date_diff = webnotes.conn.sql("select TIMEDIFF('%s', '%s')" % ( mod_db[0][0],cstr(self.doc.modified)))
if date_diff and date_diff[0][0]:
msgprint(cstr(self.doc.doctype) +" => "+ cstr(self.doc.name) +" has been modified. Please Refresh. ")
raise Exception
def update_status(self, status):
self.check_modified_date()
# Step 1:=> Update Bin
self.update_bin(is_submit = (status == 'Submitted') and 1 or 0, is_stopped = 1)
# Step 2:=> Set status
webnotes.conn.set(self.doc,'status',cstr(status))
# Step 3:=> Acknowledge User
msgprint(self.doc.doctype + ": " + self.doc.name + " has been %s." % ((status == 'Submitted') and 'Unstopped' or cstr(status)) )
def on_cancel(self):
# Step 1:=> Get Purchase Common Obj
pc_obj = get_obj(dt='Purchase Common')
# Step 2:=> Check for stopped status
pc_obj.check_for_stopped_status( self.doc.doctype, self.doc.name)
# Step 3:=> Check if Purchase Order has been submitted against current Material Request
pc_obj.check_docstatus(check = 'Next', doctype = 'Purchase Order', docname = self.doc.name, detail_doctype = 'Purchase Order Item')
# Step 4:=> Update Bin
self.update_bin(is_submit = 0, is_stopped = (cstr(self.doc.status) == 'Stopped') and 1 or 0)
# Step 5:=> Set Status
webnotes.conn.set(self.doc,'status','Cancelled')

View File

@@ -0,0 +1,427 @@
[
{
"creation": "2013-01-29 19:25:55",
"docstatus": 0,
"modified": "2013-02-18 13:10:37",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"allow_attach": 1,
"allow_print": 0,
"autoname": "naming_series:",
"doctype": "DocType",
"is_submittable": 1,
"module": "Stock",
"name": "__common__",
"read_only_onload": 1,
"search_fields": "status,transaction_date,sales_order_no"
},
{
"doctype": "DocField",
"name": "__common__",
"parent": "Material Request",
"parentfield": "fields",
"parenttype": "DocType",
"permlevel": 0
},
{
"doctype": "DocPerm",
"name": "__common__",
"parent": "Material Request",
"parentfield": "permissions",
"parenttype": "DocType",
"read": 1
},
{
"doctype": "DocType",
"name": "Material Request"
},
{
"description": "To manage multiple series please go to Setup > Manage Series",
"doctype": "DocField",
"fieldname": "naming_series",
"fieldtype": "Select",
"label": "Series",
"no_copy": 1,
"oldfieldname": "naming_series",
"oldfieldtype": "Select",
"options": "MREQ\nIDT",
"print_hide": 1,
"reqd": 1
},
{
"description": "The date at which current entry is made in system.",
"doctype": "DocField",
"fieldname": "transaction_date",
"fieldtype": "Date",
"in_filter": 1,
"label": "Transaction Date",
"no_copy": 1,
"oldfieldname": "transaction_date",
"oldfieldtype": "Date",
"print_width": "100px",
"reqd": 1,
"search_index": 1,
"width": "100px"
},
{
"doctype": "DocField",
"fieldname": "items",
"fieldtype": "Section Break",
"label": "Items",
"oldfieldtype": "Section Break"
},
{
"allow_on_submit": 1,
"doctype": "DocField",
"fieldname": "indent_details",
"fieldtype": "Table",
"label": "Material Request Items",
"no_copy": 0,
"oldfieldname": "indent_details",
"oldfieldtype": "Table",
"options": "Material Request Item"
},
{
"doctype": "DocField",
"fieldname": "section_break1",
"fieldtype": "Section Break",
"options": "Simple"
},
{
"doctype": "DocField",
"fieldname": "column_break4",
"fieldtype": "Column Break",
"print_width": "50%",
"width": "50%"
},
{
"description": "One or multiple Sales Order no which generated this Purchase Requisition",
"doctype": "DocField",
"fieldname": "sales_order_no",
"fieldtype": "Link",
"label": "Sales Order No",
"no_copy": 1,
"oldfieldname": "sales_order_no",
"oldfieldtype": "Data",
"options": "Sales Order",
"print_width": "100px",
"width": "100px"
},
{
"doctype": "DocField",
"fieldname": "column_break5",
"fieldtype": "Column Break",
"print_width": "50%",
"width": "50%"
},
{
"doctype": "DocField",
"fieldname": "pull_sales_order_details",
"fieldtype": "Button",
"label": "Pull Sales Order Items",
"options": "pull_so_details"
},
{
"default": "Give additional details about the indent.",
"description": "Filing in Additional Information about the Purchase Requisition will help you analyze your data better.",
"doctype": "DocField",
"fieldname": "more_info",
"fieldtype": "Section Break",
"label": "More Info",
"oldfieldtype": "Section Break"
},
{
"doctype": "DocField",
"fieldname": "column_break1",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_width": "50%",
"width": "50%"
},
{
"description": "Select the relevant company name if you have multiple companies",
"doctype": "DocField",
"fieldname": "company",
"fieldtype": "Link",
"in_filter": 1,
"label": "Company",
"oldfieldname": "company",
"oldfieldtype": "Link",
"options": "Company",
"print_hide": 1,
"print_width": "150px",
"reqd": 1,
"search_index": 1,
"width": "150px"
},
{
"doctype": "DocField",
"fieldname": "fiscal_year",
"fieldtype": "Select",
"in_filter": 1,
"label": "Fiscal Year",
"oldfieldname": "fiscal_year",
"oldfieldtype": "Select",
"options": "link:Fiscal Year",
"print_hide": 1,
"print_width": "150px",
"reqd": 1,
"search_index": 1,
"width": "150px"
},
{
"description": "Name of the entity who has requested for the Purchase Requisition",
"doctype": "DocField",
"fieldname": "requested_by",
"fieldtype": "Data",
"in_list_view": 0,
"label": "Requested By",
"no_copy": 1,
"oldfieldname": "requested_by",
"oldfieldtype": "Data",
"print_width": "100px",
"width": "100px"
},
{
"description": "After cancelling the Purchase Requisition, a dialog box will ask you reason for cancellation which will be reflected in this field",
"doctype": "DocField",
"fieldname": "cancel_reason",
"fieldtype": "Data",
"label": "Cancel Reason",
"no_copy": 1,
"oldfieldname": "cancel_reason",
"oldfieldtype": "Data",
"print_hide": 1,
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "column_break2",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_width": "50%",
"width": "50%"
},
{
"allow_on_submit": 1,
"doctype": "DocField",
"fieldname": "letter_head",
"fieldtype": "Select",
"label": "Letter Head",
"oldfieldname": "letter_head",
"oldfieldtype": "Select",
"options": "link:Letter Head",
"print_hide": 1
},
{
"doctype": "DocField",
"fieldname": "status",
"fieldtype": "Select",
"in_filter": 1,
"in_list_view": 1,
"label": "Status",
"no_copy": 1,
"oldfieldname": "status",
"oldfieldtype": "Select",
"options": "\nDraft\nSubmitted\nStopped\nCancelled",
"print_hide": 1,
"print_width": "100px",
"read_only": 1,
"reqd": 0,
"search_index": 1,
"width": "100px"
},
{
"description": "% of materials ordered against this Purchase Requisition",
"doctype": "DocField",
"fieldname": "per_ordered",
"fieldtype": "Percent",
"in_list_view": 1,
"label": "% Ordered",
"no_copy": 1,
"oldfieldname": "per_ordered",
"oldfieldtype": "Currency",
"print_hide": 1,
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "amended_from",
"fieldtype": "Data",
"label": "Amended From",
"no_copy": 1,
"oldfieldname": "amended_from",
"oldfieldtype": "Data",
"print_hide": 1,
"print_width": "150px",
"read_only": 1,
"width": "150px"
},
{
"description": "The date at which current entry is corrected in the system.",
"doctype": "DocField",
"fieldname": "amendment_date",
"fieldtype": "Date",
"label": "Amendment Date",
"no_copy": 1,
"oldfieldname": "amendment_date",
"oldfieldtype": "Date",
"print_hide": 1,
"print_width": "100px",
"width": "100px"
},
{
"doctype": "DocField",
"fieldname": "remark",
"fieldtype": "Small Text",
"in_list_view": 1,
"label": "Remarks",
"no_copy": 1,
"oldfieldname": "remark",
"oldfieldtype": "Small Text",
"print_hide": 0,
"print_width": "150px",
"width": "150px"
},
{
"description": "Add Terms and Conditions for the Purchase Requisition. You can also prepare a Terms and Conditions Master and use the Template",
"doctype": "DocField",
"fieldname": "terms_section_break",
"fieldtype": "Section Break",
"label": "Terms and Conditions",
"oldfieldtype": "Section Break"
},
{
"doctype": "DocField",
"fieldname": "tc_name",
"fieldtype": "Link",
"label": "Select Terms and Conditions",
"oldfieldname": "tc_name",
"oldfieldtype": "Link",
"options": "Terms and Conditions",
"print_hide": 1,
"report_hide": 1
},
{
"doctype": "DocField",
"fieldname": "get_terms",
"fieldtype": "Button",
"label": "Get Terms and Conditions",
"oldfieldtype": "Button",
"options": "get_tc_details"
},
{
"doctype": "DocField",
"fieldname": "terms",
"fieldtype": "Text Editor",
"label": "Terms and Conditions Content",
"oldfieldname": "terms",
"oldfieldtype": "Text Editor"
},
{
"allow_on_submit": 1,
"doctype": "DocField",
"fieldname": "select_print_heading",
"fieldtype": "Select",
"label": "Select Print Heading",
"options": "Print Heading",
"print_hide": 1
},
{
"doctype": "DocField",
"fieldname": "file_list",
"fieldtype": "Text",
"hidden": 1,
"label": "File List",
"no_copy": 1,
"print_hide": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 1,
"report": 0,
"role": "Purchase Manager",
"submit": 0,
"write": 0
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"permlevel": 0,
"report": 1,
"role": "Purchase Manager",
"submit": 1,
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 1,
"report": 0,
"role": "Material Manager",
"submit": 0,
"write": 0
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"permlevel": 0,
"report": 1,
"role": "Material Manager",
"submit": 1,
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 1,
"report": 0,
"role": "Material User",
"submit": 0,
"write": 0
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"permlevel": 0,
"report": 1,
"role": "Material User",
"submit": 1,
"write": 1
},
{
"amend": 1,
"cancel": 1,
"create": 1,
"doctype": "DocPerm",
"permlevel": 0,
"report": 1,
"role": "Purchase User",
"submit": 1,
"write": 1
},
{
"amend": 0,
"cancel": 0,
"create": 0,
"doctype": "DocPerm",
"permlevel": 1,
"role": "Purchase User",
"submit": 0
}
]

View File

@@ -0,0 +1,8 @@
# 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

View File

@@ -0,0 +1,207 @@
[
{
"creation": "2013-02-04 10:34:46",
"docstatus": 0,
"modified": "2013-02-18 13:12:44",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"autoname": "MREQD-.#####",
"doctype": "DocType",
"istable": 1,
"module": "Stock",
"name": "__common__"
},
{
"doctype": "DocField",
"name": "__common__",
"parent": "Material Request Item",
"parentfield": "fields",
"parenttype": "DocType",
"permlevel": 0
},
{
"doctype": "DocType",
"name": "Material Request Item"
},
{
"allow_on_submit": 0,
"doctype": "DocField",
"fieldname": "schedule_date",
"fieldtype": "Date",
"label": "Required Date",
"no_copy": 1,
"oldfieldname": "schedule_date",
"oldfieldtype": "Date",
"print_hide": 0,
"reqd": 1,
"width": "100px"
},
{
"doctype": "DocField",
"fieldname": "item_code",
"fieldtype": "Link",
"in_filter": 1,
"label": "Item Code",
"oldfieldname": "item_code",
"oldfieldtype": "Link",
"options": "Item",
"reqd": 1,
"search_index": 1,
"width": "100px"
},
{
"doctype": "DocField",
"fieldname": "description",
"fieldtype": "Text",
"label": "Description",
"oldfieldname": "description",
"oldfieldtype": "Text",
"reqd": 1,
"width": "250px"
},
{
"doctype": "DocField",
"fieldname": "warehouse",
"fieldtype": "Link",
"label": "Warehouse",
"oldfieldname": "warehouse",
"oldfieldtype": "Link",
"options": "Warehouse",
"print_hide": 0,
"reqd": 0,
"width": "100px"
},
{
"default": "0.00",
"doctype": "DocField",
"fieldname": "qty",
"fieldtype": "Float",
"label": "Quantity",
"no_copy": 0,
"oldfieldname": "qty",
"oldfieldtype": "Currency",
"reqd": 1,
"width": "80px"
},
{
"doctype": "DocField",
"fieldname": "uom",
"fieldtype": "Link",
"label": "Stock UOM",
"no_copy": 0,
"oldfieldname": "uom",
"oldfieldtype": "Link",
"options": "UOM",
"read_only": 1,
"reqd": 1,
"width": "70px"
},
{
"doctype": "DocField",
"fieldname": "lead_time_date",
"fieldtype": "Date",
"label": "Lead Time Date",
"no_copy": 1,
"oldfieldname": "lead_time_date",
"oldfieldtype": "Date",
"print_hide": 1,
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "item_name",
"fieldtype": "Data",
"in_filter": 1,
"label": "Item Name",
"oldfieldname": "item_name",
"oldfieldtype": "Data",
"reqd": 1,
"search_index": 1,
"width": "100px"
},
{
"doctype": "DocField",
"fieldname": "item_group",
"fieldtype": "Link",
"in_filter": 1,
"label": "Item Group",
"no_copy": 0,
"oldfieldname": "item_group",
"oldfieldtype": "Link",
"options": "Item Group",
"print_hide": 1,
"read_only": 1,
"reqd": 0,
"search_index": 1
},
{
"doctype": "DocField",
"fieldname": "brand",
"fieldtype": "Link",
"label": "Brand",
"oldfieldname": "brand",
"oldfieldtype": "Link",
"options": "Brand",
"print_hide": 1,
"read_only": 1,
"width": "100px"
},
{
"doctype": "DocField",
"fieldname": "min_order_qty",
"fieldtype": "Float",
"label": "Min Order Qty",
"no_copy": 1,
"oldfieldname": "min_order_qty",
"oldfieldtype": "Currency",
"print_hide": 1,
"read_only": 1,
"reqd": 0,
"width": "70px"
},
{
"doctype": "DocField",
"fieldname": "projected_qty",
"fieldtype": "Float",
"label": "Projected Qty",
"no_copy": 1,
"oldfieldname": "projected_qty",
"oldfieldtype": "Currency",
"print_hide": 1,
"read_only": 1,
"width": "70px"
},
{
"doctype": "DocField",
"fieldname": "ordered_qty",
"fieldtype": "Float",
"label": "Ordered Qty",
"no_copy": 1,
"oldfieldname": "ordered_qty",
"oldfieldtype": "Currency",
"read_only": 1
},
{
"doctype": "DocField",
"fieldname": "sales_order_no",
"fieldtype": "Link",
"label": "Sales Order No",
"no_copy": 1,
"options": "Sales Order",
"print_hide": 1,
"read_only": 1
},
{
"allow_on_submit": 1,
"doctype": "DocField",
"fieldname": "page_break",
"fieldtype": "Check",
"label": "Page Break",
"no_copy": 1,
"oldfieldname": "page_break",
"oldfieldtype": "Check",
"print_hide": 1
}
]

View File

@@ -297,7 +297,7 @@ class DocType(BuyingController):
# 4.Update Bin
self.update_stock(is_submit = 0)
# 5.Update Purchase Requests Pending Qty and accordingly it's Status
# 5.Update Material Requests Pending Qty and accordingly it's Status
pc_obj.update_prevdoc_detail(self, is_submit = 0)
# 6. Update last purchase rate

View File

@@ -158,7 +158,7 @@ class DocType:
def repost_indented_qty(self, bin):
indented_qty = webnotes.conn.sql("""select sum(pr_item.qty - pr_item.ordered_qty)
from `tabPurchase Request Item` pr_item, `tabPurchase Request` pr
from `tabMaterial Request Item` pr_item, `tabMaterial Request` pr
where pr_item.item_code=%s and pr_item.warehouse=%s
and pr_item.qty > pr_item.ordered_qty and pr_item.parent=pr.name
and pr.status!='Stopped' and pr.docstatus=1"""

View File

@@ -40,7 +40,7 @@ erpnext.StockLevel = erpnext.StockGridReport.extend({
parent: $(wrapper).find('.layout-main'),
appframe: wrapper.appframe,
doctypes: ["Item", "Warehouse", "Stock Ledger Entry", "Production Order",
"Purchase Request Item", "Purchase Order Item", "Sales Order Item", "Brand"],
"Material Request Item", "Purchase Order Item", "Sales Order Item", "Brand"],
});
this.wrapper.bind("make", function() {
@@ -164,7 +164,7 @@ erpnext.StockLevel = erpnext.StockGridReport.extend({
$.each([
["Stock Ledger Entry", "actual_qty"],
["Production Order", "planned_qty"],
["Purchase Request Item", "requested_qty"],
["Material Request Item", "requested_qty"],
["Purchase Order Item", "ordered_qty"],
["Sales Order Item", "reserved_qty"]],
function(i, v) {