[bom] [production] Cleaned up BOM, Production Planning Tool, Progress in Demo Builder

This commit is contained in:
Rushabh Mehta
2013-08-07 17:46:35 +05:30
parent 0cb97f3627
commit 7cfefbced5
10 changed files with 208 additions and 160 deletions

View File

@@ -118,6 +118,11 @@ class DocType:
rate = self.get_valuation_rate(arg)
elif self.doc.rm_cost_as_per == 'Last Purchase Rate':
rate = arg['last_purchase_rate']
elif self.doc.rm_cost_as_per == "Price List":
if not self.doc.price_list:
webnotes.throw(_("Please select Price List"))
rate = webnotes.conn.get_value("Item Price", {"price_list_name": self.doc.price_list,
"parent": arg["item_code"]}, "ref_rate") or 0
elif self.doc.rm_cost_as_per == 'Standard Rate':
rate = arg['standard_rate']
@@ -180,7 +185,7 @@ class DocType:
webnotes.conn.set(self.doc, "is_default", 0)
sql("update `tabItem` set default_bom = null where name = %s and default_bom = %s",
(self.doc.item, self.doc.name))
(self.doc.item, self.doc.name))
def clear_operations(self):
if not self.doc.with_operations:

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-01-22 15:11:38",
"docstatus": 0,
"modified": "2013-07-22 15:28:38",
"modified": "2013-08-07 17:09:46",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -66,11 +66,6 @@
"reqd": 1,
"search_index": 1
},
{
"doctype": "DocField",
"fieldname": "cb0",
"fieldtype": "Column Break"
},
{
"allow_on_submit": 1,
"default": "1",
@@ -87,6 +82,7 @@
},
{
"allow_on_submit": 1,
"default": "1",
"doctype": "DocField",
"fieldname": "is_default",
"fieldtype": "Check",
@@ -96,6 +92,11 @@
"oldfieldname": "is_default",
"oldfieldtype": "Check"
},
{
"doctype": "DocField",
"fieldname": "cb0",
"fieldtype": "Column Break"
},
{
"description": "Manage cost of operations",
"doctype": "DocField",
@@ -103,6 +104,22 @@
"fieldtype": "Check",
"label": "With Operations"
},
{
"doctype": "DocField",
"fieldname": "rm_cost_as_per",
"fieldtype": "Select",
"label": "Rate Of Materials Based On",
"options": "Valuation Rate\nLast Purchase Rate\nPrice List"
},
{
"depends_on": "eval:doc.rm_cost_as_per===\"Price List\"",
"description": "Price List for Costing",
"doctype": "DocField",
"fieldname": "price_list",
"fieldtype": "Link",
"label": "Price List",
"options": "Price List"
},
{
"depends_on": "with_operations",
"doctype": "DocField",
@@ -145,13 +162,6 @@
"label": "Costing",
"oldfieldtype": "Section Break"
},
{
"doctype": "DocField",
"fieldname": "rm_cost_as_per",
"fieldtype": "Select",
"label": "Rate Of Materials Based On",
"options": "Valuation Rate\nLast Purchase Rate"
},
{
"doctype": "DocField",
"fieldname": "total_cost",

View File

@@ -2,8 +2,8 @@
// License: GNU General Public License v3. See license.txt
cur_frm.cscript.onload = function(doc, cdt, cdn) {
doc.company = wn.defaults.get_default("company");
refresh_field("company");
cur_frm.set_value("company", wn.defaults.get_default("company"))
cur_frm.set_value("use_multi_level_bom", 1)
}
cur_frm.cscript.refresh = function(doc) {

View File

@@ -148,6 +148,7 @@ class DocType:
def validate_data(self):
self.validate_company()
for d in getlist(self.doclist, 'pp_details'):
self.validate_bom_no(d)
if not flt(d.planned_qty):
@@ -169,7 +170,6 @@ class DocType:
def raise_production_order(self):
"""It will raise production order (Draft) for all distinct FG items"""
self.validate_company()
self.validate_data()
from utilities.transaction_base import validate_uom_is_integer
@@ -180,15 +180,15 @@ class DocType:
if pro:
pro = ["""<a href="#Form/Production Order/%s" target="_blank">%s</a>""" % \
(p, p) for p in pro]
msgprint("Following Production Order has been generated:\n" + '\n'.join(pro))
msgprint("Production Order(s) created:\n\n" + '\n'.join(pro))
else :
msgprint("No Production Order generated.")
msgprint("No Production Order created.")
def get_distinct_items_and_boms(self):
""" Club similar BOM and item for processing"""
item_dict, bom_dict = {}, {}
for d in self.doclist.get({"parentfield": "pp_details"}):
for d in self.doclist.get({"parentfield": "pp_details"}):
bom_dict[d.bom_no] = bom_dict.get(d.bom_no, 0) + flt(d.planned_qty)
item_dict[(d.item_code, d.sales_order)] = {
"qty" : flt(item_dict.get((d.item_code, d.sales_order), \
@@ -223,6 +223,7 @@ class DocType:
def download_raw_materials(self):
""" Create csv data for required raw material to produce finished goods"""
self.validate_data()
bom_dict = self.get_distinct_items_and_boms()[0]
self.get_raw_materials(bom_dict)
return self.get_csv()
@@ -283,6 +284,7 @@ class DocType:
Raise Material Request if projected qty is less than qty required
Requested qty should be shortage qty considering minimum order qty
"""
self.validate_data()
if not self.doc.purchase_request_for_warehouse:
webnotes.msgprint("Please enter Warehouse for which Material Request will be raised",
raise_exception=1)
@@ -308,6 +310,7 @@ class DocType:
def get_projected_qty(self):
items = self.item_dict.keys()
item_projected_qty = webnotes.conn.sql("""select item_code, sum(projected_qty)
from `tabBin` where item_code in (%s) group by item_code""" %
(", ".join(["%s"]*len(items)),), tuple(items))
@@ -355,7 +358,7 @@ class DocType:
if purchase_request_list:
pur_req = ["""<a href="#Form/Material Request/%s" target="_blank">%s</a>""" % \
(p, p) for p in purchase_request_list]
webnotes.msgprint("Following Material Request created successfully: \n%s" %
webnotes.msgprint("Material Request(s) created: \n%s" %
"\n".join(pur_req))
else:
webnotes.msgprint("Nothing to request")

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-01-21 12:03:47",
"docstatus": 0,
"modified": "2013-07-22 15:26:45",
"modified": "2013-08-07 17:21:19",
"modified_by": "Administrator",
"owner": "jai@webnotestech.com"
},
@@ -118,46 +118,17 @@
},
{
"doctype": "DocField",
"fieldname": "clear_so_table",
"fieldtype": "Button",
"label": "Clear Table",
"options": "clear_so_table"
},
{
"description": "Enter items and planned qty for which you want to raise production orders or download raw materials for analysis.",
"doctype": "DocField",
"fieldname": "create_production_orders",
"fieldname": "items_for_production",
"fieldtype": "Section Break",
"label": "Create Production Orders"
"label": "Select Items"
},
{
"description": "Pull items from Sales Order mentioned in the above table.",
"doctype": "DocField",
"fieldname": "get_items_from_so",
"fieldtype": "Button",
"label": "Get Items",
"label": "Get Items From Sales Orders",
"options": "get_items_from_so"
},
{
"doctype": "DocField",
"fieldname": "pp_details",
"fieldtype": "Table",
"label": "Production Plan Items",
"options": "Production Plan Item"
},
{
"doctype": "DocField",
"fieldname": "clear_item_table",
"fieldtype": "Button",
"label": "Clear Table",
"options": "clear_item_table"
},
{
"doctype": "DocField",
"fieldname": "section_break3",
"fieldtype": "Section Break",
"options": "Simple"
},
{
"default": "1",
"description": "If checked, BOM for sub-assembly items will be considered for getting raw materials. Otherwise, all sub-assembly items will be treated as a raw material.",
@@ -169,36 +140,31 @@
},
{
"doctype": "DocField",
"fieldname": "cb5",
"fieldtype": "Column Break",
"width": "50%"
"fieldname": "pp_details",
"fieldtype": "Table",
"label": "Production Plan Items",
"options": "Production Plan Item"
},
{
"description": "Enter items and planned qty for which you want to raise production orders or download raw materials for analysis.",
"doctype": "DocField",
"fieldname": "create_production_orders",
"fieldtype": "Section Break",
"label": "Production Orders"
},
{
"description": "Separate production order will be created for each finished good item.",
"doctype": "DocField",
"fieldname": "raise_production_order",
"fieldtype": "Button",
"label": "Raise Production Order",
"label": "Create Production Orders",
"options": "raise_production_order"
},
{
"doctype": "DocField",
"fieldname": "sb5",
"fieldtype": "Section Break",
"label": "Materials Requirement Planning (MRP)"
},
{
"description": "Download a report containing all raw materials with their latest inventory status",
"doctype": "DocField",
"fieldname": "download_materials_required",
"fieldtype": "Button",
"label": "Download Materials Required"
},
{
"doctype": "DocField",
"fieldname": "column_break6",
"fieldtype": "Column Break",
"width": "50%"
"label": "Material Requirement"
},
{
"doctype": "DocField",
@@ -212,9 +178,16 @@
"doctype": "DocField",
"fieldname": "raise_purchase_request",
"fieldtype": "Button",
"label": "Raise Material Request",
"label": "Create Material Requests",
"options": "raise_purchase_request"
},
{
"description": "Download a report containing all raw materials with their latest inventory status",
"doctype": "DocField",
"fieldname": "download_materials_required",
"fieldtype": "Button",
"label": "Download Materials Required"
},
{
"doctype": "DocPerm"
}