Mumtiple fixes
This commit is contained in:
parent
0dd8500393
commit
f79760ce2d
@ -928,7 +928,7 @@
|
|||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"print_hide_if_no_value": 0,
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 1,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
@ -996,7 +996,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2016-02-08 04:36:35.071206",
|
"modified": "2016-02-23 07:29:38.091748",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Production Order",
|
"name": "Production Order",
|
||||||
|
@ -155,16 +155,16 @@ class ProductionOrder(Document):
|
|||||||
|
|
||||||
frappe.db.set(self,'status', 'Submitted')
|
frappe.db.set(self,'status', 'Submitted')
|
||||||
self.make_time_logs()
|
self.make_time_logs()
|
||||||
self.update_planned_qty()
|
|
||||||
self.update_completed_qty_in_material_request()
|
self.update_completed_qty_in_material_request()
|
||||||
|
self.update_planned_qty()
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
self.validate_cancel()
|
self.validate_cancel()
|
||||||
|
|
||||||
frappe.db.set(self,'status', 'Cancelled')
|
frappe.db.set(self,'status', 'Cancelled')
|
||||||
self.delete_time_logs()
|
self.delete_time_logs()
|
||||||
self.update_planned_qty()
|
|
||||||
self.update_completed_qty_in_material_request()
|
self.update_completed_qty_in_material_request()
|
||||||
|
self.update_planned_qty()
|
||||||
|
|
||||||
def validate_cancel(self):
|
def validate_cancel(self):
|
||||||
if self.status == "Stopped":
|
if self.status == "Stopped":
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"fieldname": "material_request_date",
|
"fieldname": "material_request_date",
|
||||||
"fieldtype": "Read Only",
|
"fieldtype": "Date",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
@ -76,7 +76,7 @@
|
|||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"oldfieldname": "document_date",
|
"oldfieldname": "document_date",
|
||||||
"oldfieldtype": "Date",
|
"oldfieldtype": "Date",
|
||||||
"options": "material_request.transaction_date",
|
"options": "",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
@ -100,7 +100,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2016-02-11 04:21:34.372317",
|
"modified": "2016-02-23 02:06:15.169120",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Production Plan Material Request",
|
"name": "Production Plan Material Request",
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"fieldname": "sales_order_date",
|
"fieldname": "sales_order_date",
|
||||||
"fieldtype": "Read Only",
|
"fieldtype": "Date",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
@ -51,12 +51,12 @@
|
|||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"oldfieldname": "document_date",
|
"oldfieldname": "document_date",
|
||||||
"oldfieldtype": "Date",
|
"oldfieldtype": "Date",
|
||||||
"options": "sales_order.transaction_date",
|
"options": "",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"print_hide_if_no_value": 0,
|
"print_hide_if_no_value": 0,
|
||||||
"print_width": "120px",
|
"print_width": "120px",
|
||||||
"read_only": 0,
|
"read_only": 1,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
@ -92,7 +92,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"fieldname": "customer",
|
"fieldname": "customer",
|
||||||
"fieldtype": "Read Only",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
@ -100,7 +100,7 @@
|
|||||||
"label": "Customer",
|
"label": "Customer",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"options": "sales_order.customer",
|
"options": "Customer",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"print_hide_if_no_value": 0,
|
"print_hide_if_no_value": 0,
|
||||||
@ -119,7 +119,7 @@
|
|||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"default": "",
|
"default": "",
|
||||||
"fieldname": "grand_total",
|
"fieldname": "grand_total",
|
||||||
"fieldtype": "Read Only",
|
"fieldtype": "Currency",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
@ -127,7 +127,7 @@
|
|||||||
"label": "Grand Total",
|
"label": "Grand Total",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"options": "sales_order.base_grand_total",
|
"options": "",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"print_hide_if_no_value": 0,
|
"print_hide_if_no_value": 0,
|
||||||
@ -150,7 +150,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2016-02-11 04:17:42.849873",
|
"modified": "2016-02-23 02:13:07.340323",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Production Plan Sales Order",
|
"name": "Production Plan Sales Order",
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
frappe.require("assets/erpnext/js/utils.js");
|
frappe.require("assets/erpnext/js/utils.js");
|
||||||
|
|
||||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
cur_frm.cscript.onload = function(doc) {
|
||||||
cur_frm.set_value("company", frappe.defaults.get_user_default("Company"))
|
cur_frm.set_value("company", frappe.defaults.get_user_default("Company"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11,6 +11,58 @@ cur_frm.cscript.refresh = function(doc) {
|
|||||||
cur_frm.disable_save();
|
cur_frm.disable_save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cur_frm.add_fetch("material_request", "transaction_date", "material_request_date");
|
||||||
|
|
||||||
|
cur_frm.add_fetch("sales_order", "transaction_date", "sales_order_date");
|
||||||
|
cur_frm.add_fetch("sales_order", "customer", "customer");
|
||||||
|
cur_frm.add_fetch("sales_order", "base_grand_total", "grand_total");
|
||||||
|
|
||||||
|
frappe.ui.form.on("Production Planning Tool", {
|
||||||
|
get_sales_orders: function(frm) {
|
||||||
|
frappe.call({
|
||||||
|
doc: frm.doc,
|
||||||
|
method: "get_open_sales_orders",
|
||||||
|
callback: function(r) {
|
||||||
|
refresh_field("sales_orders");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
get_material_request: function(frm) {
|
||||||
|
frappe.call({
|
||||||
|
doc: frm.doc,
|
||||||
|
method: "get_pending_material_requests",
|
||||||
|
callback: function(r) {
|
||||||
|
refresh_field("material_requests");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
get_items: function(frm) {
|
||||||
|
frappe.call({
|
||||||
|
doc: frm.doc,
|
||||||
|
method: "get_items",
|
||||||
|
callback: function(r) {
|
||||||
|
refresh_field("items");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
create_production_order: function(frm) {
|
||||||
|
frappe.call({
|
||||||
|
doc: frm.doc,
|
||||||
|
method: "raise_production_orders"
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
create_material_requests: function(frm) {
|
||||||
|
frappe.call({
|
||||||
|
doc: frm.doc,
|
||||||
|
method: "raise_material_requests"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
cur_frm.cscript.item_code = function(doc,cdt,cdn) {
|
cur_frm.cscript.item_code = function(doc,cdt,cdn) {
|
||||||
var d = locals[cdt][cdn];
|
var d = locals[cdt][cdn];
|
||||||
if (d.item_code) {
|
if (d.item_code) {
|
||||||
@ -27,13 +79,6 @@ cur_frm.cscript.item_code = function(doc,cdt,cdn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.raise_purchase_request = function(doc, cdt, cdn) {
|
|
||||||
return frappe.call({
|
|
||||||
method: "raise_purchase_request",
|
|
||||||
doc:doc
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
cur_frm.cscript.download_materials_required = function(doc, cdt, cdn) {
|
cur_frm.cscript.download_materials_required = function(doc, cdt, cdn) {
|
||||||
return $c_obj(doc, 'validate_data', '', function(r, rt) {
|
return $c_obj(doc, 'validate_data', '', function(r, rt) {
|
||||||
if (!r['exc'])
|
if (!r['exc'])
|
||||||
@ -41,7 +86,6 @@ cur_frm.cscript.download_materials_required = function(doc, cdt, cdn) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cur_frm.fields_dict['sales_orders'].grid.get_field('sales_order').get_query = function(doc) {
|
cur_frm.fields_dict['sales_orders'].grid.get_field('sales_order').get_query = function(doc) {
|
||||||
var args = { "docstatus": 1 };
|
var args = { "docstatus": 1 };
|
||||||
if(doc.customer) {
|
if(doc.customer) {
|
||||||
|
@ -266,7 +266,7 @@
|
|||||||
"label": "Get Sales Orders",
|
"label": "Get Sales Orders",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"options": "get_open_sales_orders",
|
"options": "",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"print_hide_if_no_value": 0,
|
"print_hide_if_no_value": 0,
|
||||||
@ -339,7 +339,7 @@
|
|||||||
"label": "Get Material Request",
|
"label": "Get Material Request",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"options": "get_pending_material_requests",
|
"options": "",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
@ -413,7 +413,7 @@
|
|||||||
"label": "Get Items",
|
"label": "Get Items",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"options": "get_items",
|
"options": "",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"print_hide_if_no_value": 0,
|
"print_hide_if_no_value": 0,
|
||||||
@ -503,7 +503,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"description": "Separate production order will be created for each finished good item.",
|
"description": "Separate production order will be created for each finished good item.",
|
||||||
"fieldname": "raise_production_order",
|
"fieldname": "create_production_order",
|
||||||
"fieldtype": "Button",
|
"fieldtype": "Button",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
@ -512,7 +512,7 @@
|
|||||||
"label": "Create Production Orders",
|
"label": "Create Production Orders",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"options": "raise_production_orders",
|
"options": "",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"print_hide_if_no_value": 0,
|
"print_hide_if_no_value": 0,
|
||||||
@ -576,7 +576,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"description": "Items to be requested which are \"Out of Stock\" considering all warehouses based on projected qty and minimum order qty",
|
"description": "Items to be requested which are \"Out of Stock\" considering all warehouses based on projected qty and minimum order qty",
|
||||||
"fieldname": "raise_purchase_request",
|
"fieldname": "create_material_requests",
|
||||||
"fieldtype": "Button",
|
"fieldtype": "Button",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
@ -631,7 +631,7 @@
|
|||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2016-02-16 06:56:08.244906",
|
"modified": "2016-02-23 02:37:51.260645",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "Production Planning Tool",
|
"name": "Production Planning Tool",
|
||||||
|
@ -63,7 +63,7 @@ class ProductionPlanningTool(Document):
|
|||||||
""" Add sales orders in the table"""
|
""" Add sales orders in the table"""
|
||||||
self.clear_table("sales_orders")
|
self.clear_table("sales_orders")
|
||||||
|
|
||||||
so_list = [d.sales_order for d in self.get('sales_orders')]
|
so_list = []
|
||||||
for r in open_so:
|
for r in open_so:
|
||||||
if cstr(r['name']) not in so_list:
|
if cstr(r['name']) not in so_list:
|
||||||
pp_so = self.append('sales_orders', {})
|
pp_so = self.append('sales_orders', {})
|
||||||
@ -107,7 +107,7 @@ class ProductionPlanningTool(Document):
|
|||||||
""" Add Material Requests in the table"""
|
""" Add Material Requests in the table"""
|
||||||
self.clear_table("material_requests")
|
self.clear_table("material_requests")
|
||||||
|
|
||||||
mr_list = [d.material_request for d in self.get('material_requests')]
|
mr_list = []
|
||||||
for r in pending_mr:
|
for r in pending_mr:
|
||||||
if cstr(r['name']) not in mr_list:
|
if cstr(r['name']) not in mr_list:
|
||||||
mr = self.append('material_requests', {})
|
mr = self.append('material_requests', {})
|
||||||
@ -121,7 +121,7 @@ class ProductionPlanningTool(Document):
|
|||||||
self.get_mr_items()
|
self.get_mr_items()
|
||||||
|
|
||||||
def get_so_items(self):
|
def get_so_items(self):
|
||||||
so_list = filter(None, [d.sales_order for d in self.get('sales_orders')])
|
so_list = [d.sales_order for d in self.get('sales_orders') if d.sales_order]
|
||||||
if not so_list:
|
if not so_list:
|
||||||
msgprint(_("Please enter Sales Orders in the above table"))
|
msgprint(_("Please enter Sales Orders in the above table"))
|
||||||
return []
|
return []
|
||||||
@ -157,14 +157,14 @@ class ProductionPlanningTool(Document):
|
|||||||
self.add_items(items + packed_items)
|
self.add_items(items + packed_items)
|
||||||
|
|
||||||
def get_mr_items(self):
|
def get_mr_items(self):
|
||||||
mr_list = filter(None, [d.material_request for d in self.get('material_requests')])
|
mr_list = [d.material_request for d in self.get('material_requests') if d.material_request]
|
||||||
if not mr_list:
|
if not mr_list:
|
||||||
msgprint(_("Please enter Material Requests in the above table"))
|
msgprint(_("Please enter Material Requests in the above table"))
|
||||||
return []
|
return []
|
||||||
|
|
||||||
item_condition = ""
|
item_condition = ""
|
||||||
if self.fg_item:
|
if self.fg_item:
|
||||||
item_condition = ' and mr_item.item_code = "' + self.fg_item + '"'
|
item_condition = ' and mr_item.item_code = "' + frappe.db.escape(self.fg_item, percent=False) + '"'
|
||||||
|
|
||||||
items = frappe.db.sql("""select distinct parent, name, item_code, warehouse,
|
items = frappe.db.sql("""select distinct parent, name, item_code, warehouse,
|
||||||
(qty - ordered_qty) as pending_qty
|
(qty - ordered_qty) as pending_qty
|
||||||
@ -371,7 +371,7 @@ class ProductionPlanningTool(Document):
|
|||||||
|
|
||||||
return item_list
|
return item_list
|
||||||
|
|
||||||
def raise_purchase_request(self):
|
def raise_material_requests(self):
|
||||||
"""
|
"""
|
||||||
Raise Material Request if projected qty is less than qty required
|
Raise Material Request if projected qty is less than qty required
|
||||||
Requested qty should be shortage qty considering minimum order qty
|
Requested qty should be shortage qty considering minimum order qty
|
||||||
@ -384,7 +384,7 @@ class ProductionPlanningTool(Document):
|
|||||||
self.get_raw_materials(bom_dict)
|
self.get_raw_materials(bom_dict)
|
||||||
|
|
||||||
if self.item_dict:
|
if self.item_dict:
|
||||||
self.insert_purchase_request()
|
self.create_material_request()
|
||||||
|
|
||||||
def get_requested_items(self):
|
def get_requested_items(self):
|
||||||
item_projected_qty = self.get_projected_qty()
|
item_projected_qty = self.get_projected_qty()
|
||||||
@ -433,7 +433,7 @@ class ProductionPlanningTool(Document):
|
|||||||
|
|
||||||
return dict(item_projected_qty)
|
return dict(item_projected_qty)
|
||||||
|
|
||||||
def insert_purchase_request(self):
|
def create_material_request(self):
|
||||||
items_to_be_requested = self.get_requested_items()
|
items_to_be_requested = self.get_requested_items()
|
||||||
|
|
||||||
material_request_list = []
|
material_request_list = []
|
||||||
|
@ -6,6 +6,9 @@ import frappe
|
|||||||
from frappe.model.utils.rename_field import rename_field
|
from frappe.model.utils.rename_field import rename_field
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
frappe.reload_doc('Stock', 'doctype', 'material_request_item')
|
frappe.reload_doc('stock', 'doctype', 'material_request_item')
|
||||||
rename_field("Material Request Item", "sales_order", "sales_order")
|
rename_field("Material Request Item", "sales_order_no", "sales_order")
|
||||||
|
|
||||||
|
frappe.reload_doc('support', 'doctype', 'maintenance_schedule_item')
|
||||||
|
rename_field("Maintenance Schedule Item", "prevdoc_docname", "sales_order")
|
||||||
|
|
@ -193,7 +193,7 @@ class SalesOrder(SellingController):
|
|||||||
#check maintenance schedule
|
#check maintenance schedule
|
||||||
submit_ms = frappe.db.sql_list("""select t1.name from `tabMaintenance Schedule` t1,
|
submit_ms = frappe.db.sql_list("""select t1.name from `tabMaintenance Schedule` t1,
|
||||||
`tabMaintenance Schedule Item` t2
|
`tabMaintenance Schedule Item` t2
|
||||||
where t2.parent=t1.name and t2.prevdoc_docname = %s and t1.docstatus = 1""", self.name)
|
where t2.parent=t1.name and t2.sales_order = %s and t1.docstatus = 1""", self.name)
|
||||||
if submit_ms:
|
if submit_ms:
|
||||||
frappe.throw(_("Maintenance Schedule {0} must be cancelled before cancelling this Sales Order").format(comma_and(submit_ms)))
|
frappe.throw(_("Maintenance Schedule {0} must be cancelled before cancelling this Sales Order").format(comma_and(submit_ms)))
|
||||||
|
|
||||||
@ -464,15 +464,12 @@ def make_sales_invoice(source_name, target_doc=None, ignore_permissions=False):
|
|||||||
def make_maintenance_schedule(source_name, target_doc=None):
|
def make_maintenance_schedule(source_name, target_doc=None):
|
||||||
maint_schedule = frappe.db.sql("""select t1.name
|
maint_schedule = frappe.db.sql("""select t1.name
|
||||||
from `tabMaintenance Schedule` t1, `tabMaintenance Schedule Item` t2
|
from `tabMaintenance Schedule` t1, `tabMaintenance Schedule Item` t2
|
||||||
where t2.parent=t1.name and t2.prevdoc_docname=%s and t1.docstatus=1""", source_name)
|
where t2.parent=t1.name and t2.sales_order=%s and t1.docstatus=1""", source_name)
|
||||||
|
|
||||||
if not maint_schedule:
|
if not maint_schedule:
|
||||||
doclist = get_mapped_doc("Sales Order", source_name, {
|
doclist = get_mapped_doc("Sales Order", source_name, {
|
||||||
"Sales Order": {
|
"Sales Order": {
|
||||||
"doctype": "Maintenance Schedule",
|
"doctype": "Maintenance Schedule",
|
||||||
"field_map": {
|
|
||||||
"name": "sales_order"
|
|
||||||
},
|
|
||||||
"validation": {
|
"validation": {
|
||||||
"docstatus": ["=", 1]
|
"docstatus": ["=", 1]
|
||||||
}
|
}
|
||||||
@ -480,7 +477,7 @@ def make_maintenance_schedule(source_name, target_doc=None):
|
|||||||
"Sales Order Item": {
|
"Sales Order Item": {
|
||||||
"doctype": "Maintenance Schedule Item",
|
"doctype": "Maintenance Schedule Item",
|
||||||
"field_map": {
|
"field_map": {
|
||||||
"parent": "prevdoc_docname"
|
"parent": "sales_order"
|
||||||
},
|
},
|
||||||
"add_if_empty": True
|
"add_if_empty": True
|
||||||
}
|
}
|
||||||
@ -499,9 +496,6 @@ def make_maintenance_visit(source_name, target_doc=None):
|
|||||||
doclist = get_mapped_doc("Sales Order", source_name, {
|
doclist = get_mapped_doc("Sales Order", source_name, {
|
||||||
"Sales Order": {
|
"Sales Order": {
|
||||||
"doctype": "Maintenance Visit",
|
"doctype": "Maintenance Visit",
|
||||||
"field_map": {
|
|
||||||
"name": "sales_order"
|
|
||||||
},
|
|
||||||
"validation": {
|
"validation": {
|
||||||
"docstatus": ["=", 1]
|
"docstatus": ["=", 1]
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten
|
|||||||
frappe.call({
|
frappe.call({
|
||||||
method:"erpnext.stock.doctype.material_request.material_request.raise_production_orders",
|
method:"erpnext.stock.doctype.material_request.material_request.raise_production_orders",
|
||||||
args: {
|
args: {
|
||||||
"source_name": cur_frm.doc.name
|
"material_request": cur_frm.doc.name
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
from frappe.utils import cstr, flt, getdate, comma_and
|
from frappe.utils import cstr, flt, getdate, new_line_sep
|
||||||
from frappe import msgprint, _
|
from frappe import msgprint, _
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
from erpnext.stock.stock_balance import update_bin_qty, get_indented_qty
|
from erpnext.stock.stock_balance import update_bin_qty, get_indented_qty
|
||||||
@ -336,11 +336,11 @@ def make_stock_entry(source_name, target_doc=None):
|
|||||||
return doclist
|
return doclist
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def raise_production_orders(source_name):
|
def raise_production_orders(material_request):
|
||||||
material_request= frappe.get_doc("Material Request", source_name)
|
mr= frappe.get_doc("Material Request", material_request)
|
||||||
errors =[]
|
errors =[]
|
||||||
production_orders = []
|
production_orders = []
|
||||||
for d in material_request.items:
|
for d in mr.items:
|
||||||
if (d.qty - d.ordered_qty) >0 :
|
if (d.qty - d.ordered_qty) >0 :
|
||||||
if frappe.db.get_value("Item", d.item_code, "is_pro_applicable"):
|
if frappe.db.get_value("Item", d.item_code, "is_pro_applicable"):
|
||||||
prod_order = frappe.new_doc("Production Order")
|
prod_order = frappe.new_doc("Production Order")
|
||||||
@ -352,10 +352,10 @@ def raise_production_orders(source_name):
|
|||||||
prod_order.expected_delivery_date = d.schedule_date
|
prod_order.expected_delivery_date = d.schedule_date
|
||||||
prod_order.sales_order = d.sales_order
|
prod_order.sales_order = d.sales_order
|
||||||
prod_order.bom_no = get_item_details(d.item_code).bom_no
|
prod_order.bom_no = get_item_details(d.item_code).bom_no
|
||||||
prod_order.material_request = material_request.name
|
prod_order.material_request = mr.name
|
||||||
prod_order.material_request_item = d.name
|
prod_order.material_request_item = d.name
|
||||||
prod_order.planned_start_date = material_request.transaction_date
|
prod_order.planned_start_date = mr.transaction_date
|
||||||
prod_order.company = material_request.company
|
prod_order.company = mr.company
|
||||||
prod_order.save()
|
prod_order.save()
|
||||||
production_orders.append(prod_order.name)
|
production_orders.append(prod_order.name)
|
||||||
else:
|
else:
|
||||||
@ -363,7 +363,7 @@ def raise_production_orders(source_name):
|
|||||||
if production_orders:
|
if production_orders:
|
||||||
message = ["""<a href="#Form/Production Order/%s" target="_blank">%s</a>""" % \
|
message = ["""<a href="#Form/Production Order/%s" target="_blank">%s</a>""" % \
|
||||||
(p, p) for p in production_orders]
|
(p, p) for p in production_orders]
|
||||||
msgprint(_("Production Orders {0} created").format(comma_and(message)))
|
msgprint(_("The following Production Orders were created : \n {0} ").format(new_line_sep(message)))
|
||||||
if errors:
|
if errors:
|
||||||
msgprint(_("Could not Raise Production Orders for {0}").format(comma_and(errors)))
|
msgprint(_("Productions Orders cannot be raised for : \n {0}").format(new_line_sep(errors)))
|
||||||
return production_orders
|
return production_orders
|
@ -438,12 +438,14 @@ class TestMaterialRequest(unittest.TestCase):
|
|||||||
#testing bin requested qty after issuing stock against material request
|
#testing bin requested qty after issuing stock against material request
|
||||||
self.assertEquals(_get_requested_qty(), existing_requested_qty)
|
self.assertEquals(_get_requested_qty(), existing_requested_qty)
|
||||||
|
|
||||||
def test_completed_qty_for__manufacture(self):
|
def test_material_request_type_manufacture(self):
|
||||||
mr = frappe.copy_doc(test_records[1]).insert()
|
mr = frappe.copy_doc(test_records[1]).insert()
|
||||||
mr = frappe.get_doc("Material Request", mr.name)
|
mr = frappe.get_doc("Material Request", mr.name)
|
||||||
mr.submit()
|
mr.submit()
|
||||||
completed_qty = mr.items[0].ordered_qty
|
completed_qty = mr.items[0].ordered_qty
|
||||||
|
requested_qty = frappe.db.sql("""select indented_qty from `tabBin` where \
|
||||||
|
item_code= %s and warehouse= %s """, (mr.items[0].item_code, mr.items[0].warehouse))[0][0]
|
||||||
|
|
||||||
prod_order = raise_production_orders(mr.name)
|
prod_order = raise_production_orders(mr.name)
|
||||||
po = frappe.get_doc("Production Order", prod_order[0])
|
po = frappe.get_doc("Production Order", prod_order[0])
|
||||||
po.wip_warehouse = "_Test Warehouse 1 - _TC"
|
po.wip_warehouse = "_Test Warehouse 1 - _TC"
|
||||||
@ -451,11 +453,20 @@ class TestMaterialRequest(unittest.TestCase):
|
|||||||
|
|
||||||
mr = frappe.get_doc("Material Request", mr.name)
|
mr = frappe.get_doc("Material Request", mr.name)
|
||||||
self.assertEquals(completed_qty + po.qty, mr.items[0].ordered_qty)
|
self.assertEquals(completed_qty + po.qty, mr.items[0].ordered_qty)
|
||||||
|
|
||||||
|
new_requested_qty = frappe.db.sql("""select indented_qty from `tabBin` where \
|
||||||
|
item_code= %s and warehouse= %s """, (mr.items[0].item_code, mr.items[0].warehouse))[0][0]
|
||||||
|
|
||||||
|
self.assertEquals(requested_qty - po.qty, new_requested_qty)
|
||||||
|
|
||||||
po.cancel()
|
po.cancel()
|
||||||
|
|
||||||
mr = frappe.get_doc("Material Request", mr.name)
|
mr = frappe.get_doc("Material Request", mr.name)
|
||||||
self.assertEquals(completed_qty, mr.items[0].ordered_qty)
|
self.assertEquals(completed_qty, mr.items[0].ordered_qty)
|
||||||
|
|
||||||
|
new_requested_qty = frappe.db.sql("""select indented_qty from `tabBin` where \
|
||||||
|
item_code= %s and warehouse= %s """, (mr.items[0].item_code, mr.items[0].warehouse))[0][0]
|
||||||
|
self.assertEquals(requested_qty, new_requested_qty)
|
||||||
|
|
||||||
test_dependencies = ["Currency Exchange"]
|
test_dependencies = ["Currency Exchange"]
|
||||||
test_records = frappe.get_test_records('Material Request')
|
test_records = frappe.get_test_records('Material Request')
|
||||||
|
@ -158,12 +158,12 @@ class MaintenanceSchedule(TransactionBase):
|
|||||||
|
|
||||||
def validate_sales_order(self):
|
def validate_sales_order(self):
|
||||||
for d in self.get('items'):
|
for d in self.get('items'):
|
||||||
if d.prevdoc_docname:
|
if d.sales_order:
|
||||||
chk = frappe.db.sql("""select ms.name from `tabMaintenance Schedule` ms,
|
chk = frappe.db.sql("""select ms.name from `tabMaintenance Schedule` ms,
|
||||||
`tabMaintenance Schedule Item` msi where msi.parent=ms.name and
|
`tabMaintenance Schedule Item` msi where msi.parent=ms.name and
|
||||||
msi.prevdoc_docname=%s and ms.docstatus=1""", d.prevdoc_docname)
|
msi.sales_order=%s and ms.docstatus=1""", d.sales_order)
|
||||||
if chk:
|
if chk:
|
||||||
throw(_("Maintenance Schedule {0} exists against {0}").format(chk[0][0], d.prevdoc_docname))
|
throw(_("Maintenance Schedule {0} exists against {0}").format(chk[0][0], d.sales_order))
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_maintenance_detail()
|
self.validate_maintenance_detail()
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
"options": "Item",
|
"options": "Item",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
@ -50,6 +51,7 @@
|
|||||||
"oldfieldtype": "Data",
|
"oldfieldtype": "Data",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -74,6 +76,7 @@
|
|||||||
"oldfieldtype": "Data",
|
"oldfieldtype": "Data",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"print_width": "300px",
|
"print_width": "300px",
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
@ -98,6 +101,7 @@
|
|||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -122,6 +126,7 @@
|
|||||||
"oldfieldtype": "Date",
|
"oldfieldtype": "Date",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
@ -146,6 +151,7 @@
|
|||||||
"oldfieldtype": "Date",
|
"oldfieldtype": "Date",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
@ -171,6 +177,7 @@
|
|||||||
"options": "\nWeekly\nMonthly\nQuarterly\nHalf Yearly\nYearly\nRandom",
|
"options": "\nWeekly\nMonthly\nQuarterly\nHalf Yearly\nYearly\nRandom",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -195,6 +202,7 @@
|
|||||||
"oldfieldtype": "Int",
|
"oldfieldtype": "Int",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
@ -220,6 +228,7 @@
|
|||||||
"options": "Sales Person",
|
"options": "Sales Person",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
@ -242,6 +251,7 @@
|
|||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -266,6 +276,7 @@
|
|||||||
"oldfieldtype": "Small Text",
|
"oldfieldtype": "Small Text",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
@ -277,19 +288,21 @@
|
|||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"fieldname": "prevdoc_docname",
|
"fieldname": "sales_order",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"in_filter": 1,
|
"in_filter": 1,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"label": "Against Docname",
|
"label": "Sales Order",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"oldfieldname": "prevdoc_docname",
|
"oldfieldname": "prevdoc_docname",
|
||||||
"oldfieldtype": "Data",
|
"oldfieldtype": "Data",
|
||||||
|
"options": "Sales Order",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
"print_width": "150px",
|
"print_width": "150px",
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
@ -309,7 +322,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2015-11-16 06:29:49.903875",
|
"modified": "2016-02-23 04:59:32.924534",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Support",
|
"module": "Support",
|
||||||
"name": "Maintenance Schedule Item",
|
"name": "Maintenance Schedule Item",
|
||||||
|
Loading…
Reference in New Issue
Block a user