mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 04:09:11 +00:00
Sourced wnframework-modules from Google Code as erpnext
This commit is contained in:
519
production/Module Def/Production/Production.txt
Normal file
519
production/Module Def/Production/Production.txt
Normal file
@@ -0,0 +1,519 @@
|
||||
[
|
||||
{
|
||||
'_last_update': '1300959287',
|
||||
'creation': '2010-11-30 22:42:49',
|
||||
'disabled': 'No',
|
||||
'docstatus': 0,
|
||||
'doctype': u'Module Def',
|
||||
'doctype_list': None,
|
||||
'file_list': 'support.gif,FileData/00214',
|
||||
'idx': None,
|
||||
'is_hidden': 'No',
|
||||
'last_updated_date': '2010-11-29 12:02:02',
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'module_desc': '<p>Production Documents</p>',
|
||||
'module_icon': 'process.png',
|
||||
'module_label': 'Production',
|
||||
'module_name': 'Production',
|
||||
'module_page': None,
|
||||
'module_seq': 7,
|
||||
'name': 'Production',
|
||||
'owner': 'Administrator',
|
||||
'parent': None,
|
||||
'parentfield': None,
|
||||
'parenttype': None,
|
||||
'trash_reason': None,
|
||||
'widget_code': None
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2010-11-30 22:42:49',
|
||||
'description': 'Bill of material master containing raw materials, operation and costs',
|
||||
'display_name': 'Bill Of Materials',
|
||||
'doc_name': 'Bill Of Materials',
|
||||
'doc_type': 'Forms',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': 'id\nitem\ndescription\noperating_cost\nmaintained_by',
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': 1,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDI00209',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2010-11-30 22:42:49',
|
||||
'description': 'Machinery in warehouse where operations are performed on raw materials',
|
||||
'display_name': 'Workstation',
|
||||
'doc_name': 'Workstation',
|
||||
'doc_type': 'Forms',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': 'id\nworkstation_name\nwarehouse\ndescription',
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': 2,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDI00210',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2010-11-30 22:42:49',
|
||||
'description': 'Explode Bill of Materials in a tree and calculate the cost',
|
||||
'display_name': 'Bill of Materials (Tree)',
|
||||
'doc_name': 'Bill of Materials',
|
||||
'doc_type': 'Pages',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': 3,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDI00211',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2010-11-30 22:42:49',
|
||||
'description': 'Update confirmed delivery dates in Sales Orders included in Production Plan',
|
||||
'display_name': 'Update Delivery Dates',
|
||||
'doc_name': 'Update Delivery Date',
|
||||
'doc_type': 'Single DocType',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': 4,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDI00212',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2010-11-30 22:42:49',
|
||||
'description': 'Plan your production by including relevant Sales Orders in your plan',
|
||||
'display_name': 'Production Planning Tool',
|
||||
'doc_name': 'Production Planning Tool',
|
||||
'doc_type': 'Single DocType',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': 5,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDI00213',
|
||||
'owner': 'saumil@webnotestech.com',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2010-11-30 22:42:49',
|
||||
'description': 'Change raw materials used in a Bill of Material through BOM replace utility',
|
||||
'display_name': 'BOM Replace Utility',
|
||||
'doc_name': 'BOM Replace Utility',
|
||||
'doc_type': 'Single DocType',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': 6,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDI00214',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2010-11-30 22:42:49',
|
||||
'description': 'Raise your Production Orders Manually',
|
||||
'display_name': 'Production Order',
|
||||
'doc_name': 'Production Order',
|
||||
'doc_type': 'Forms',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': 7,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDI00215',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2011-03-24 15:04:47',
|
||||
'description': None,
|
||||
'display_name': None,
|
||||
'doc_name': 'Reports',
|
||||
'doc_type': 'Separator',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': 8,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': '000003093',
|
||||
'owner': 'saumil@webnotestech.com',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2011-03-24 15:04:47',
|
||||
'description': None,
|
||||
'display_name': 'Delivery Plan',
|
||||
'doc_name': 'Sales Order Detail',
|
||||
'doc_type': 'Reports',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': 9,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': '000003094',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2011-03-24 15:04:47',
|
||||
'description': None,
|
||||
'display_name': 'Itemwise Production Report',
|
||||
'doc_name': 'Stock Entry Detail',
|
||||
'doc_type': 'Reports',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': 10,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': '000003095',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2011-03-24 15:04:47',
|
||||
'description': None,
|
||||
'display_name': 'Production Orders In Process',
|
||||
'doc_name': 'Production Order',
|
||||
'doc_type': 'Reports',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': 11,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': '000003096',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2010-11-30 22:42:49',
|
||||
'description': 'Bill of material master containing raw materials, operation and costs',
|
||||
'display_name': 'Bill Of Materials',
|
||||
'doc_name': 'Bill Of Materials',
|
||||
'doc_type': 'Forms',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': 'id\nitem\ndescription\noperating_cost\nmaintained_by',
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': 1,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDI00209',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2010-11-30 22:42:49',
|
||||
'description': 'Machinery in warehouse where operations are performed on raw materials',
|
||||
'display_name': 'Workstation',
|
||||
'doc_name': 'Workstation',
|
||||
'doc_type': 'Forms',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': 'id\nworkstation_name\nwarehouse\ndescription',
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': 2,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDI00210',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2010-11-30 22:42:49',
|
||||
'description': 'Explode Bill of Materials in a tree and calculate the cost',
|
||||
'display_name': 'Bill of Materials (Tree)',
|
||||
'doc_name': 'Bill of Materials',
|
||||
'doc_type': 'Pages',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': 3,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDI00211',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2010-11-30 22:42:49',
|
||||
'description': 'Update confirmed delivery dates in Sales Orders included in Production Plan',
|
||||
'display_name': 'Update Delivery Dates',
|
||||
'doc_name': 'Update Delivery Date',
|
||||
'doc_type': 'Single DocType',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': 4,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDI00212',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2010-11-30 22:42:49',
|
||||
'description': 'Plan your production by including relevant Sales Orders in your plan',
|
||||
'display_name': 'Production Planning Tool',
|
||||
'doc_name': 'Production Planning Tool',
|
||||
'doc_type': 'Single DocType',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': 5,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDI00213',
|
||||
'owner': 'saumil@webnotestech.com',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2010-11-30 22:42:49',
|
||||
'description': 'Change raw materials used in a Bill of Material through BOM replace utility',
|
||||
'display_name': 'BOM Replace Utility',
|
||||
'doc_name': 'BOM Replace Utility',
|
||||
'doc_type': 'Single DocType',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': 6,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDI00214',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2010-11-30 22:42:49',
|
||||
'description': 'Raise your Production Orders Manually',
|
||||
'display_name': 'Production Order',
|
||||
'doc_name': 'Production Order',
|
||||
'doc_type': 'Forms',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': 7,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDI00215',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2011-03-24 15:04:47',
|
||||
'description': None,
|
||||
'display_name': None,
|
||||
'doc_name': 'Reports',
|
||||
'doc_type': 'Separator',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': 8,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': '000003093',
|
||||
'owner': 'saumil@webnotestech.com',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2011-03-24 15:04:47',
|
||||
'description': None,
|
||||
'display_name': 'Delivery Plan',
|
||||
'doc_name': 'Sales Order Detail',
|
||||
'doc_type': 'Reports',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': 9,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': '000003094',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2011-03-24 15:04:47',
|
||||
'description': None,
|
||||
'display_name': 'Itemwise Production Report',
|
||||
'doc_name': 'Stock Entry Detail',
|
||||
'doc_type': 'Reports',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': 10,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': '000003095',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'click_function': None,
|
||||
'creation': '2011-03-24 15:04:47',
|
||||
'description': None,
|
||||
'display_name': 'Production Orders In Process',
|
||||
'doc_name': 'Production Order',
|
||||
'doc_type': 'Reports',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Item',
|
||||
'fields': None,
|
||||
'hide': None,
|
||||
'icon': None,
|
||||
'idx': 11,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': '000003096',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'items',
|
||||
'parenttype': 'Module Def'
|
||||
},
|
||||
{
|
||||
'creation': '2010-11-30 22:42:49',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Role',
|
||||
'idx': 1,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDR00040',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'roles',
|
||||
'parenttype': 'Module Def',
|
||||
'role': 'Production User'
|
||||
},
|
||||
{
|
||||
'creation': '2010-11-30 22:42:49',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Module Def Role',
|
||||
'idx': 2,
|
||||
'modified': '2011-03-24 15:29:36',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'MDR00041',
|
||||
'owner': 'Administrator',
|
||||
'parent': 'Production',
|
||||
'parentfield': 'roles',
|
||||
'parenttype': 'Module Def',
|
||||
'role': 'Production Manager'
|
||||
}
|
||||
]
|
||||
0
production/__init__.py
Normal file
0
production/__init__.py
Normal file
0
production/doctype/__init__.py
Normal file
0
production/doctype/__init__.py
Normal file
0
production/doctype/bill_of_materials/__init__.py
Normal file
0
production/doctype/bill_of_materials/__init__.py
Normal file
103
production/doctype/bill_of_materials/bill_of_materials.js
Normal file
103
production/doctype/bill_of_materials/bill_of_materials.js
Normal file
@@ -0,0 +1,103 @@
|
||||
$import(Production Tips Common)
|
||||
|
||||
// ONLOAD
|
||||
cur_frm.cscript.onload = function(doc,cdt,cdn){
|
||||
|
||||
cur_frm.cscript.get_tips(doc, cdt, cdn);
|
||||
}
|
||||
|
||||
// On REFRESH
|
||||
cur_frm.cscript.refresh = function(doc,cdt,cdn){
|
||||
|
||||
cur_frm.cscript.get_tips(doc, cdt, cdn);
|
||||
|
||||
// Hide - Un Hide Buttons
|
||||
if (!doc.is_default && doc.__islocal!=1) unhide_field('Set as Default BOM');
|
||||
else hide_field('Set as Default BOM');
|
||||
|
||||
if(doc.__islocal!=1){
|
||||
set_field_permlevel('item',1);
|
||||
}
|
||||
if (flt(doc.docstatus) == 1){
|
||||
if (doc.is_active == 'Yes') { unhide_field('Inactivate BOM'); hide_field('Activate BOM');}
|
||||
else { hide_field('Inactivate BOM'); unhide_field('Activate BOM');}
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['item'].get_query = function(doc) {
|
||||
return 'SELECT DISTINCT `tabItem`.`name`, `tabItem`.description FROM `tabItem` WHERE (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` = "0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND `tabItem`.`%(key)s` like "%s" ORDER BY `tabItem`.`name` LIMIT 50';
|
||||
}
|
||||
|
||||
// ---------------------- Get project name --------------------------
|
||||
cur_frm.fields_dict['project_name'].get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT `tabProject`.name FROM `tabProject` WHERE `tabProject`.status = "Open" AND `tabProject`.name LIKE "%s" ORDER BY `tabProject`.name ASC LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['bom_materials'].grid.get_field('item_code').get_query = function(doc) {
|
||||
return 'SELECT DISTINCT `tabItem`.`name`, `tabItem`.description FROM `tabItem` WHERE (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` = "0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND `tabItem`.`%(key)s` like "%s" ORDER BY `tabItem`.`name` LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['bom_materials'].grid.get_field('bom_no').get_query = function(doc) {
|
||||
var d = locals[this.doctype][this.docname];
|
||||
return 'SELECT DISTINCT `tabBill Of Materials`.`name`, `tabBill Of Materials`.`remarks` FROM `tabBill Of Materials` WHERE `tabBill Of Materials`.`item` = "' + d.item_code + '" AND `tabBill Of Materials`.`name` like "%s" ORDER BY `tabBill Of Materials`.`name` LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.cscript.item = function(doc, cdt, cdn) {
|
||||
if (doc.item) {
|
||||
get_server_fields('get_item_detail',doc.item,'',doc,cdt,cdn,1);
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.workstation = function(doc,cdt,cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
if (d.workstation) {
|
||||
get_server_fields('get_workstation_details',d.workstation,'bom_operations',doc,cdt,cdn,1);
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.item_code =function(doc,cdt,cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
if (d.item_code) {
|
||||
arg = "{'item_code' : '" + d.item_code + "', 'bom_no' : ''}";
|
||||
get_server_fields('get_bom_material_detail',arg,'bom_materials',doc,cdt,cdn,1);
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.bom_no = function(doc,cdt,cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
if (d.item_code && d.bom_no) {
|
||||
arg = "{'item_code' : '" + d.item_code + "', 'bom_no' : '" + d.bom_no + "'}";
|
||||
get_server_fields('get_bom_material_detail',arg,'bom_materials',doc,cdt,cdn,1);
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript['Set as Default BOM'] = function(doc,cdt,cdn) {
|
||||
var check = confirm("Do you Really want to Set BOM " + doc.name + " as default for Item " + doc.item);
|
||||
if (check) {
|
||||
$c('runserverobj', args={'method':'set_as_default_bom', 'docs': compress_doclist([doc])}, function(r,rt) {
|
||||
refresh_field('is_default');
|
||||
hide_field('Set as Default BOM');
|
||||
refresh_field('Set as Default BOM');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript['Activate BOM'] = function(doc,cdt,cdn) {
|
||||
var check = confirm("DO YOU REALLY WANT TO ACTIVATE BOM : " + doc.name);
|
||||
|
||||
if (check) {
|
||||
$c('runserverobj', args={'method':'activate_inactivate_bom', 'arg': 'Activate', 'docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
|
||||
cur_frm.refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript['Inactivate BOM'] = function(doc,cdt,cdn) {
|
||||
var check = confirm("DO YOU REALLY WANT TO INACTIVATE BOM : " + doc.name);
|
||||
|
||||
if (check) {
|
||||
$c('runserverobj', args={'method':'activate_inactivate_bom', 'arg': 'Inactivate', 'docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
|
||||
cur_frm.refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
541
production/doctype/bill_of_materials/bill_of_materials.py
Normal file
541
production/doctype/bill_of_materials/bill_of_materials.py
Normal file
@@ -0,0 +1,541 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
def autoname(self):
|
||||
last_name = sql("select max(name) from `tabBill Of Materials` where name like 'BOM/%s/%%'" % self.doc.item)
|
||||
if last_name:
|
||||
idx = cint(cstr(last_name[0][0]).split('/')[-1]) + 1
|
||||
else:
|
||||
idx = 1
|
||||
self.doc.name = 'BOM/' + self.doc.item + ('/%.3i' % idx)
|
||||
|
||||
#----------- Client Trigger function ----------
|
||||
def get_item_detail(self, item_code):
|
||||
item = sql("select description from `tabItem` where (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now()) and name = %s",item_code , as_dict =1)
|
||||
ret={
|
||||
'description' : item and item[0]['description'] or ''
|
||||
}
|
||||
return cstr(ret)
|
||||
|
||||
def get_workstation_details(self,workstation):
|
||||
ws = sql("select hour_rate, capacity from `tabWorkstation` where name = %s",workstation , as_dict = 1)
|
||||
ret = {
|
||||
'hour_rate' : ws and flt(ws[0]['hour_rate']) or '',
|
||||
'workstation_capacity' : ws and flt(ws[0]['capacity']) or ''
|
||||
}
|
||||
return cstr(ret)
|
||||
|
||||
def get_bom_material_detail(self, arg):
|
||||
arg = eval(arg)
|
||||
if arg['item_code'] and arg['item_code'] == self.doc.item:
|
||||
msgprint(" Item_code: "+arg['item_code']+" in materials tab cannot be same as main Item in BOM := " +cstr(self.doc.name))
|
||||
raise Exception
|
||||
if arg['item_code']:
|
||||
item = sql("select is_asset_item, is_purchase_item, docstatus, is_sub_contracted_item, description, stock_uom, default_bom from `tabItem` where item_code = %s", (arg['item_code']), as_dict = 1)
|
||||
|
||||
# Check for Asset Item
|
||||
if item and item[0]['is_asset_item'] == 'Yes':
|
||||
msgprint("Sorry!!! Item " + arg['item_code'] + " is an Asset of the company. Entered in BOM := " + cstr(self.doc.name))
|
||||
raise Exception
|
||||
|
||||
if item and item[0]['docstatus'] == 2:
|
||||
msgprint("Item %s does not exist in system" % cstr(args['item_code']))
|
||||
|
||||
ret_item = {
|
||||
'description' : item and item[0]['description'] or '',
|
||||
'stock_uom' : item and item[0]['stock_uom'] or '',
|
||||
'bom_no' : item and item[0]['default_bom'] or ''
|
||||
}
|
||||
|
||||
# Check for Purchase Item
|
||||
if item and (item[0]['is_purchase_item'] == 'Yes' or item[0]['is_sub_contracted_item'] == 'Yes'):
|
||||
ret_item['moving_avg_rate'], ret_item['last_purchase_rate'], ret_item['standard_rate'] = self.get_mar_lpr_sr(arg['item_code'], mar = 1, lpr = 1, sr = 1)
|
||||
ret_item['operating_cost'], ret_item['dir_mat_as_per_mar'], ret_item['dir_mat_as_per_lpr'], ret_item['dir_mat_as_per_sr'] = 0, 0, 0, 0
|
||||
ret_item['value_as_per_mar'], ret_item['value_as_per_lpr'], ret_item['value_as_per_sr'] = 0, 0, 0
|
||||
ret_item['amount_as_per_mar'], ret_item['amount_as_per_lpr'], ret_item['amount_as_per_sr'] = 0, 0, 0
|
||||
|
||||
if arg['bom_no'] or not ret_item['bom_no'] =='':
|
||||
if arg['bom_no']:
|
||||
bom = sql("select name, dir_mat_as_per_mar,dir_mat_as_per_lpr,dir_mat_as_per_sr, operating_cost, quantity from `tabBill Of Materials` where is_active = 'Yes' and name = %s", (arg['bom_no']), as_dict=1)
|
||||
else:
|
||||
# get recent direct material cost, operating_cost, cost from Default BOM of Item
|
||||
bom = sql("select name, dir_mat_as_per_mar, dir_mat_as_per_lpr, dir_mat_as_per_sr, operating_cost, quantity from `tabBill Of Materials` where is_active = 'Yes' and name = %s", (ret_item['bom_no']), as_dict=1)
|
||||
|
||||
# get recent direct material cost, operating_cost, cost from Entered BOM of Item
|
||||
ret_item['bom_no'] = bom and bom[0]['name'] or ''
|
||||
|
||||
if bom and bom[0]['name']:
|
||||
ret_bom = {
|
||||
'dir_mat_as_per_mar' : flt(bom[0]['dir_mat_as_per_mar']) / flt(bom[0]['quantity']) or 0.00,
|
||||
'dir_mat_as_per_lpr' : flt(bom[0]['dir_mat_as_per_lpr']) / flt(bom[0]['quantity']) or 0.00,
|
||||
'dir_mat_as_per_sr' : flt(bom[0]['dir_mat_as_per_sr']) / flt(bom[0]['quantity']) or 0.00,
|
||||
'operating_cost' : flt(bom[0]['operating_cost']) / flt(bom[0]['quantity']) or 0.00,
|
||||
'value_as_per_mar' : ((flt(bom[0]['dir_mat_as_per_mar']) + flt(bom[0]['operating_cost'])) / flt(bom[0]['quantity'])) or 0.00,
|
||||
'value_as_per_lpr' : ((flt(bom[0]['dir_mat_as_per_lpr']) + flt(bom[0]['operating_cost'])) / flt(bom[0]['quantity'])) or 0.00,
|
||||
'value_as_per_sr' : ((flt(bom[0]['dir_mat_as_per_sr']) + flt(bom[0]['operating_cost'])) / flt(bom[0]['quantity'])) or 0.00,
|
||||
'amount_as_per_mar' : 0,
|
||||
'amount_as_per_lpr' : 0,
|
||||
'amount_as_per_sr' : 0
|
||||
}
|
||||
ret_item.update(ret_bom)
|
||||
if item and item[0]['is_sub_contracted_item'] != 'Yes':
|
||||
ret_bom_rates = {
|
||||
'moving_avg_rate' : 0,
|
||||
'last_purchase_rate' : 0,
|
||||
'standard_rate' : 0
|
||||
}
|
||||
ret_item.update(ret_bom_rates)
|
||||
return cstr(ret_item)
|
||||
|
||||
def set_as_default_bom(self):
|
||||
# set Is Default as 1
|
||||
set(self.doc,'is_default', flt(1))
|
||||
|
||||
# get previous default bom from Item Master
|
||||
prev_def_bom = sql("select default_bom from `tabItem` where name = %s", self.doc.item,as_dict = 1)
|
||||
|
||||
if prev_def_bom[0]['default_bom'] and prev_def_bom[0]['default_bom'] != self.doc.name:
|
||||
# update Is Default as 0 in Previous Default BOM
|
||||
msgprint(cstr(prev_def_bom[0]['default_bom']) + "is no longer Default BOM for item" + cstr(self.doc.item))
|
||||
sql("update `tabBill Of Materials` set is_default = 0 where name = '%s'" % (prev_def_bom[0]['default_bom']))
|
||||
|
||||
# update current BOM as default bom in Item Master
|
||||
sql("update `tabItem` set default_bom = '%s' where name = '%s'" % (self.doc.name,self.doc.item))
|
||||
msgprint(cstr(self.doc.name) + "has been set as Default BOM for Item "+cstr(self.doc.item))
|
||||
|
||||
def check_active_parent_boms(self):
|
||||
act_pbom = sql("select distinct t1.parent from `tabBOM Material` t1, `tabBill Of Materials` t2 where t1.bom_no ='%s' and t2.name = t1.parent and t2.is_active = 'Yes' and t2.docstatus = 1 and t1.docstatus =1 " % self.doc.name )
|
||||
if act_pbom and act_pbom[0][0]:
|
||||
msgprint("Sorry cannot Inactivate as BOM %s is child of one or many other active parent BOMs" % self.doc.name)
|
||||
raise Exception
|
||||
|
||||
def activate_inactivate_bom(self, action):
|
||||
if cstr(action) == 'Activate':
|
||||
self.validate()
|
||||
set(self.doc, 'is_active', 'Yes')
|
||||
elif cstr(action) == 'Inactivate':
|
||||
self.check_active_parent_boms()
|
||||
set(self.doc, 'is_active', 'No')
|
||||
|
||||
#------ On Validation Of Document ----------
|
||||
def validate_main_item(self):
|
||||
item = sql("select is_manufactured_item, is_sub_contracted_item from `tabItem` where name = %s and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now())", self.doc.item, as_dict = 1)
|
||||
|
||||
if not item:
|
||||
msgprint("Item %s do not exists in the system. Entered in BOM := %s" % (cstr(self.doc.item), cstr(self.doc.name)))
|
||||
raise Exception
|
||||
|
||||
elif not item[0]['is_manufactured_item'] == 'Yes' and not item[0]['is_sub_contracted_item'] == 'Yes':
|
||||
msgprint("Sorry cannot make Bill Of Materials for Item %s. As it is not a manufactured / sub-contracted item. Entered in BOM := %s " % (cstr(self.doc.item), cstr(self.doc.name)))
|
||||
raise Exception
|
||||
|
||||
# validate operations
|
||||
#------------------------------------------------------
|
||||
def validate_operations(self,o,validate = "0"):
|
||||
if not o.operation_no:
|
||||
msgprint("Please Enter Operation No at Row " + cstr(o.idx)+" in BOM := " +cstr(self.doc.name))
|
||||
raise Exception
|
||||
|
||||
if not o.workstation:
|
||||
msgprint("Please Enter Workstation for Operation No. " + cstr(o.operation_no) + " in BOM NO. " + self.doc.name)
|
||||
raise Exception
|
||||
|
||||
if not o.time_in_mins:
|
||||
msgprint("Please Enter Operation Time of Operation No. " + cstr(o.operation_no) + " in BOM NO. " + self.doc.name)
|
||||
raise Exception
|
||||
|
||||
# Operation No should not repeat.
|
||||
if o.operation_no in self.op:
|
||||
msgprint("Operation No " + cstr(o.operation_no) + "is repeated in Operations Table of BOM NO. " + self.doc.name)
|
||||
raise Exception
|
||||
|
||||
# add operation in op list
|
||||
self.op.append(cstr(o.operation_no))
|
||||
|
||||
# Validate materials
|
||||
#-------------------------------------------------
|
||||
|
||||
def validate_materials(self,m):
|
||||
|
||||
# check for operation no
|
||||
if not self.op:
|
||||
msgprint("Please Enter Operations in operation table of BOM NO. " + self.doc.name)
|
||||
raise Exception
|
||||
|
||||
# check if operation no not in op list
|
||||
if m.operation_no not in self.op:
|
||||
msgprint("Operation no "+ cstr(m.operation_no) + " for item code " + cstr(m.item_code) +" is not present in BOM Operations of BOM NO. " + self.doc.name)
|
||||
raise Exception
|
||||
|
||||
if not m.item_code:
|
||||
msgprint("Please Enter Item Code at Row " + cstr(m.idx) + "of BOM Material in BOM NO. " + self.doc.name)
|
||||
raise Exception
|
||||
|
||||
item = sql("select is_manufactured_item, is_sub_contracted_item from`tabItem` where item_code = %s and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now())", m.item_code, as_dict = 1)
|
||||
if not item:
|
||||
msgprint("Item %s is not present in Item Master." % m.item_code)
|
||||
raise Exception
|
||||
|
||||
if item[0]['is_manufactured_item'] == 'Yes' or item[0]['is_sub_contracted_item'] == 'Yes':
|
||||
bom = sql("select name, is_active, docstatus from `tabBill Of Materials` where item = %s", m.item_code, as_dict =1)
|
||||
if bom and bom[0]['name']:
|
||||
if not m.bom_no:
|
||||
msgprint("Please Enter BOM No for Item " + cstr(m.item_code) + " in Materials at Row No. " + cstr(m.idx) + " in BOM NO. " + self.doc.name)
|
||||
raise Exception
|
||||
else:
|
||||
match = 0
|
||||
for b in bom:
|
||||
if cstr(m.bom_no) == cstr(b['name']):
|
||||
if b['is_active'] != 'Yes':
|
||||
msgprint("BOM %s NOT ACTIVE BOM. Entered in BOM := %s at row no := %s" % (cstr(m.bom_no), cstr(self.doc.name), m.idx))
|
||||
raise Exception
|
||||
|
||||
#if flt(b['docstatus']) != 1:
|
||||
# msgprint("BOM %s is NOT SUBMITTED."% cstr(m.bom_no))
|
||||
# raise Exception
|
||||
|
||||
match = 1
|
||||
if not match:
|
||||
msgprint("Item %s does not belongs to Bill Of Material %s or Bill Of Material %s is NOT ACTIVE BOM. Entered in BOM := %s at row no := %s" % (cstr(m.item_code),cstr(m.bom_no), cstr(m.bom_no), self.doc.name, m.idx))
|
||||
raise Exception
|
||||
|
||||
if not item[0]['is_manufactured_item'] == 'Yes' and not item[0]['is_sub_contracted_item']== 'Yes':
|
||||
if m.bom_no:
|
||||
msgprint("As in Item Master of Item %s Is Manufactured Item / Is Sub-Contracted Item is not 'Yes' hence there should be no BOM.In BOm := %s at row no := %s" % (m.item_code, cstr(self.doc.name), m.idx))
|
||||
raise Exception
|
||||
|
||||
if not m.qty or m.qty <= 0:
|
||||
msgprint("Please Enter Qty value greater than 0(Zero) at Row " + cstr(m.idx) + " in BOM NO. " + self.doc.name)
|
||||
raise Exception
|
||||
|
||||
if m.scrap and m.scrap < 0:
|
||||
msgprint("Please Enter Scrap value Greater than 0(Zero) at Row " + cstr(m.idx) + " in BOM NO. " + self.doc.name)
|
||||
raise Exception
|
||||
|
||||
# Calculate Cost
|
||||
#-----------------------------------------------
|
||||
|
||||
def calculate_cost(self, validate = 0):
|
||||
self.op, op_cost, dir_mat_as_per_mar, dir_mat_as_per_lpr, dir_mat_as_per_sr, count_mat = [], 0.0, 0.0,0.0,0.0, 0
|
||||
# -------- Calculate Cost Of BOM -------------
|
||||
# --- calculate operating cost from BOM Operations ----
|
||||
for o in getlist(self.doclist, 'bom_operations'):
|
||||
# --- Validation for enteries in BOM Operations ----
|
||||
if validate:
|
||||
self.validate_operations(o)
|
||||
|
||||
o.operating_cost = flt(flt(o.time_in_mins)/60) * flt(o.hour_rate)
|
||||
if validate != 1:
|
||||
o.save()
|
||||
|
||||
op_cost = flt(op_cost) + flt(o.operating_cost)
|
||||
|
||||
# --- calculate operating cost and direct material cost from BOM Material ---
|
||||
for m in getlist(self.doclist, 'bom_materials'):
|
||||
# --- Validation for enteries in BOM Material --- '''
|
||||
count_mat = count_mat + 1
|
||||
if validate:
|
||||
self.validate_materials(m)
|
||||
|
||||
if m.bom_no:
|
||||
# add operating cost of child boms
|
||||
op_cost += flt(m.operating_cost)
|
||||
|
||||
# update dir_mat, op_cost, value from child bom
|
||||
self.update_childs_dir_op_value(m, child_bom_cost = 1)
|
||||
|
||||
# check for is_sub_contracted_item
|
||||
item = sql("select is_sub_contracted_item from `tabItem` where name = '%s'" % m.item_code, as_dict =1)
|
||||
if item and item[0]['is_sub_contracted_item'] == 'Yes':
|
||||
# update recent mar,lpr,sr
|
||||
self.update_mar_lpr_sr(m, mar =1, lpr =1, sr =1)
|
||||
# calculate amount for sub contracted item
|
||||
self.calculate_amount( m, has_bom = 1, is_sub_cont = 1)
|
||||
# calculate Direct Material
|
||||
dir_mat_as_per_mar, dir_mat_as_per_lpr, dir_mat_as_per_sr = self.calculate_dir_mat(m, dir_mat_as_per_mar, dir_mat_as_per_lpr, dir_mat_as_per_sr, has_bom = 1, is_sub_cont =1)
|
||||
else:
|
||||
# update mar,lpr,sr as 0
|
||||
self.update_mar_lpr_sr( m, mar = 0, lpr = 0, sr = 0)
|
||||
# calculate amount
|
||||
self.calculate_amount( m, has_bom = 1, is_sub_cont = 0)
|
||||
# calculate Direct Material
|
||||
dir_mat_as_per_mar, dir_mat_as_per_lpr, dir_mat_as_per_sr = self.calculate_dir_mat(m, dir_mat_as_per_mar, dir_mat_as_per_lpr, dir_mat_as_per_sr, has_bom = 1, is_sub_cont =0)
|
||||
|
||||
else :
|
||||
# update dir_mat,op_cost, value as 0
|
||||
self.update_childs_dir_op_value(m, child_bom_cost = 0)
|
||||
# update recent mar,lpr,sr
|
||||
self.update_mar_lpr_sr(m, mar =1, lpr =1, sr =1)
|
||||
# calculate amount
|
||||
self.calculate_amount(m, has_bom = 0, is_sub_cont = 0)
|
||||
# calculate Direct Material
|
||||
dir_mat_as_per_mar, dir_mat_as_per_lpr, dir_mat_as_per_sr = self.calculate_dir_mat(m, dir_mat_as_per_mar, dir_mat_as_per_lpr, dir_mat_as_per_sr, has_bom =0, is_sub_cont =0)
|
||||
|
||||
# update qty_consumed_per_unit
|
||||
m.qty_consumed_per_unit = flt(m.qty) / flt(self.doc.quantity)
|
||||
m.save()
|
||||
#msgprint("dir_mat_as_per_mar < ==> " + cstr(dir_mat_as_per_mar) + "***" + "dir_mat_as_per_lpr < ==> " + cstr(dir_mat_as_per_lpr) + "***" + "dir_mat_as_per_sr < ==> " + cstr(dir_mat_as_per_sr) + "***")
|
||||
if not count_mat:
|
||||
msgprint("There should at least one Item in BOM Material. In BOM := " +cstr(self.doc.name))
|
||||
raise Exception
|
||||
|
||||
set(self.doc, 'operating_cost' ,op_cost)
|
||||
set(self.doc, 'cost_as_on' ,now())
|
||||
# update dir_mat
|
||||
set(self.doc, 'dir_mat_as_per_mar' ,dir_mat_as_per_mar)
|
||||
set(self.doc, 'dir_mat_as_per_lpr' ,dir_mat_as_per_lpr)
|
||||
set(self.doc, 'dir_mat_as_per_sr' ,dir_mat_as_per_sr)
|
||||
# update cost
|
||||
set(self.doc, 'cost_as_per_mar' ,flt(dir_mat_as_per_mar + op_cost))
|
||||
set(self.doc, 'cost_as_per_lpr' ,flt(dir_mat_as_per_lpr + op_cost))
|
||||
set(self.doc, 'cost_as_per_sr' ,flt(dir_mat_as_per_sr + op_cost))
|
||||
|
||||
def update_childs_dir_op_value(self, m, child_bom_cost = 0):
|
||||
#msgprint("IN UPDATE CHILDS DIR OP VALUE")
|
||||
if child_bom_cost:
|
||||
# get recent direct material cost, operating cost, cost from child bom
|
||||
child_bom_cost = sql("select dir_mat_as_per_mar, dir_mat_as_per_lpr, dir_mat_as_per_sr, operating_cost, cost_as_per_mar, cost_as_per_lpr, cost_as_per_sr, quantity from `tabBill Of Materials` where name = %s", m.bom_no, as_dict = 1)
|
||||
|
||||
# operating_cost
|
||||
m.operating_cost = child_bom_cost and flt(child_bom_cost[0]['operating_cost']) / flt(child_bom_cost[0]['quantity']) or 0.00
|
||||
|
||||
val_dir_dict = {'value_as_per_mar': 'cost_as_per_mar', 'dir_mat_as_per_mar': 'dir_mat_as_per_mar',
|
||||
'value_as_per_lpr': 'cost_as_per_lpr', 'dir_mat_as_per_lpr': 'dir_mat_as_per_lpr',
|
||||
'value_as_per_sr' : 'cost_as_per_sr' , 'dir_mat_as_per_sr' : 'dir_mat_as_per_sr' }
|
||||
for d in val_dir_dict:
|
||||
# Set Value and Dir MAt
|
||||
m.fields[d] = child_bom_cost and flt(child_bom_cost[0][val_dir_dict[d]])/flt(child_bom_cost[0]['quantity']) or 0.00
|
||||
|
||||
def update_mar_lpr_sr(self, m, mar = 0, lpr = 0, sr = 0):
|
||||
m.moving_avg_rate, m.last_purchase_rate, m.standard_rate = self.get_mar_lpr_sr(cstr(m.item_code), mar, lpr, sr, m.qty)
|
||||
|
||||
def calculate_amount(self, m, has_bom = 0, is_sub_cont = 0):
|
||||
#msgprint("IN CALCULATE AMOUNT")
|
||||
if has_bom :
|
||||
m.amount_as_per_mar = flt(m.qty) * (is_sub_cont and flt(m.moving_avg_rate) or flt(m.value_as_per_mar)) * flt(1.00 + (flt(m.scrap)/100)) or 0
|
||||
m.amount_as_per_lpr = flt(m.qty) * (is_sub_cont and (flt(m.value_as_per_lpr) + flt(m.last_purchase_rate)) or flt(m.value_as_per_lpr)) * flt(1.00 + (flt(m.scrap)/100)) or 0
|
||||
m.amount_as_per_sr = flt(m.qty) * (is_sub_cont and (flt(m.value_as_per_sr) + flt(m.standard_rate)) or flt(m.value_as_per_mar)) * flt(1.00 + (flt(m.scrap)/100)) or 0
|
||||
|
||||
else:
|
||||
m.amount_as_per_mar = flt(m.qty) * flt(m.moving_avg_rate) * flt(1.00 + (flt(m.scrap)/100)) or 0
|
||||
m.amount_as_per_lpr = flt(m.qty) * flt(m.last_purchase_rate) * flt(1.00 + (flt(m.scrap)/100)) or 0
|
||||
m.amount_as_per_sr = flt(m.qty) * flt(m.standard_rate) * flt(1.00 + (flt(m.scrap)/100)) or 0
|
||||
#msgprint(cstr(m.item_code))
|
||||
#msgprint("amount_as_per_mar < ==> " + cstr(m.amount_as_per_mar) + "***" + "amount_as_per_lpr < ==> " + cstr(m.amount_as_per_lpr) + "***" + "amount_as_per_sr < ==> " + cstr(m.amount_as_per_sr) + "***")
|
||||
def calculate_dir_mat(self, m, dir_mat_as_per_mar, dir_mat_as_per_lpr, dir_mat_as_per_sr, has_bom = 0, is_sub_cont =0):
|
||||
#msgprint("IN CALCULATE DIR MAT")
|
||||
if has_bom:
|
||||
dir_mat_as_per_mar += flt(m.qty) * (is_sub_cont and flt(m.moving_avg_rate) or flt(m.dir_mat_as_per_mar)) * flt(1.00 + (flt(m.scrap)/100)) or 0
|
||||
dir_mat_as_per_lpr += flt(m.qty) * (is_sub_cont and ( flt(m.dir_mat_as_per_lpr)+ flt(m.last_purchase_rate)) or flt(m.dir_mat_as_per_lpr)) * flt(1.00 + (flt(m.scrap)/100)) or 0
|
||||
dir_mat_as_per_sr += flt(m.qty) * (is_sub_cont and ( flt(m.dir_mat_as_per_sr)+ flt(m.standard_rate) ) or flt(m.dir_mat_as_per_sr)) * flt(1.00 + (flt(m.scrap)/100)) or 0
|
||||
else:
|
||||
dir_mat_as_per_mar += flt(m.amount_as_per_mar)
|
||||
dir_mat_as_per_lpr += flt(m.amount_as_per_lpr)
|
||||
dir_mat_as_per_sr += flt(m.amount_as_per_sr)
|
||||
#msgprint(cstr(m.item_code))
|
||||
#msgprint("dir_mat_as_per_mar < ==> " + cstr(dir_mat_as_per_mar) + "***" + "dir_mat_as_per_lpr < ==> " + cstr(dir_mat_as_per_lpr) + "***" + "dir_mat_as_per_sr < ==> " + cstr(dir_mat_as_per_sr) + "***")
|
||||
return dir_mat_as_per_mar, dir_mat_as_per_lpr, dir_mat_as_per_sr
|
||||
|
||||
|
||||
# Get FIFO Rate from Stack
|
||||
# -------------------------
|
||||
def get_fifo_rate(self, fcfs_bal, qty):
|
||||
if qty:
|
||||
fcfs_val = 0
|
||||
withdraw = flt(qty)
|
||||
while withdraw:
|
||||
if not fcfs_bal:
|
||||
break # nothing in store
|
||||
|
||||
batch = fcfs_bal[0]
|
||||
|
||||
if batch[0] < withdraw:
|
||||
# not enough in current batch, clear batch
|
||||
withdraw -= batch[0]
|
||||
fcfs_val += (flt(batch[0]) * flt(batch[1]))
|
||||
fcfs_bal.pop(0)
|
||||
else:
|
||||
# all from current batch
|
||||
fcfs_val += (flt(withdraw) * flt(batch[1]))
|
||||
batch[0] -= withdraw
|
||||
withdraw = 0
|
||||
fcfs_rate = flt(fcfs_val) / flt(qty)
|
||||
return fcfs_rate
|
||||
else:
|
||||
return fcfs_bal and fcfs_bal[0][1] or 0
|
||||
|
||||
|
||||
# Get valuation rate
|
||||
# --------------------
|
||||
def get_valuation_rate(self, item_code, qty):
|
||||
# get default warehouse
|
||||
warehouse = sql("select default_warehouse from tabItem where name = %s", item_code)
|
||||
warehouse = warehouse and warehouse[0][0] or ''
|
||||
in_rate = 0
|
||||
|
||||
# get default valuation method
|
||||
val_method = sql("select valuation_method from tabItem where name = %s", item_code)
|
||||
val_method = val_method and val_method[0][0] or ''
|
||||
if not val_method: val_method = get_defaults().has_key('valuation_method') and get_defaults()['valuation_method'] or 'FIFO'
|
||||
|
||||
if val_method == 'FIFO':
|
||||
if warehouse:
|
||||
bin_obj = get_obj('Warehouse',warehouse).get_bin(item_code)
|
||||
prev_sle = bin_obj.get_prev_sle('',nowdate(), (now().split(' ')[1])[:-3])
|
||||
fcfs_stack = prev_sle and (prev_sle[0][3] and eval(prev_sle[0][3]) or []) or []
|
||||
else:
|
||||
prev_sle = sql("select fcfs_stack from `tabStock Ledger Entry` where item_code = '%s' and posting_date <= '%s' order by posting_date DESC, posting_time DESC, name DESC limit 1" % (item_code, nowdate()))
|
||||
fcfs_stack = prev_sle and (prev_sle[0][0] and eval(prev_sle[0][0]) or []) or []
|
||||
in_rate = fcfs_stack and self.get_fifo_rate(fcfs_stack, qty) or 0
|
||||
elif val_method == 'Moving Average':
|
||||
in_rate = sql("select ifnull(sum(valuation_rate), 0)/ ifnull(count(*),1) from `tabBin` where item_code = '%s' and ifnull(ma_rate, 0) > 0" % cstr(item_code))
|
||||
in_rate = in_rate and flt(in_rate[0][0]) or 0
|
||||
return in_rate
|
||||
|
||||
|
||||
# Get valuation, Last Purchase and Standard Rate
|
||||
# ------------------------------------------------
|
||||
def get_mar_lpr_sr(self, item_code, mar = 0, lpr = 0, sr = 0, qty = 1.00):
|
||||
# get list of warehouse having
|
||||
ma_rate, lpr_rate, sr_rate = 0,0,0
|
||||
if mar:
|
||||
# get recent moving average rate
|
||||
#ma_rate = sql("select ifnull(sum(ma_rate), 0)/ ifnull(count(*),1) from `tabBin` where item_code = '%s' and ifnull(ma_rate, 0) > 0" % cstr(item_code))
|
||||
#ma_rate = flt(ma_rate and ma_rate[0][0]) or 0
|
||||
ma_rate = self.get_valuation_rate(item_code, qty)
|
||||
|
||||
# get recent last purchase rate
|
||||
lpr_rate = lpr and flt(sql("select last_purchase_rate from `tabItem` where name = '%s'" % item_code)[0][0]) or 0.00
|
||||
# get recent standard rate
|
||||
sr_rate = sr and flt(sql("select standard_rate from `tabItem` where name = '%s'" % item_code)[0][0]) or 0.00
|
||||
return ma_rate, lpr_rate, sr_rate
|
||||
|
||||
#checking for duplicate items i.e items that may be entered twice
|
||||
def validate_duplicate_items(self):
|
||||
check_list = []
|
||||
for d in getlist(self.doclist, 'bom_materials'):
|
||||
if cstr(d.item_code) in check_list:
|
||||
msgprint("Item %s has been entered twice. In BOM %s" % (d.item_code, self.doc.name))
|
||||
raise Exception
|
||||
else:
|
||||
check_list.append(cstr(d.item_code))
|
||||
|
||||
#----- Document on Save function------
|
||||
def validate(self):
|
||||
self.validate_main_item()
|
||||
self.validate_duplicate_items()
|
||||
self.calculate_cost(validate = 1)
|
||||
|
||||
def check_recursion(self):
|
||||
check_list = [['parent', 'bom_no', 'parent'], ['bom_no', 'parent', 'child']]
|
||||
for d in check_list:
|
||||
bom_list, count = [self.doc.name], 0
|
||||
while ( len(bom_list) > count ):
|
||||
boms = sql(" select %s from `tabBOM Material` where %s = '%s' " % ( d[0], d[1], cstr(bom_list[count])))
|
||||
count = count + 1
|
||||
for b in boms:
|
||||
if b[0] == self.doc.name:
|
||||
msgprint("Recursion Occured:=> '%s' cannot be '%s' of '%s'." % ( cstr(b), cstr(d[2]), cstr(self.doc.name)))
|
||||
raise Exception
|
||||
if b[0]:
|
||||
bom_list.append(b[0])
|
||||
|
||||
def on_update(self):
|
||||
if self.doc.item != cstr(self.doc.name.split('/')[1]):
|
||||
msgprint("Cannot change Item once the Bill Of Material is created.")
|
||||
raise Exception
|
||||
self.check_recursion()
|
||||
|
||||
|
||||
# ********************************************** Submit *************************************************************
|
||||
|
||||
# Add Flat BOM Details
|
||||
# -----------------------
|
||||
def add_to_flat_bom_detail(self, is_submit = 0):
|
||||
self.doc.clear_table(self.doclist, 'flat_bom_details', 1)
|
||||
fb_lbl = {'item_code': 0, 'description': 1, 'qty': 2, 'stock_uom': 3, 'moving_avg_rate': 4,'amount_as_per_mar': 5, 'last_purchase_rate': 6, 'amount_as_per_lpr':7,'standard_rate':8,'amount_as_per_sr':9,'qty_consumed_per_unit': 10, 'parent_bom': 11, 'bom_mat_no': 12, 'is_pro_applicable': 13}
|
||||
for d in self.cur_flat_bom_items:
|
||||
fb_child = addchild(self.doc, 'flat_bom_details', 'Flat BOM Detail', 1, self.doclist)
|
||||
for i in fb_lbl:
|
||||
fb_child.fields[i] = d[fb_lbl[i]]
|
||||
fb_child.docstatus = is_submit
|
||||
fb_child.save(1)
|
||||
self.doc.save()
|
||||
|
||||
|
||||
#Get Child Flat BOM Items
|
||||
#----------------------------------------
|
||||
def get_child_flat_bom_items(self, item, d):
|
||||
child_flat_bom_items=[]
|
||||
if item and (item[0]['is_sub_contracted_item'] == 'Yes' or item[0]['is_pro_applicable'] == 'Yes'):
|
||||
child_flat_bom_items = sql("select item_code, description, qty_consumed_per_unit, stock_uom, moving_avg_rate, last_purchase_rate, standard_rate, '%s' as parent_bom, bom_mat_no, 'No' as is_pro_applicable from `tabFlat BOM Detail` where parent = '%s' and is_pro_applicable = 'No' and docstatus = 1" % ( d.bom_no, cstr(d.bom_no)))
|
||||
self.cur_flat_bom_items.append([d.item_code, d.description, flt(d.qty), d.stock_uom, flt(d.moving_avg_rate), flt(d.amount_as_per_mar), flt(d.last_purchase_rate), flt(d.amount_as_per_lpr), flt(d.standard_rate), flt(d.amount_as_per_sr), flt(d.qty_consumed_per_unit), (item[0]['is_sub_contracted_item'] == 'Yes') and d.parent or d.bom_no, d.name, (item[0]['is_sub_contracted_item'] == 'Yes') and 'No' or 'Yes'])
|
||||
|
||||
else:
|
||||
child_flat_bom_items = sql("select item_code, description, qty_consumed_per_unit, stock_uom, moving_avg_rate, last_purchase_rate, standard_rate, if(parent_bom = '%s', '%s', parent_bom) as parent_bom, bom_mat_no, is_pro_applicable from `tabFlat BOM Detail` where parent = '%s' and docstatus = 1" % ( d.bom_no, d.parent, cstr(d.bom_no)))
|
||||
|
||||
if not child_flat_bom_items:
|
||||
msgprint("Please Submit Child BOM := %s first." % cstr(d.bom_no))
|
||||
raise Exception
|
||||
else:
|
||||
return child_flat_bom_items
|
||||
|
||||
|
||||
# Get Current Flat BOM Items
|
||||
# -----------------------------
|
||||
def get_current_flat_bom_items(self):
|
||||
self.cur_flat_bom_items = []
|
||||
|
||||
cfb_lbl = {'item_code': 0, 'description': 1, 'qty_consumed_per_unit': 2, 'stock_uom': 3, 'moving_avg_rate': 4, 'last_purchase_rate': 5, 'standard_rate': 6, 'parent_bom': 7, 'bom_mat_no': 8, 'is_pro_applicable': 9}
|
||||
|
||||
for d in getlist(self.doclist, 'bom_materials'):
|
||||
if d.bom_no:
|
||||
item = sql("select is_sub_contracted_item, is_pro_applicable from `tabItem` where name = '%s'" % d.item_code, as_dict = 1)
|
||||
child_flat_bom_items = self.get_child_flat_bom_items(item,d)
|
||||
|
||||
for c in child_flat_bom_items:
|
||||
self.cur_flat_bom_items.append([c[cfb_lbl['item_code']], c[cfb_lbl['description']], flt(d.qty) * flt(c[cfb_lbl['qty_consumed_per_unit']]), c[cfb_lbl['stock_uom']], flt(c[cfb_lbl['moving_avg_rate']]), flt(d.qty) * flt(c[cfb_lbl['qty_consumed_per_unit']]) * flt(c[cfb_lbl['moving_avg_rate']]) ,flt(c[cfb_lbl['last_purchase_rate']]), flt(d.qty) * flt(c[cfb_lbl['qty_consumed_per_unit']]) * flt(c[cfb_lbl['last_purchase_rate']]), flt(c[cfb_lbl['standard_rate']]), flt(d.qty) * flt(c[cfb_lbl['qty_consumed_per_unit']]) * flt(c[cfb_lbl['standard_rate']]), flt(d.qty_consumed_per_unit) * flt(c[cfb_lbl['qty_consumed_per_unit']]), c[cfb_lbl['parent_bom']], c[cfb_lbl['bom_mat_no']], c[cfb_lbl['is_pro_applicable']]])
|
||||
else:
|
||||
# add purchase_items from bom material to the child_flat_bom_items
|
||||
self.cur_flat_bom_items.append([d.item_code, d.description, flt(d.qty), d.stock_uom, flt(d.moving_avg_rate), flt(d.amount_as_per_mar), flt(d.last_purchase_rate), flt(d.amount_as_per_lpr), flt(d.standard_rate), flt(d.amount_as_per_sr), flt(d.qty_consumed_per_unit), d.parent, d.name, 'No' ])
|
||||
|
||||
# Update Flat BOM Engine
|
||||
# ------------------------
|
||||
def update_flat_bom_engine(self, is_submit = 0):
|
||||
# following will be correct data
|
||||
# get correct / updated flat bom data
|
||||
self.get_current_flat_bom_items()
|
||||
# insert to curr flat bom data
|
||||
self.add_to_flat_bom_detail(is_submit)
|
||||
|
||||
|
||||
# On Submit
|
||||
# -----------
|
||||
def on_submit(self):
|
||||
self.update_flat_bom_engine()
|
||||
|
||||
|
||||
def get_parent_bom_list(self, bom_no):
|
||||
p_bom = sql("select parent from `tabBOM Material` where bom_no = '%s'" % bom_no)
|
||||
return p_bom and [i[0] for i in p_bom] or []
|
||||
1348
production/doctype/bill_of_materials/bill_of_materials.txt
Normal file
1348
production/doctype/bill_of_materials/bill_of_materials.txt
Normal file
File diff suppressed because it is too large
Load Diff
0
production/doctype/bom_control/__init__.py
Normal file
0
production/doctype/bom_control/__init__.py
Normal file
101
production/doctype/bom_control/bom_control.py
Normal file
101
production/doctype/bom_control/bom_control.py
Normal file
@@ -0,0 +1,101 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
def get_item_group(self):
|
||||
ret = sql("select name from `tabItem Group` ")
|
||||
item_group = []
|
||||
for r in ret:
|
||||
item =sql("select t1.name from `tabItem` t1, `tabBill Of Materials` t2 where t2.item = t1.name and t1.item_group = '%s' " % (r[0]))
|
||||
if item and item[0][0]:
|
||||
item_group.append(r[0])
|
||||
return '~~~'.join([r for r in item_group])
|
||||
|
||||
def get_item_code(self,item_group):
|
||||
# here Bill Of Materials docstatus = 1 and is_active ='yes' condition is not given because some bom is under construction
|
||||
# that is it is still in saved mode and they want see till where they have reach.
|
||||
ret = sql("select distinct t1.name from `tabItem` t1, `tabBill Of Materials` t2 where t2.item = t1.name and t1.item_group = '%s' " % (item_group))
|
||||
return '~~~'.join([r[0] for r in ret])
|
||||
|
||||
def get_bom_no(self,item_code):
|
||||
ret = sql("select name from `tabBill Of Materials` where item = '%s' " % (item_code))
|
||||
return '~~~'.join([r[0] for r in ret])
|
||||
|
||||
def get_operations(self,bom_no):
|
||||
# reply = [ 'Operation',operation_no, opn_description,BOM NO , workstation, hour_rate, time_in_minutes, Total Direct Material, Total Operating Cost, Cost]
|
||||
# reply = [ 0 , 1 , 2 ,3 , 4 , 5 , 6 , 7 , 8 ,9 , 10 , 11 ]
|
||||
|
||||
ret = sql("select operation_no,opn_description,workstation,hour_rate,time_in_mins from `tabBOM Operation` where parent = %s", bom_no, as_dict = 1)
|
||||
cost = sql("select dir_mat_as_per_mar , operating_cost , cost_as_per_mar from `tabBill Of Materials` where name = %s", bom_no, as_dict = 1)
|
||||
# Validate the BOM ENTRIES
|
||||
#check = get_obj('Bill Of Materials', bom_no, with_children =1).validate()
|
||||
reply = []
|
||||
for r in ret:
|
||||
reply.append(['operation',cint(r['operation_no']), r['opn_description'] or '','%s'% bom_no,r['workstation'],flt(r['hour_rate']),flt(r['time_in_mins']),0,0,0])
|
||||
reply[0][7]= flt(cost[0]['dir_mat_as_per_mar'])
|
||||
reply[0][8]=flt(cost[0]['operating_cost'])
|
||||
reply[0][9]=flt(cost[0]['cost_as_per_mar'])
|
||||
#msgprint(bom_no)
|
||||
return reply
|
||||
|
||||
def get_item_bom(self,data):
|
||||
# reply = ['item_bom',item_code,description, BOM NO , qty, uom , scrap ,m_avg_r or value, 1 or 0]
|
||||
# reply = [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ]
|
||||
data = eval(data)
|
||||
reply = []
|
||||
ret = sql("select item_code,description,bom_no,qty,scrap,stock_uom,value_as_per_mar,moving_avg_rate from `tabBOM Material` where parent = '%s' and operation_no = '%s'" % (data['bom_no'],data['op_no']), as_dict =1 )
|
||||
|
||||
for r in ret:
|
||||
item = sql("select is_manufactured_item, is_sub_contracted_item from `tabItem` where name = '%s'" % r['item_code'], as_dict=1)
|
||||
if not item[0]['is_manufactured_item'] == 'Yes' and not item[0]['is_sub_contracted_item'] =='Yes':
|
||||
#msgprint("IS_PURCHASE")
|
||||
#if item is not manufactured or it is not sub-contracted
|
||||
reply.append([ 'item_bom', r['item_code'] or '', r['description'] or '', r['bom_no'] or '', flt(r['qty']) or 0, r['stock_uom'] or '', flt(r['scrap']) or 0, flt(r['moving_avg_rate']) or 0, 1])
|
||||
else:
|
||||
#msgprint("IS_NOT_PURCHASE")
|
||||
# if it is manufactured or sub_contracted this will be considered(here item can be purchase item)
|
||||
reply.append([ 'item_bom', r['item_code'] or '', r['description'] or '', r['bom_no'] or '', flt(r['qty']) or 0, r['stock_uom'] or '', flt(r['scrap']) or 0, flt(r['value_as_per_mar']) or 0, 0])
|
||||
return reply
|
||||
|
||||
|
||||
|
||||
#------------- Wrapper Code --------------
|
||||
# BOM TREE
|
||||
def calculate_cost( self, bom_no):
|
||||
main_bom_list = get_obj(dt = 'Production Control').traverse_bom_tree( bom_no = bom_no, qty = 1, calculate_cost = 1)
|
||||
main_bom_list.reverse()
|
||||
for bom in main_bom_list:
|
||||
bom_obj = get_obj('Bill Of Materials', bom, with_children = 1)
|
||||
bom_obj.calculate_cost(validate = 0)
|
||||
bom_obj.doc.save()
|
||||
return 'calculated'
|
||||
|
||||
|
||||
def get_bom_tree_list(self,args):
|
||||
arg = eval(args)
|
||||
i =[]
|
||||
for a in sql("select t1.name from `tabBill Of Materials` t1, `tabItem` t2 where t2.item_group like '%s' and t1.item like '%s'"%(arg['item_group'] +'%',arg['item_code'] + '%')):
|
||||
if a[0] not in i:
|
||||
i.append(a[0])
|
||||
return i
|
||||
# return [s[0] for s in sql("select t1.name from `tabBill Of Materials` t1, `tabItem` t2 where t2.item_group like '%s' and t1.item like '%s' " %(arg['item_group']+'%',arg['item_code'+'%'])]
|
||||
1
production/doctype/bom_control/bom_control.txt
Normal file
1
production/doctype/bom_control/bom_control.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-08-31 15:17:30', 'search_fields': None, 'module': 'Production', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 108, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': '', 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'nabin@webnotestech.com', 'document_type': None, 'name': 'BOM Control', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}]
|
||||
0
production/doctype/bom_material/__init__.py
Normal file
0
production/doctype/bom_material/__init__.py
Normal file
1
production/doctype/bom_material/bom_material.txt
Normal file
1
production/doctype/bom_material/bom_material.txt
Normal file
File diff suppressed because one or more lines are too long
0
production/doctype/bom_operation/__init__.py
Normal file
0
production/doctype/bom_operation/__init__.py
Normal file
1
production/doctype/bom_operation/bom_operation.txt
Normal file
1
production/doctype/bom_operation/bom_operation.txt
Normal file
File diff suppressed because one or more lines are too long
0
production/doctype/bom_replace_utility/__init__.py
Normal file
0
production/doctype/bom_replace_utility/__init__.py
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
// Get Query functions
|
||||
cur_frm.fields_dict['s_bom'].get_query = function(doc) {
|
||||
return 'SELECT `tabBill Of Materials`.`name` FROM `tabBill Of Materials` WHERE `tabBill Of Materials`.`docstatus` = 1 AND `tabBill Of Materials`.%(key)s LIKE "%s" ORDER BY `tabBill Of Materials`.`name` DESC LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['r_bom'].get_query = function(doc) {
|
||||
return 'SELECT `tabBill Of Materials`.`name` FROM `tabBill Of Materials` WHERE `tabBill Of Materials`.`docstatus` = 1 and `tabBill Of Materials`.%(key)s LIKE "%s" ORDER BY `tabBill Of Materials`.`name` DESC LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['s_item'].get_query = function(doc) {
|
||||
return 'SELECT DISTINCT `tabItem`.name FROM `tabItem` WHERE (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` ="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND (`tabItem`.is_purchase_item = "Yes" OR`tabItem`.is_sub_contracted_item = "Yes") AND tabItem.%(key)s LIKE "%s" ORDER BY `tabItem`.item_code LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['r_item'].get_query = function(doc) {
|
||||
return 'SELECT DISTINCT `tabItem`.name FROM `tabItem` WHERE (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` ="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND (`tabItem`.is_purchase_item = "Yes" OR`tabItem`.is_sub_contracted_item = "Yes") AND tabItem.%(key)s LIKE "%s" ORDER BY `tabItem`.item_code LIMIT 50';
|
||||
}
|
||||
|
||||
// Client Triggers
|
||||
|
||||
127
production/doctype/bom_replace_utility/bom_replace_utility.py
Normal file
127
production/doctype/bom_replace_utility/bom_replace_utility.py
Normal file
@@ -0,0 +1,127 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
def search_parent_bom_of_bom(self):
|
||||
pbom = sql("select parent from `tabBOM Material` where bom_no = '%s' and docstatus = 1 " % self.doc.s_bom )
|
||||
self.doc.clear_table(self.doclist,'replace_bom_details', 1)
|
||||
self.add_to_replace_bom_utility_detail(pbom, 'replace_bom_details')
|
||||
|
||||
def search_parent_bom_of_item(self):
|
||||
pbom = sql("select parent from `tabBOM Material` where item_code = '%s' and (bom_no is NULL or bom_no = '') and docstatus =1" % self.doc.s_item )
|
||||
self.doc.clear_table(self.doclist,'replace_item_details', 1)
|
||||
self.add_to_replace_bom_utility_detail(pbom, 'replace_item_details')
|
||||
|
||||
def add_to_replace_bom_utility_detail(self, pbom, t_fname):
|
||||
for d in pbom:
|
||||
br_child = addchild( self.doc, t_fname, 'BOM Replace Utility Detail', 0,self.doclist)
|
||||
br_child.parent_bom = d[0]
|
||||
br_child.save()
|
||||
self.doc.save()
|
||||
|
||||
def replace_bom(self):
|
||||
# validate r_bom
|
||||
bom = sql("select name, is_active, docstatus from `tabBill Of Materials` where name = %s",self.doc.r_bom, as_dict =1)
|
||||
if not bom:
|
||||
msgprint("Please Enter Valid BOM to replace with.")
|
||||
raise Exception
|
||||
if bom and bom[0]['is_active'] != 'Yes':
|
||||
msgprint("BOM '%s' is not Active BOM." % cstr(self.doc.r_bom))
|
||||
raise Exception
|
||||
if bom and flt(bom[0]['docstatus']) != 1:
|
||||
msgprint("BOM '%s' is not Submitted BOM." % cstr(self.doc.r_bom))
|
||||
raise Exception
|
||||
|
||||
# get item code of r_bom
|
||||
item_code = cstr(sql("select item from `tabBill Of Materials` where name = '%s' " % self.doc.r_bom)[0][0])
|
||||
# call replace bom engine
|
||||
self.replace_bom_engine('replace_bom_details', 'bom_no', self.doc.s_bom, self.doc.r_bom, item_code)
|
||||
|
||||
def replace_item(self):
|
||||
item = sql("select name, is_active from `tabItem` where name = %s", self.doc.r_item, as_dict = 1)
|
||||
if not item:
|
||||
msgprint("Please enter Valid Item Code to replace with.")
|
||||
raise Exception
|
||||
if item and item[0]['is_active'] != 'Yes':
|
||||
msgprint("Item Code '%s' is not Active Item." % cstr(self.doc.r_item))
|
||||
raise Exception
|
||||
self.replace_bom_engine('replace_item_details', 'item_code', self.doc.s_item, self.doc.r_item)
|
||||
|
||||
def replace_data_in_bom_materials(self, dl, fname, s_data, r_data, item_code =''):
|
||||
for d in getlist(dl, 'bom_materials'):
|
||||
if d.fields[fname] == s_data:
|
||||
d.fields[fname] = r_data
|
||||
if fname == 'bom_no':
|
||||
d.item_code = item_code
|
||||
d.save()
|
||||
|
||||
def replace_bom_engine(self, t_fname, fname, s_data, r_data, item_code = ''):
|
||||
if not r_data:
|
||||
msgprint("Please Enter '%s' and then click on '%s'." % ((t_fname == 'replace_bom_details') and 'BOM to Replace' or 'Item to Replace',(t_fname == 'replace_bom_details') and 'Replace BOM' or 'Replace Item' ))
|
||||
raise Exception
|
||||
|
||||
for d in getlist(self.doclist, t_fname):
|
||||
if d.bom_created:
|
||||
msgprint("Please click on '%s' and then on '%s'." % ((t_fname == 'replace_bom_details') and 'Search BOM' or 'Search Item',(t_fname == 'replace_bom_details') and 'Replace BOM' or 'Replace Item' ))
|
||||
raise Exception
|
||||
|
||||
if d.replace:
|
||||
# copy_doclist is the framework funcn which create duplicate document and returns doclist of new document
|
||||
# Reinder :=
|
||||
# make copy
|
||||
if self.doc.create_new_bom:
|
||||
import webnotes.model.doc
|
||||
new_bom_dl = copy_doclist(webnotes.model.doc.get('Bill Of Materials', d.parent_bom), no_copy = ['is_active', 'is_default', 'is_sub_assembly', 'remarks', 'flat_bom_details'])
|
||||
|
||||
new_bom_dl[0].docstatus = 0
|
||||
new_bom_dl[0].save()
|
||||
else:
|
||||
new_bom_dl = get_obj('Bill Of Materials', d.parent_bom, with_children = 1).doclist
|
||||
|
||||
# replace s_data with r_data in Bom Material Detail Table
|
||||
self.replace_data_in_bom_materials(new_bom_dl, fname, s_data, r_data, item_code)
|
||||
|
||||
d.bom_created = new_bom_dl[0].name
|
||||
d.save()
|
||||
|
||||
def update_docstatus(self):
|
||||
sql("update `tabBill Of Materials` set docstatus = 0 where name = '%s' limit 1" % self.doc.bom)
|
||||
msgprint("Updated")
|
||||
|
||||
def update_bom(self):
|
||||
self.check_bom_list = []
|
||||
main_bom_list = get_obj('Production Control').traverse_bom_tree(self.doc.fg_bom_no, 1)
|
||||
main_bom_list.reverse()
|
||||
# run calculate cost and get
|
||||
#msgprint(main_bom_list)
|
||||
for bom in main_bom_list:
|
||||
if bom and bom not in self.check_bom_list:
|
||||
bom_obj = get_obj('Bill Of Materials', bom, with_children = 1)
|
||||
#print(bom_obj.doc.fields)
|
||||
bom_obj.validate()
|
||||
bom_obj.doc.docstatus = 1
|
||||
bom_obj.check_recursion()
|
||||
bom_obj.update_flat_bom_engine(is_submit = 1)
|
||||
bom_obj.doc.docstatus = 1
|
||||
bom_obj.doc.save()
|
||||
self.check_bom_list.append(bom)
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2010-01-14 12:17:12', 'search_fields': None, 'module': 'Production', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'jai@webnotestech.com', 'in_dialog': None, 'in_create': 1, 'read_only': 1, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 8, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': 1, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': 'BRUD/.#####', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'jai@webnotestech.com', 'document_type': None, 'name': 'BOM Replace Utility Detail', 'idx': None, 'hide_toolbar': 1, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'cancel': None, 'amend': None, 'execute': None, 'modified_by': 'jai@webnotestech.com', 'name': 'PERM00985', 'parent': 'BOM Replace Utility Detail', 'read': 1, 'create': 0, 'creation': '2010-04-29 10:17:25', 'modified': '2010-04-29 10:17:25', 'submit': None, 'doctype': 'DocPerm', 'write': 1, 'idx': 1, 'parenttype': 'DocType', 'role': 'Administrator', 'owner': 'jai@webnotestech.com', 'docstatus': 0, 'permlevel': 0, 'match': None, 'parentfield': 'permissions'}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2010-01-14 12:19:28', 'doctype': 'DocField', 'oldfieldname': 'parent_bom', 'owner': 'jai@webnotestech.com', 'reqd': 1, 'in_filter': None, 'print_hide': None, 'modified_by': 'jai@webnotestech.com', 'label': 'Parent BOM', 'width': None, 'trigger': '', 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'BOM Replace Utility Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03593', 'idx': 1, 'default': None, 'colour': 'White:FFF', 'modified': '2010-04-29 10:17:25', 'parenttype': 'DocType', 'fieldname': 'parent_bom', 'fieldtype': 'Link', 'options': 'Bill Of Materials', 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Check', 'creation': '2010-01-14 12:19:28', 'doctype': 'DocField', 'oldfieldname': 'replace', 'owner': 'jai@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'jai@webnotestech.com', 'label': 'Replace', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'BOM Replace Utility Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03594', 'idx': 2, 'default': None, 'colour': None, 'modified': '2010-04-29 10:17:25', 'parenttype': 'DocType', 'fieldname': 'replace', 'fieldtype': 'Check', 'options': None, 'report_hide': None, 'parentfield': 'fields'}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2010-01-14 12:19:28', 'doctype': 'DocField', 'oldfieldname': 'bom_created', 'owner': 'jai@webnotestech.com', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'jai@webnotestech.com', 'label': 'BOM Created', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 1, 'description': None, 'parent': 'BOM Replace Utility Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL03595', 'idx': 3, 'default': None, 'colour': None, 'modified': '2010-04-29 10:17:25', 'parenttype': 'DocType', 'fieldname': 'bom_created', 'fieldtype': 'Link', 'options': 'Bill Of Materials', 'report_hide': None, 'parentfield': 'fields'}]
|
||||
0
production/doctype/bom_report_detail/__init__.py
Normal file
0
production/doctype/bom_report_detail/__init__.py
Normal file
File diff suppressed because one or more lines are too long
0
production/doctype/flat_bom_detail/__init__.py
Normal file
0
production/doctype/flat_bom_detail/__init__.py
Normal file
1
production/doctype/flat_bom_detail/flat_bom_detail.txt
Normal file
1
production/doctype/flat_bom_detail/flat_bom_detail.txt
Normal file
File diff suppressed because one or more lines are too long
0
production/doctype/pf_detail/__init__.py
Normal file
0
production/doctype/pf_detail/__init__.py
Normal file
1
production/doctype/pf_detail/pf_detail.txt
Normal file
1
production/doctype/pf_detail/pf_detail.txt
Normal file
File diff suppressed because one or more lines are too long
0
production/doctype/pp_detail/__init__.py
Normal file
0
production/doctype/pp_detail/__init__.py
Normal file
1
production/doctype/pp_detail/pp_detail.txt
Normal file
1
production/doctype/pp_detail/pp_detail.txt
Normal file
File diff suppressed because one or more lines are too long
0
production/doctype/pp_so_detail/__init__.py
Normal file
0
production/doctype/pp_so_detail/__init__.py
Normal file
1
production/doctype/pp_so_detail/pp_so_detail.txt
Normal file
1
production/doctype/pp_so_detail/pp_so_detail.txt
Normal file
File diff suppressed because one or more lines are too long
0
production/doctype/ppw_detail/__init__.py
Normal file
0
production/doctype/ppw_detail/__init__.py
Normal file
1
production/doctype/ppw_detail/ppw_detail.txt
Normal file
1
production/doctype/ppw_detail/ppw_detail.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-08-31 15:17:49', 'search_fields': None, 'module': 'Production', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': None, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 1, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': 'PPWD/.#######', 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'Administrator', 'document_type': None, 'name': 'PPW Detail', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': None, 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}, {'no_copy': None, 'oldfieldtype': 'Link', 'creation': '2009-08-31 15:17:49', 'doctype': 'DocField', 'oldfieldname': 'warehouse', 'owner': 'Administrator', 'reqd': None, 'in_filter': None, 'print_hide': None, 'modified_by': 'Administrator', 'label': 'Warehouse', 'width': None, 'trigger': None, 'depends_on': None, 'docstatus': 0, 'hidden': None, 'permlevel': 0, 'description': None, 'parent': 'PPW Detail', 'search_index': None, 'allow_on_submit': None, 'icon': None, 'name': 'FL02843', 'idx': 1, 'default': None, 'colour': None, 'modified': '2010-03-31 10:48:47', 'parenttype': 'DocType', 'fieldname': 'warehouse', 'fieldtype': 'Link', 'options': 'Warehouse', 'report_hide': None, 'parentfield': 'fields'}]
|
||||
0
production/doctype/pro_detail/__init__.py
Normal file
0
production/doctype/pro_detail/__init__.py
Normal file
1
production/doctype/pro_detail/pro_detail.txt
Normal file
1
production/doctype/pro_detail/pro_detail.txt
Normal file
File diff suppressed because one or more lines are too long
0
production/doctype/pro_pp_detail/__init__.py
Normal file
0
production/doctype/pro_pp_detail/__init__.py
Normal file
1
production/doctype/pro_pp_detail/pro_pp_detail.txt
Normal file
1
production/doctype/pro_pp_detail/pro_pp_detail.txt
Normal file
File diff suppressed because one or more lines are too long
0
production/doctype/production_control/__init__.py
Normal file
0
production/doctype/production_control/__init__.py
Normal file
155
production/doctype/production_control/production_control.py
Normal file
155
production/doctype/production_control/production_control.py
Normal file
@@ -0,0 +1,155 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__( self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
# pur_items = {'item_code':req_qty}
|
||||
self.pur_items = {}
|
||||
# bom_list = [[]]
|
||||
self.bom_list = []
|
||||
# list for sub assembly item
|
||||
self.sub_assembly_items = []
|
||||
# Item Master
|
||||
self.item_master = {}
|
||||
|
||||
def traverse_bom_tree( self, bom_no, qty, ext_pur_items = 0, ext_sub_assembly_items = 0, calculate_cost = 0, maintain_item_master = 0 ):
|
||||
count, bom_list, qty_list = 0, [bom_no], [qty]
|
||||
while (count < len(bom_list)):
|
||||
# get child items from BOM MAterial Table.
|
||||
child_items = sql("select item_code, bom_no, qty, qty_consumed_per_unit from `tabBOM Material` where parent = %s", bom_list[count], as_dict = 1)
|
||||
child_items = child_items and child_items or []
|
||||
#msgprint(bom_list[count])
|
||||
#msgprint(qty_list)
|
||||
for item in child_items:
|
||||
# Calculate qty required for FG's qty.
|
||||
item['reqd_qty'] = flt(qty) * ((count == 0) and 1 or flt(qty_list[count]) )* flt(item['qty_consumed_per_unit'])
|
||||
#gprint("Item Reqd : " + cstr(item['reqd_qty']))
|
||||
|
||||
# extracting Purchase Items
|
||||
if ext_pur_items and not item['bom_no']:
|
||||
# item exist in pur_items dict then just add qty with previous qty
|
||||
if self.pur_items.has_key(item['item_code']):
|
||||
self.pur_items[item['item_code']] = flt(self.pur_items[item['item_code']]) + flt(item['reqd_qty'])
|
||||
# maintain item master
|
||||
#if maintain_item_master:
|
||||
|
||||
# else add item in pur_item dict with reqd qty.
|
||||
else:
|
||||
self.pur_items[item['item_code']] = flt(item['reqd_qty'])
|
||||
# maintain item master
|
||||
#if maintain_item_master:
|
||||
|
||||
# For calculate cost extracting BOM Items check for duplicate boms, this optmizes the time complexity for while loop.
|
||||
if calculate_cost and item['bom_no'] and (item['bom_no'] not in bom_list):
|
||||
bom_list.append(item['bom_no'])
|
||||
qty_list.append(item['reqd_qty'])
|
||||
|
||||
# Here repeated bom are considered to calculate total qty of raw material required
|
||||
if not calculate_cost and item['bom_no']:
|
||||
# append bom to bom_list
|
||||
bom_list.append(item['bom_no'])
|
||||
qty_list.append(item['reqd_qty'])
|
||||
|
||||
# # extracting Sub Assembly Items . Make Sure Sub Assembly Items have BOM No. in BOM MATERIAL
|
||||
# if ext_sub_assembly_items:
|
||||
# # If Production Order Applicable is 'Yes'
|
||||
# if item['pro_applicable#'] == "Yes":
|
||||
# # append item in sub_assembly_items
|
||||
# self.sub_assembly_items.append([item['item_code']])
|
||||
# # Remove current bom from bom_list
|
||||
# bom_list.pop()
|
||||
|
||||
count += 1
|
||||
return bom_list
|
||||
|
||||
|
||||
|
||||
# Raise Production Order
|
||||
def create_production_order(self,company, fy, pp_detail = '', pro_detail = ''):
|
||||
pro_lbl = {'production_item': 0, 'description': 1, 'qty' : 2, 'stock_uom' : 3, 'bom_no': 4, 'consider_sa_items': 5}
|
||||
|
||||
default_values = { 'transaction_date' : now(),
|
||||
'origin' : pp_detail and 'MRP' or 'Direct',
|
||||
'wip_warehouse' : 'MB1-Stores',
|
||||
'status' : 'Draft',
|
||||
'company' : company,
|
||||
'fiscal_year' : fy }
|
||||
|
||||
pro_list, count = pp_detail and pp_detail or pro_detail, 0
|
||||
|
||||
while (count < len(pro_list)):
|
||||
pro_doc = Document('Production Order')
|
||||
|
||||
for key in pro_lbl.keys():
|
||||
pro_doc.fields[key] = pro_list[count][pro_lbl[key]]
|
||||
|
||||
for key in default_values:
|
||||
pro_doc.fields[key] = default_values[key]
|
||||
|
||||
pro_doc.save(new = 1)
|
||||
pro_list[count] = pro_doc.name
|
||||
|
||||
# This was for adding raw materials in pro detail and get sa items
|
||||
#sa_list = get_obj('Porduction Order', pro_doc.name, with_children = 1).get_purchase_item( get_sa_items = 1, add_child= 1)
|
||||
#for sa_item in sa_list:
|
||||
# pro_list.append(sa_item)
|
||||
|
||||
count = count + 1
|
||||
return pro_list
|
||||
|
||||
|
||||
def update_bom(self, bom_no):
|
||||
main_bom_list = self.traverse_bom_tree(bom_no, 1)
|
||||
main_bom_list.reverse()
|
||||
#print('--------------')
|
||||
msgprint(main_bom_list)
|
||||
#print('--------------')
|
||||
# run calculate cost and get
|
||||
for bom in main_bom_list:
|
||||
if bom and bom not in self.check_bom_list:
|
||||
#print(bom)
|
||||
bom_obj = get_obj('Bill Of Materials', bom, with_children = 1)
|
||||
#print(bom_obj.doc.fields)
|
||||
bom_obj.doc.save()
|
||||
bom_obj.check_recursion()
|
||||
bom_obj.update_flat_bom_engine()
|
||||
bom_obj.doc.docstatus = 1
|
||||
bom_obj.doc.save()
|
||||
self.check_bom_list.append(bom)
|
||||
#errprint(" " + cstr(bom) + " has been submitted successfully.")
|
||||
|
||||
|
||||
def update_all_fg(self):
|
||||
self.check_bom_list = []
|
||||
#pc_obj = get_obj(dt = 'Production Control')
|
||||
cn_bom = sql("select name from `tabBill Of Materials` where item not like 'CN%' and item not like 'LDR%' and item not like 'HD%' limit 1")
|
||||
#cn_bom = (('BOM/A012629/001',),)
|
||||
i=1
|
||||
#msgprint(cn_bom)
|
||||
for d in cn_bom:
|
||||
if not cstr(d[0]) in self.check_bom_list:
|
||||
print('Main BOM')
|
||||
msgprint(d[0])
|
||||
msgprint(i)
|
||||
#sql("start transaction")
|
||||
#self.update_bom(d[0])
|
||||
#sql("commit")
|
||||
i += 1
|
||||
@@ -0,0 +1 @@
|
||||
[{'section_style': 'Simple', 'is_transaction_doc': None, 'creation': '2009-09-07 18:57:06', 'search_fields': None, 'module': 'Production', 'doctype': 'DocType', 'change_log': None, 'print_outline': '', 'owner': 'Administrator', 'in_dialog': None, 'in_create': None, 'read_only': None, 'allow_email': None, 'dt_template': None, 'hide_heading': None, 'issingle': 1, 'allow_rename': None, 'smallicon': '', 'allow_attach': None, 'show_in_menu': 0, 'max_attachments': None, 'version': 19, 'menu_index': None, 'docstatus': 0, 'allow_copy': None, 'istable': None, 'description': None, 'parent': None, 'server_code': None, 'allow_trash': None, 'allow_print': None, 'autoname': None, 'client_script_core': None, 'client_string': None, 'use_template': None, 'modified_by': 'harshada@webnotestech.com', 'document_type': None, 'name': 'Production Control', 'idx': None, 'hide_toolbar': None, 'colour': 'White:FFF', 'client_script': None, 'modified': '2010-09-20 14:06:57', 'server_code_error': ' ', 'name_case': '', 'parenttype': None, 'read_only_onload': None, 'server_code_core': None, 'server_code_compiled': None, 'parent_node': None, 'parentfield': None}]
|
||||
0
production/doctype/production_order/__init__.py
Normal file
0
production/doctype/production_order/__init__.py
Normal file
113
production/doctype/production_order/production_order.js
Normal file
113
production/doctype/production_order/production_order.js
Normal file
@@ -0,0 +1,113 @@
|
||||
$import(Production Tips Common)
|
||||
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
|
||||
cur_frm.cscript.get_tips(doc, cdt, cdn);
|
||||
|
||||
if (!doc.fiscal_year && doc.__islocal){ set_default_values(doc);}
|
||||
if (!doc.transaction_date) doc.transaction_date = dateutil.obj_to_str(new Date());
|
||||
if (!doc.status) doc.status = 'Draft';
|
||||
cfn_set_fields(doc, cdt, cdn);
|
||||
if (doc.origin != "MRP"){
|
||||
doc.origin = "Manual";
|
||||
//get_field('Production Order', 'consider_sa_items').permlevel = 0;
|
||||
set_field_permlevel('production_item', 0);
|
||||
set_field_permlevel('bom_no', 0);
|
||||
set_field_permlevel('consider_sa_items',0);
|
||||
|
||||
}
|
||||
}
|
||||
// ================================== Refresh ==========================================
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
|
||||
cur_frm.cscript.get_tips(doc, cdt, cdn);
|
||||
cfn_set_fields(doc, cdt, cdn);
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['production_item'].get_query = function(doc) {
|
||||
return 'SELECT DISTINCT `tabItem`.`name`, `tabItem`.`description` FROM `tabItem` WHERE (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` = "0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND `tabItem`.%(key)s LIKE "%s" ORDER BY `tabItem`.`name` LIMIT 50';
|
||||
}
|
||||
|
||||
// ---------------------- Get project name --------------------------
|
||||
cur_frm.fields_dict['project_name'].get_query = function(doc, cdt, cdn) {
|
||||
return 'SELECT `tabProject`.name FROM `tabProject` WHERE `tabProject`.status = "Open" AND `tabProject`.name LIKE "%s" ORDER BY `tabProject`.name ASC LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['bom_no'].get_query = function(doc) {
|
||||
if (doc.production_item){
|
||||
return 'SELECT DISTINCT `tabBill Of Materials`.`name` FROM `tabBill Of Materials` WHERE `tabBill Of Materials`.`is_active` = "Yes" AND `tabBill Of Materials`.`item` = "' + cstr(doc.production_item) + '" AND`tabBill Of Materials`.%(key)s LIKE "%s" ORDER BY `tabBill Of Materials`.`name` LIMIT 50';
|
||||
}
|
||||
else {
|
||||
alert(" Please Enter Production Item First.")
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript.production_item = function(doc, cdt, cdn) {
|
||||
get_server_fields('get_item_detail',doc.production_item,'',doc,cdt,cdn,1);
|
||||
}
|
||||
|
||||
var cfn_set_fields = function(doc, cdt, cdn) {
|
||||
hide_field('Material Transfer');
|
||||
hide_field('Stop Production Order');
|
||||
hide_field('Unstop Production Order')
|
||||
hide_field('Backflush');
|
||||
if (doc.docstatus == 1){
|
||||
unhide_field('Stop Production Order');
|
||||
if (doc.status == 'Submitted' || doc.status == 'Material Transferred' || doc.status == 'In Process'){
|
||||
unhide_field(['Material Transfer','Backflush']);
|
||||
}
|
||||
else if (doc.status == 'Stopped'){
|
||||
unhide_field('Unstop Production Order');
|
||||
hide_field(['Stop Production Order', 'Material Transfer', 'Backflush']);
|
||||
}
|
||||
else if (doc.status == 'Completed'){
|
||||
hide_field(['Stop Production Order', 'Material Transfer', 'Backflush']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Stop PRODUCTION ORDER
|
||||
// ==================================================================================================
|
||||
cur_frm.cscript['Stop Production Order'] = function(doc,cdt,cdn) {
|
||||
var check = confirm("DO YOU REALLY WANT TO Stop PRODUCTION ORDER : " + doc.name);
|
||||
|
||||
if (check) {
|
||||
$c('runserverobj', args={'method':'update_status', 'arg': 'Stopped', 'docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
|
||||
cur_frm.refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Unstop PRODUCTION ORDER
|
||||
// ==================================================================================================
|
||||
cur_frm.cscript['Unstop Production Order'] = function(doc,cdt,cdn) {
|
||||
var check = confirm("DO YOU REALLY WANT TO Unstop PRODUCTION ORDER : " + doc.name);
|
||||
|
||||
if (check) {
|
||||
$c('runserverobj', args={'method':'update_status', 'arg': 'Unstopped', 'docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
|
||||
cur_frm.refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.cscript['Material Transfer'] = function(doc,cdt,cdn) {
|
||||
cur_frm.cscript.make_se(doc, process = 'Material Transfer');
|
||||
}
|
||||
|
||||
cur_frm.cscript['Backflush'] = function(doc,cdt,cdn) {
|
||||
cur_frm.cscript.make_se(doc, process = 'Backflush');
|
||||
}
|
||||
|
||||
cur_frm.cscript.make_se = function(doc, process) {
|
||||
var se = LocalDB.create('Stock Entry');
|
||||
se = locals['Stock Entry'][se];
|
||||
se.purpose = 'Production Order';
|
||||
se.process = process;
|
||||
se.posting_date = doc.posting_date;
|
||||
se.production_order = doc.name;
|
||||
se.fiscal_year = doc.fiscal_year;
|
||||
se.company = doc.company;
|
||||
|
||||
loaddoc('Stock Entry', se.name);
|
||||
}
|
||||
104
production/doctype/production_order/production_order.py
Normal file
104
production/doctype/production_order/production_order.py
Normal file
@@ -0,0 +1,104 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
# Autoname
|
||||
def autoname(self):
|
||||
p = self.doc.fiscal_year
|
||||
self.doc.name = make_autoname('PRO/' + self.doc.fiscal_year[2:5]+self.doc.fiscal_year[7:9] + '/.######')
|
||||
|
||||
def get_item_detail(self, production_item):
|
||||
item = sql("select description, stock_uom, default_bom from `tabItem` where (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now()) and name = %s", production_item, as_dict = 1 )
|
||||
ret = {
|
||||
'description' : item and item[0]['description'] or '',
|
||||
'stock_uom' : item and item[0]['stock_uom'] or '',
|
||||
'default_bom' : item and item[0]['default_bom'] or ''
|
||||
}
|
||||
return cstr(ret)
|
||||
|
||||
def validate(self):
|
||||
if not self.doc.production_item :
|
||||
msgprint("Please enter Production Item")
|
||||
raise Exception
|
||||
if self.doc.production_item :
|
||||
item_detail = sql("select docstatus from `tabItem` where name = '%s'" % self.doc.production_item, as_dict = 1)
|
||||
if not item_detail:
|
||||
msgprint("Item '%s' do not exist in the system." % cstr(self.doc.production_item))
|
||||
raise Exception
|
||||
if item_detail[0]['docstatus'] == 2:
|
||||
msgprint("Item '%s' is Trashed Item ."% self.doc.production_item)
|
||||
raise Exception
|
||||
if self.doc.bom_no:
|
||||
bom_detail = sql("select item, is_active, docstatus from `tabBill Of Materials` where name = '%s'" % self.doc.bom_no, as_dict =1)
|
||||
if not bom_detail:
|
||||
msgprint("BOM No '%s' do not exist in the system." % cstr(self.doc.bom_no))
|
||||
raise Exception
|
||||
if cstr(bom_detail[0]['item']) != cstr(self.doc.production_item):
|
||||
msgprint("The Item '%s' in BOM := '%s' do not match with Produciton Item '%s'." % (cstr(bom_detail[0]['item']), cstr(self.doc.bom_no), cstr(self.doc.production_item)))
|
||||
raise Exception
|
||||
if cstr(bom_detail[0]['is_active']) != 'Yes':
|
||||
msgprint("BOM := '%s' is not Active BOM." % self.doc.bom_no)
|
||||
raise Exception
|
||||
if flt(bom_detail[0]['docstatus']) != 1:
|
||||
msgprint("BOM := '%s' is not Submitted BOM." % self.doc.bom_no)
|
||||
raise Exception
|
||||
|
||||
def update_status(self, status):
|
||||
# Set Status
|
||||
if status == 'Stopped':
|
||||
set(self.doc, 'status', cstr(status))
|
||||
else:
|
||||
if flt(self.doc.qty) == flt(self.doc.produced_qty):
|
||||
set(self.doc, 'status', 'Completed')
|
||||
if flt(self.doc.qty) > flt(self.doc.produced_qty):
|
||||
set(self.doc, 'status', 'In Process')
|
||||
if flt(self.doc.produced_qty) == 0:
|
||||
set(self.doc, 'status', 'Submitted')
|
||||
|
||||
# Update Planned Qty of Production Item
|
||||
qty = (flt(self.doc.qty) - flt(self.doc.produced_qty)) * ((status == 'Stopped') and -1 or 1)
|
||||
get_obj('Warehouse', self.doc.fg_warehouse).update_bin(0, 0, 0, 0, flt(qty), self.doc.production_item, now())
|
||||
|
||||
# Acknowledge user
|
||||
msgprint(self.doc.doctype + ": " + self.doc.name + " has been %s and status has been updated as %s." % (cstr(status), cstr(self.doc.status)))
|
||||
|
||||
def on_submit(self):
|
||||
# Set Status AS "Submitted"
|
||||
set(self.doc,'status', 'Submitted')
|
||||
|
||||
# increase Planned Qty of Prooduction Item by Qty
|
||||
get_obj('Warehouse', self.doc.fg_warehouse).update_bin(0, 0, 0, 0,flt(self.doc.qty), self.doc.production_item, now())
|
||||
|
||||
|
||||
def on_cancel(self):
|
||||
# Stock Entries Against this Production Order
|
||||
st = sql("select name from `tabStock Entry` where production_order = '%s' and docstatus = 1" % cstr(self.doc.name))
|
||||
if st and st[0][0]:
|
||||
msgprint("Stock Entry "+ cstr(st[0][0]) + " has already been submitted.")
|
||||
raise Exception
|
||||
|
||||
# Set Status AS "Submitted"
|
||||
set(self.doc,'status', 'Cancelled')
|
||||
|
||||
# decrease Planned Qty of Prooduction Item by Qty
|
||||
get_obj('Warehouse', self.doc.fg_warehouse).update_bin(0, 0, 0, 0,-flt(self.doc.qty), self.doc.production_item, now())
|
||||
1
production/doctype/production_order/production_order.txt
Normal file
1
production/doctype/production_order/production_order.txt
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,45 @@
|
||||
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
|
||||
if(!doc.fiscal_year){ set_default_values(doc);}
|
||||
}
|
||||
|
||||
cur_frm.cscript.item_code = function(doc,cdt,cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
if (d.item_code) {
|
||||
temp = "{'item_code':'"+(d.item_code?d.item_code:'')+"'}";
|
||||
get_server_fields('get_item_details', temp, 'pp_details', doc, cdt, cdn, 1);
|
||||
}
|
||||
}
|
||||
|
||||
cur_frm.fields_dict['pp_details'].grid.get_field('item_code').get_query = function(doc) {
|
||||
return 'SELECT DISTINCT `tabItem`.`name`,`tabItem`.`item_name` FROM `tabItem` WHERE (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life`="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND tabItem.%(key)s like "%s" ORDER BY `tabItem`.`name` LIMIT 50';
|
||||
}
|
||||
|
||||
// Get Query for BOM NO
|
||||
//-------------------------------------------------------------------------------
|
||||
cur_frm.fields_dict['pp_details'].grid.get_field('bom_no').get_query = function(doc) {
|
||||
var d = locals[this.doctype][this.docname];
|
||||
return 'SELECT DISTINCT `tabBill Of Materials`.`name` FROM `tabBill Of Materials` WHERE `tabBill Of Materials`.`item` = "' + d.item_code + '" AND `tabBill Of Materials`.`is_active` = "Yes" AND `tabBill Of Materials`.`name` like "%s" ORDER BY `tabBill Of Materials`.`name` LIMIT 50';
|
||||
}
|
||||
|
||||
cur_frm.cscript['Clear Document Table'] = function(doc, cdt, cdn){
|
||||
$c('runserverobj', args={'method':'clear_table', 'arg': 'pp_so_details', 'docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
|
||||
cur_frm.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
cur_frm.cscript['Clear Item Table'] = function(doc, cdt, cdn){
|
||||
$c('runserverobj', args={'method':'clear_table', 'arg': 'pp_details', 'docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
|
||||
cur_frm.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
cur_frm.cscript['Download Raw Material Report'] = function(doc, cdt, cdn) {
|
||||
call_back = function(r, rt){
|
||||
if (r.message) {
|
||||
$c_obj_csv(make_doclist(cdt, cdn), 'get_raw_materials_report', '');
|
||||
}
|
||||
}
|
||||
$c('runserverobj', args = {'method':'validate_data','args':'','docs':compress_doclist(make_doclist(doc.doctype, doc.name))}, call_back)
|
||||
}
|
||||
@@ -0,0 +1,281 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
self.item_dict = {}
|
||||
self.defaults = get_defaults()
|
||||
|
||||
def get_item_details(self, args):
|
||||
args = eval(args)
|
||||
item = sql("select description, stock_uom, default_bom from `tabItem` where name = '%s' and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now())" % args['item_code'], as_dict =1 )
|
||||
if item:
|
||||
ret = {'description' : item and item[0]['description'],
|
||||
'stock_uom' : item and item[0]['stock_uom'],
|
||||
'bom_no' : item and item[0]['default_bom']
|
||||
}
|
||||
return cstr(ret)
|
||||
else:
|
||||
msgprint("Item %s does not exist in system." %(args['item_code']))
|
||||
raise Exception
|
||||
|
||||
def validate_data(self):
|
||||
for d in getlist(self.doclist, 'pp_details'):
|
||||
if not d.pro_created:
|
||||
|
||||
bom = sql("select name from `tabBill Of Materials` where item = %s and docstatus < 2", d.item_code, as_dict = 1)
|
||||
if d.bom_no and not bom:
|
||||
msgprint("There is no Active BOM for item code " + cstr(d.item_code) + " at row no." + cstr(d.idx)+ " which is Submitted. ")
|
||||
raise Exception
|
||||
if bom and bom[0]['name'] and not d.bom_no:
|
||||
msgprint("Please Enter BOM No. for item code " + cstr(d.item_code) + "at row no " + cstr(d.idx))
|
||||
raise Exception
|
||||
item = sql("select is_purchase_item from `tabItem` where name = %s", d.item_code,as_dict = 1)
|
||||
# if not item[0]['is_mrp_item']:
|
||||
# msgprint("Please Delete Row No " + cstr(d.idx) + " as Item " + cstr(d.item_code) + " is not MRP ITEM ")
|
||||
# raise Exception
|
||||
if not item[0]['is_purchase_item'] and not d.bom_no:
|
||||
msgprint("Please Delete Row No. "+ cstr(d.idx)+" as Item " + cstr(d.item_code) + " is not a PURCHASE ITEM ")
|
||||
raise Exception
|
||||
if not flt(d.planned_qty):
|
||||
msgprint("Please Enter Planned Qty for item code " + cstr(d.item_code) + "at row no " + cstr(d.idx))
|
||||
raise Exception
|
||||
if flt(d.prevdoc_reqd_qty) and flt(d.planned_qty) > flt(d.prevdoc_reqd_qty):
|
||||
msgprint(" Planned Qty cannot be greater than total Qty at row no " + cstr(d.idx))
|
||||
raise Exception
|
||||
|
||||
item = sql("select is_manufactured_item, is_sub_contracted_item from`tabItem` where name = %s", d.item_code, as_dict = 1)
|
||||
if not item:
|
||||
msgprint("Item %s is not present in Item Master." % d.item_code)
|
||||
raise Exception
|
||||
|
||||
if item[0]['is_manufactured_item'] == 'Yes' or item[0]['is_sub_contracted_item'] == 'Yes':
|
||||
bom = sql("select name, docstatus from `tabBill Of Materials` where item = %s", d.item_code, as_dict =1)
|
||||
if bom and bom[0]['name']:
|
||||
if not d.bom_no:
|
||||
msgprint("Please Enter BOM No for Item " + cstr(d.item_code) + " in Materials at Row No. " + cstr(d.idx) + " in BOM NO. " + self.doc.name)
|
||||
raise Exception
|
||||
else:
|
||||
match = 0
|
||||
for b in bom:
|
||||
if flt(b['docstatus']) > 1:
|
||||
msgprint("BOM %s is NOT SUBMITTED."% cstr(d.bom_no))
|
||||
raise Exception
|
||||
|
||||
match = 1
|
||||
if not match:
|
||||
msgprint("Item %s does not belong to Bill Of Material %s or Bill Of Material %s is NOT ACTIVE BOM." % (cstr(d.item_code),cstr(d.bom_no), cstr(d.bom_no)))
|
||||
raise Exception
|
||||
|
||||
if not item[0]['is_manufactured_item'] == 'Yes' and not item[0]['is_sub_contracted_item']== 'Yes':
|
||||
if d.bom_no:
|
||||
msgprint("As in Item Master of Item %s Is Manufactured Item / Is Sub-Contracted Item is not 'Yes' hence there should be no BOM." % d.item_code)
|
||||
raise Exception
|
||||
|
||||
return 1
|
||||
|
||||
def pull_document(self):
|
||||
if self.doc.sales_order:
|
||||
open_so = sql("select distinct 'Sales Order' as prevdoc, t1.name, ifnull(t1.transaction_date, ''), ifnull(t2.confirmation_date,'') from `tabSales Order` t1, `tabSales Order Detail` t2, `tabDelivery Note Packing Detail` t3 where ifnull(t3.planned_qty,0) < ifnull(t3.qty,0) and (t2.qty - ifnull(t2.delivered_qty,0)) > 0 and t3.parent_detail_docname = t2.name and t2.parent = t1.name and t1.docstatus = 1 and t1.name = '%s' order by t1.transaction_date" % self.doc.sales_order)
|
||||
self.add_open_documents(open_so)
|
||||
#if self.doc.production_forecast:
|
||||
#open_pf = sql("select distinct 'Production Forecast' as prevdoc, t1.name, ifnull(t1.transaction_date,''), ifnull(t1.forecast_due_date,'') from `tabProduction Forecast` t1, `tabPF Detail` t2 where t2.planned_qty < t2.qty and t2.parent = t1.name and t1.name = '%s' and t1.docstatus = 1 order by t1.forecast_due_date " % self.doc.production_forecast)
|
||||
#self.add_open_documents(open_pf)
|
||||
|
||||
def validate_duplicate_docname(self, check_data):
|
||||
for d in getlist(self.doclist, 'pp_so_details'):
|
||||
if [ d.prevdoc_docname, d.document_date, d.confirmation_date] == check_data :
|
||||
msgprint(cstr(d.prevdoc) + ": " + cstr(d.prevdoc_docname) + " appears more than once.")
|
||||
raise Exception
|
||||
|
||||
def add_open_documents(self, open_doc):
|
||||
for r in open_doc:
|
||||
self.validate_duplicate_docname([r[1], r[2], r[3]])
|
||||
pp_so = addchild(self.doc, 'pp_so_details', 'PP SO Detail', 1, self.doclist)
|
||||
pp_so.prevdoc = r[0]
|
||||
pp_so.prevdoc_docname = r[1]
|
||||
pp_so.document_date = cstr(r[2])
|
||||
pp_so.confirmation_date = cstr(r[3])
|
||||
pp_so.save()
|
||||
|
||||
def get_open_docs(self):
|
||||
# Step 1:=> Remove unwanted rows from PP SO DETAIL TABLE
|
||||
self.remove_unwanted_rows_from_table(check_field ='include_in_plan', table_fname='pp_so_details')
|
||||
|
||||
# Step 2:=> Check From Date should be before To Date
|
||||
if self.doc.from_date:
|
||||
if (getdate(self.doc.from_date) > getdate(self.doc.to_date)):
|
||||
msgprint("From Date cannot be after To Date")
|
||||
raise Exception
|
||||
|
||||
# Step 3:=> At Least to date should be there
|
||||
if not self.doc.to_date:
|
||||
msgprint("To Date is Mandatory.")
|
||||
raise Exception
|
||||
|
||||
# Step 4:=> GEt Open Sales ORder and Production Forecasts
|
||||
open_so = sql("select distinct 'Sales Order' as prevdoc, t1.name, t1.transaction_date, t2.confirmation_date from `tabSales Order` t1, `tabSales Order Detail` t2 where (t2.qty - ifnull(t2.delivered_qty,0)) > 0 and t2.parent = t1.name %s and t1.transaction_date <= '%s' and t1.docstatus = 1 order by t1.transaction_date" % ((self.doc.from_date and "and t1.transaction_date >= '%s' " % self.doc.from_date or '') , self.doc.to_date))
|
||||
#open_pf = sql("select distinct 'Production Forecast' as prevdoc, t1.name, t1.transaction_date, t1.forecast_due_date from `tabProduction Forecast` t1, `tabPF Detail` t2 where ifnull(t2.planned_qty,0) < ifnull(t2.qty,0) and t1.name = t2.parent %s and t1.forecast_due_date <= '%s' and t1.docstatus = 1 order by t1.forecast_due_date " % ( self.doc.from_date and "and t1.forecast_due_date >= '%s' " % self.doc.from_date or '', self.doc.to_date))
|
||||
#open_doc = open_so + open_pf
|
||||
open_doc = open_so
|
||||
self.add_open_documents(open_doc)
|
||||
|
||||
def remove_unwanted_rows_from_table(self, check_field, table_fname):
|
||||
for d in getlist(self.doclist, table_fname):
|
||||
if not d.fields[check_field]:
|
||||
d.fields['__oldparent'] = d.parent
|
||||
d.parent = 'old_parent:' + d.parent # for client to send it back while saving
|
||||
d.docstatus = 2
|
||||
if not d.fields.get('__islocal'):
|
||||
d.save()
|
||||
else:
|
||||
d.save()
|
||||
|
||||
def get_packing_list_items(self, sales_order):
|
||||
#sales_com_obj.make_packing_list(self,'sales_order_details')
|
||||
pack_l = sql("select t2.name, t2.parent_item, t2.item_code, t0.transaction_date, t1.confirmation_date,(t1.qty - ifnull(t1.delivered_qty,0)) * (ifnull(t2.qty,0) / ifnull(t1.qty,1)) as 'pending_qty' from `tabSales Order` t0, `tabSales Order Detail` t1, `tabDelivery Note Packing Detail` t2 where ifnull(t2.planned_qty,0) < ifnull(t2.qty,0) and (t1.qty - ifnull(t1.delivered_qty,0)) > 0 and t2.parent_detail_docname = t1.name and t0.name = t1.parent and t1.parent = '%s' and t2.parent = '%s' and t1.docstatus =1 and t2.docstatus = 1" % (sales_order, sales_order), as_dict =1)
|
||||
for p in pack_l:
|
||||
pi = addchild(self.doc, 'pp_details', 'PP Detail', 0, self.doclist)
|
||||
pi.source_doctype = 'Sales Order'
|
||||
pi.source_docname = sales_order
|
||||
pi.source_detail_docname = p['name']
|
||||
pi.parent_item = p['parent_item']
|
||||
pi.item_code = p['item_code']
|
||||
pi.document_date = cstr(p['transaction_date'])
|
||||
pi.confirmation_date = cstr(p['confirmation_date'])
|
||||
item_details = sql("select description, stock_uom from tabItem where name=%s and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' or end_of_life > now())", p['item_code'])
|
||||
pi.description = item_details and item_details[0][0] or ''
|
||||
pi.stock_uom = item_details and item_details[0][1] or ''
|
||||
pi.prevdoc_reqd_qty = flt(p['pending_qty'])
|
||||
pi.save()
|
||||
|
||||
def get_items(self):
|
||||
# Step 1:=> Remove unwanted rows from PP SO DETAIL TABLE
|
||||
self.remove_unwanted_rows_from_table(check_field ='include_in_plan', table_fname='pp_so_details')
|
||||
# Step 2:=> Remove unwanted rows from PP DETAIL TABLE
|
||||
self.doc.clear_table(self.doclist, 'pp_details', 1)
|
||||
# Step 3:=> Get All Details From Production Forecast and Sales Order which are marked Include In Plan in PP SO Detail
|
||||
for d in getlist(self.doclist, 'pp_so_details'):
|
||||
if d.include_in_plan:
|
||||
# Step 3.a :=> Get packing List items from sales order
|
||||
if d.prevdoc == 'Sales Order':
|
||||
self.get_packing_list_items(d.prevdoc_docname)
|
||||
# Step 3.b :=> Get Production Forecast items
|
||||
if d.prevdoc == 'Production Forecast':
|
||||
get_obj('DocType Mapper', 'Production Forecast-Production Planning Tool').dt_map('Production Forecast','Production Planning Tool', d.prevdoc_docname, self.doc, self.doclist, "[['Production Forecast','Production Planning Tool'],['PF Detail', 'PP Detail']]")
|
||||
|
||||
self.set_defaults_pp_detail()
|
||||
|
||||
def clear_table(self, table_name = ''):
|
||||
self.doc.clear_table(self.doclist, table_name, 1)
|
||||
|
||||
def set_defaults_pp_detail(self):
|
||||
for d in getlist(self.doclist,'pp_details'):
|
||||
if not d.mrp:
|
||||
# set default BOM
|
||||
if not d.bom_no:
|
||||
bom = sql("select default_bom from `tabItem` where name = %s and (ifnull(end_of_life,'')='' or end_of_life ='0000-00-00' or end_of_life > now())", d.item_code, as_dict = 1)
|
||||
if bom and bom[0]['default_bom']:
|
||||
d.bom_no = bom[0]['default_bom']
|
||||
# Set planned qty as prevdoc_reqd_qty
|
||||
d.planned_qty = flt(d.prevdoc_reqd_qty)
|
||||
d.save()
|
||||
|
||||
def make_items_dict(self, items_list):
|
||||
# items_list = [[item_name, qty]]
|
||||
for i in items_list:
|
||||
if self.item_dict.has_key(i[0]):
|
||||
self.item_dict[i[0]] = flt(self.item_dict[i[0]]) + flt(i[1])
|
||||
else:
|
||||
self.item_dict[i[0]] = flt(i[1])
|
||||
|
||||
def get_raw_materials(self, bom_dict):
|
||||
for bom in bom_dict:
|
||||
# get all purchase items
|
||||
if self.doc.consider_sa_items == 'No':
|
||||
fl_bom_items = sql("select item_code, ifnull(sum(qty_consumed_per_unit), 0) * '%s' from `tabFlat BOM Detail` where parent = '%s' and is_pro_applicable = 'No' and docstatus < 2 group by item_code" % (bom_dict[bom], bom))
|
||||
self.make_items_dict(fl_bom_items)
|
||||
|
||||
# get all purchase items without sa child_items
|
||||
if self.doc.consider_sa_items == 'Yes':
|
||||
fl_bom_sa_items = sql("select item_code, ifnull(sum(qty_consumed_per_unit), 0) * '%s' from `tabFlat BOM Detail` where parent = '%s' and parent_bom != '%s' and is_pro_applicable = 'Yes' and docstatus < 2 group by item_code" % (bom_dict[bom], bom, bom))
|
||||
self.make_items_dict(fl_bom_sa_items)
|
||||
fl_bom_items = sql("select item_code, ifnull(sum(qty_consumed_per_unit), 0) * '%s' from `tabFlat BOM Detail` where parent = '%s' and parent_bom not in (select distinct parent_bom from `tabFlat BOM Detail` where parent = '%s' and parent_bom != '%s' and is_pro_applicable = 'Yes' and docstatus <2) and docstatus < 2 and is_pro_applicable = 'No' group by item_code" % (bom_dict[bom], bom, bom, bom) )
|
||||
self.make_items_dict(fl_bom_items)
|
||||
|
||||
return self.item_dict
|
||||
|
||||
def send_csv(self, item_dict):
|
||||
item_list = [['Item Code', 'Description', 'Stock UOM','Required Qty', 'Indented Qty', 'Ordered Qty', 'Actual Qty', ]]
|
||||
for d in item_dict:
|
||||
item_detail = sql("select description, stock_uom from `tabItem` where name = '%s'" % d)
|
||||
item_qty= sql("select sum(indented_qty), sum(ordered_qty), sum(actual_qty) from `tabBin` where item_code = '%s' " % d)
|
||||
item_list.append([d, cstr(item_detail[0][0]), cstr(item_detail[0][1]), flt(item_dict[d]), item_qty and flt(item_qty[0][0]), item_qty and flt(item_qty[0][1]), item_qty and flt(item_qty[0][2])])
|
||||
return item_list
|
||||
|
||||
def get_raw_materials_report(self):
|
||||
#self.validate_data()
|
||||
bom_dict = self.check_criteria_for_same_items(check_for = 'Report')
|
||||
item_dict = self.get_raw_materials(bom_dict)
|
||||
#msgprint(item_dict)
|
||||
#raise Exception
|
||||
return self.send_csv(item_dict)
|
||||
|
||||
def raise_production_order(self):
|
||||
self.validate_data()
|
||||
pp_detail = self.check_criteria_for_same_items(check_for = 'Raise Production Order')
|
||||
pro = get_obj(dt = 'Production Control').create_production_order(self.doc.company, self.doc.fiscal_year, pp_detail = pp_detail)
|
||||
if len(pro) == 1:
|
||||
result = "Only Production Order " + cstr(pro[0]) + " has been generated."
|
||||
elif len(pro) > 1 :
|
||||
result = "Production Order From " + cstr(pro[0]) + " to " + cstr(pro[len(pro) - 1]) + " has been generated."
|
||||
else :
|
||||
result = " No Production Order is generated."
|
||||
msgprint(result)
|
||||
|
||||
def check_criteria_for_same_items(self, check_for):
|
||||
pro_lbl = {'production_item': 0, 'description': 1, 'qty' : 2, 'stock_uom' : 3, 'bom_no': 4, 'consider_sa_items': 5}
|
||||
pp_detail, appended, bom_dict = [], 0, {}
|
||||
for d in getlist(self.doclist, 'pp_details'):
|
||||
if check_for == 'Report':
|
||||
if d.bom_no:
|
||||
if bom_dict.has_key(d.bom_no):
|
||||
bom_dict[d.bom_no] = flt(bom_dict[d.bom_no]) + flt(d.planned_qty)
|
||||
else:
|
||||
bom_dict[d.bom_no] = flt(d.planned_qty)
|
||||
else:
|
||||
self.make_items_dict([[d.item_code, d.planned_qty]])
|
||||
|
||||
if check_for == 'Raise Production Order' and not d.pro_created:
|
||||
appended = 0
|
||||
if pp_detail:
|
||||
for i in pp_detail:
|
||||
# if same bom_no
|
||||
if d.bom_no and d.bom_no == i[pro_lbl['bom_no']]:
|
||||
# set appended , add qty
|
||||
appended, i[pro_lbl['qty']], d.pro_created = 1, i[pro_lbl['qty']] + flt(d.planned_qty) , 1
|
||||
|
||||
if not appended and d.bom_no:
|
||||
pp_detail.append([d.item_code, d.description, d.planned_qty, d.stock_uom, d.bom_no, self.doc.consider_sa_items])
|
||||
d.pro_created = 1
|
||||
|
||||
d.save()
|
||||
return (check_for =='Report') and bom_dict or pp_detail
|
||||
File diff suppressed because one or more lines are too long
0
production/doctype/update_delivery_date/__init__.py
Normal file
0
production/doctype/update_delivery_date/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
//get query select Territory
|
||||
//=======================================================================================================================
|
||||
cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
|
||||
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def get_open_sales_order(self):
|
||||
if not (self.doc.from_date and self.doc.to_date):
|
||||
msgprint("From Date and To Date are Mandatory")
|
||||
return
|
||||
|
||||
cond = ''
|
||||
if self.doc.customer:
|
||||
cond += " AND t1.customer = '%s' " % self.doc.customer
|
||||
if self.doc.sales_order:
|
||||
cond += " AND t1.name = '%s' " % self.doc.sales_order
|
||||
if self.doc.territory:
|
||||
cond += " AND t1.territory = '%s' " %self.doc.territory
|
||||
|
||||
dl = sql("select distinct t1.name, t1.customer, t1.delivery_date, t1.territory, t1.rounded_total from `tabSales Order` t1, `tabSales Order Detail` t2 where t1.transaction_date >= '%s' and t1.transaction_date <= '%s' and t1.docstatus=1 and t1.status != 'Completed' and t1.name = t2.parent and t2.docstatus =1 and t2.qty > t2.delivered_qty and (t2.confirmation_date is null or t2.confirmation_date= '' or t2.confirmation_date='0000-00-00') %s"% (self.doc.from_date, self.doc.to_date, cond))
|
||||
self.doc.clear_table(self.doclist, 'entries')
|
||||
count = 0
|
||||
for d in dl:
|
||||
nl = addchild(self.doc, 'entries', 'Update Delivery Date Detail', 1, self.doclist)
|
||||
nl.sales_order_no = str(d[0])
|
||||
nl.customer = str(d[1])
|
||||
nl.territory = str(d[3])
|
||||
nl.rounded_total = str(d[4])
|
||||
nl.delivery_date = str(d[2])
|
||||
count = count +1
|
||||
if not count:
|
||||
msgprint("No Sales Order found as per filters set.")
|
||||
|
||||
def update_sales_order(self):
|
||||
for d in getlist(self.doclist, 'entries'):
|
||||
if d.confirmation_date:
|
||||
sql("update `tabSales Order Detail` set confirmation_date = %s where parent = %s ", (d.confirmation_date, d.sales_order_no))
|
||||
msgprint("Updated")
|
||||
640
production/doctype/update_delivery_date/update_delivery_date.txt
Normal file
640
production/doctype/update_delivery_date/update_delivery_date.txt
Normal file
@@ -0,0 +1,640 @@
|
||||
[
|
||||
{
|
||||
'_last_update': '1300960466',
|
||||
'allow_attach': None,
|
||||
'allow_copy': None,
|
||||
'allow_email': None,
|
||||
'allow_print': None,
|
||||
'allow_rename': None,
|
||||
'allow_trash': None,
|
||||
'autoname': None,
|
||||
'change_log': None,
|
||||
'client_script': None,
|
||||
'client_script_core': None,
|
||||
'client_string': None,
|
||||
'colour': 'White:FFF',
|
||||
'creation': '2010-11-30 22:42:48',
|
||||
'description': None,
|
||||
'docstatus': 0,
|
||||
'doctype': 'DocType',
|
||||
'document_type': None,
|
||||
'dt_template': None,
|
||||
'hide_heading': None,
|
||||
'hide_toolbar': None,
|
||||
'idx': None,
|
||||
'in_create': None,
|
||||
'in_dialog': None,
|
||||
'is_transaction_doc': None,
|
||||
'issingle': 1,
|
||||
'istable': None,
|
||||
'last_update': '1294161010',
|
||||
'max_attachments': None,
|
||||
'menu_index': None,
|
||||
'modified': '2010-09-20 14:06:57',
|
||||
'modified_by': 'Administrator',
|
||||
'module': 'Production',
|
||||
'name': 'Update Delivery Date',
|
||||
'name_case': None,
|
||||
'owner': 'Administrator',
|
||||
'parent': None,
|
||||
'parent_node': None,
|
||||
'parentfield': None,
|
||||
'parenttype': None,
|
||||
'print_outline': None,
|
||||
'read_only': None,
|
||||
'read_only_onload': None,
|
||||
'search_fields': None,
|
||||
'section_style': 'Simple',
|
||||
'server_code': None,
|
||||
'server_code_compiled': None,
|
||||
'server_code_core': None,
|
||||
'server_code_error': ' ',
|
||||
'show_in_menu': None,
|
||||
'smallicon': None,
|
||||
'use_template': None,
|
||||
'version': 6
|
||||
},
|
||||
{
|
||||
'allow_on_submit': None,
|
||||
'colour': None,
|
||||
'creation': '2010-11-30 17:30:33',
|
||||
'default': None,
|
||||
'depends_on': None,
|
||||
'description': None,
|
||||
'docstatus': 0,
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'from_date',
|
||||
'fieldtype': 'Date',
|
||||
'hidden': None,
|
||||
'icon': None,
|
||||
'idx': 1,
|
||||
'in_filter': None,
|
||||
'label': 'From Date',
|
||||
'modified': '2011-03-24 15:58:11',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'FL00655',
|
||||
'no_copy': None,
|
||||
'oldfieldname': None,
|
||||
'oldfieldtype': None,
|
||||
'options': None,
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Update Delivery Date',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'print_hide': None,
|
||||
'report_hide': None,
|
||||
'reqd': 1,
|
||||
'search_index': None,
|
||||
'trigger': None,
|
||||
'width': None
|
||||
},
|
||||
{
|
||||
'allow_on_submit': None,
|
||||
'colour': None,
|
||||
'creation': '2010-11-30 22:42:48',
|
||||
'default': None,
|
||||
'depends_on': None,
|
||||
'description': None,
|
||||
'docstatus': 0,
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'from_date',
|
||||
'fieldtype': 'Date',
|
||||
'hidden': None,
|
||||
'icon': None,
|
||||
'idx': 1,
|
||||
'in_filter': None,
|
||||
'label': 'From Date',
|
||||
'modified': '2010-11-30 22:42:48',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'FL02950',
|
||||
'no_copy': None,
|
||||
'oldfieldname': None,
|
||||
'oldfieldtype': None,
|
||||
'options': None,
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Update Delivery Date',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'print_hide': None,
|
||||
'report_hide': None,
|
||||
'reqd': 1,
|
||||
'search_index': None,
|
||||
'trigger': None,
|
||||
'width': None
|
||||
},
|
||||
{
|
||||
'allow_on_submit': None,
|
||||
'colour': None,
|
||||
'creation': '2010-11-30 17:30:33',
|
||||
'default': None,
|
||||
'depends_on': None,
|
||||
'description': None,
|
||||
'docstatus': 0,
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'to_date',
|
||||
'fieldtype': 'Date',
|
||||
'hidden': None,
|
||||
'icon': None,
|
||||
'idx': 2,
|
||||
'in_filter': None,
|
||||
'label': 'To Date',
|
||||
'modified': '2011-03-24 15:58:11',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'FL00656',
|
||||
'no_copy': None,
|
||||
'oldfieldname': None,
|
||||
'oldfieldtype': None,
|
||||
'options': None,
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Update Delivery Date',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'print_hide': None,
|
||||
'report_hide': None,
|
||||
'reqd': 1,
|
||||
'search_index': None,
|
||||
'trigger': None,
|
||||
'width': None
|
||||
},
|
||||
{
|
||||
'allow_on_submit': None,
|
||||
'colour': None,
|
||||
'creation': '2010-11-30 22:42:48',
|
||||
'default': None,
|
||||
'depends_on': None,
|
||||
'description': None,
|
||||
'docstatus': 0,
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'to_date',
|
||||
'fieldtype': 'Date',
|
||||
'hidden': None,
|
||||
'icon': None,
|
||||
'idx': 2,
|
||||
'in_filter': None,
|
||||
'label': 'To Date',
|
||||
'modified': '2010-11-30 22:42:48',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'FL02951',
|
||||
'no_copy': None,
|
||||
'oldfieldname': None,
|
||||
'oldfieldtype': None,
|
||||
'options': None,
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Update Delivery Date',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'print_hide': None,
|
||||
'report_hide': None,
|
||||
'reqd': 1,
|
||||
'search_index': None,
|
||||
'trigger': None,
|
||||
'width': None
|
||||
},
|
||||
{
|
||||
'allow_on_submit': None,
|
||||
'colour': None,
|
||||
'creation': '2010-11-30 17:30:40',
|
||||
'default': None,
|
||||
'depends_on': None,
|
||||
'description': None,
|
||||
'docstatus': 0,
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'customer',
|
||||
'fieldtype': 'Link',
|
||||
'hidden': None,
|
||||
'icon': None,
|
||||
'idx': 3,
|
||||
'in_filter': None,
|
||||
'label': 'Customer',
|
||||
'modified': '2011-03-24 15:58:11',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'FL00887',
|
||||
'no_copy': None,
|
||||
'oldfieldname': None,
|
||||
'oldfieldtype': None,
|
||||
'options': 'Customer',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Update Delivery Date',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'print_hide': None,
|
||||
'report_hide': None,
|
||||
'reqd': None,
|
||||
'search_index': None,
|
||||
'trigger': None,
|
||||
'width': None
|
||||
},
|
||||
{
|
||||
'allow_on_submit': None,
|
||||
'colour': None,
|
||||
'creation': '2010-11-30 22:42:48',
|
||||
'default': None,
|
||||
'depends_on': None,
|
||||
'description': None,
|
||||
'docstatus': 0,
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'customer',
|
||||
'fieldtype': 'Link',
|
||||
'hidden': None,
|
||||
'icon': None,
|
||||
'idx': 3,
|
||||
'in_filter': None,
|
||||
'label': 'Customer',
|
||||
'modified': '2010-11-30 22:42:48',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'FL02952',
|
||||
'no_copy': None,
|
||||
'oldfieldname': None,
|
||||
'oldfieldtype': None,
|
||||
'options': 'Customer',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Update Delivery Date',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'print_hide': None,
|
||||
'report_hide': None,
|
||||
'reqd': None,
|
||||
'search_index': None,
|
||||
'trigger': None,
|
||||
'width': None
|
||||
},
|
||||
{
|
||||
'allow_on_submit': None,
|
||||
'colour': None,
|
||||
'creation': '2010-11-30 17:30:42',
|
||||
'default': None,
|
||||
'depends_on': None,
|
||||
'description': None,
|
||||
'docstatus': 0,
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'sales_order',
|
||||
'fieldtype': 'Link',
|
||||
'hidden': None,
|
||||
'icon': None,
|
||||
'idx': 4,
|
||||
'in_filter': None,
|
||||
'label': 'Sales Order',
|
||||
'modified': '2011-03-24 15:58:11',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'FL00977',
|
||||
'no_copy': None,
|
||||
'oldfieldname': None,
|
||||
'oldfieldtype': None,
|
||||
'options': 'Sales Order',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Update Delivery Date',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'print_hide': None,
|
||||
'report_hide': None,
|
||||
'reqd': None,
|
||||
'search_index': None,
|
||||
'trigger': None,
|
||||
'width': None
|
||||
},
|
||||
{
|
||||
'allow_on_submit': None,
|
||||
'colour': None,
|
||||
'creation': '2010-11-30 22:42:48',
|
||||
'default': None,
|
||||
'depends_on': None,
|
||||
'description': None,
|
||||
'docstatus': 0,
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'sales_order',
|
||||
'fieldtype': 'Link',
|
||||
'hidden': None,
|
||||
'icon': None,
|
||||
'idx': 4,
|
||||
'in_filter': None,
|
||||
'label': 'Sales Order',
|
||||
'modified': '2010-11-30 22:42:48',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'FL02953',
|
||||
'no_copy': None,
|
||||
'oldfieldname': None,
|
||||
'oldfieldtype': None,
|
||||
'options': 'Sales Order',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Update Delivery Date',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'print_hide': None,
|
||||
'report_hide': None,
|
||||
'reqd': None,
|
||||
'search_index': None,
|
||||
'trigger': None,
|
||||
'width': None
|
||||
},
|
||||
{
|
||||
'allow_on_submit': None,
|
||||
'colour': None,
|
||||
'creation': '2010-11-30 22:42:48',
|
||||
'default': None,
|
||||
'depends_on': None,
|
||||
'description': None,
|
||||
'docstatus': 0,
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'company',
|
||||
'fieldtype': 'Select',
|
||||
'hidden': None,
|
||||
'icon': None,
|
||||
'idx': 5,
|
||||
'in_filter': None,
|
||||
'label': 'Company',
|
||||
'modified': '2010-11-30 22:42:48',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'FL02954',
|
||||
'no_copy': None,
|
||||
'oldfieldname': None,
|
||||
'oldfieldtype': None,
|
||||
'options': 'link:Company',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Update Delivery Date',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'print_hide': None,
|
||||
'report_hide': None,
|
||||
'reqd': None,
|
||||
'search_index': None,
|
||||
'trigger': None,
|
||||
'width': None
|
||||
},
|
||||
{
|
||||
'allow_on_submit': None,
|
||||
'colour': None,
|
||||
'creation': '2011-03-23 11:02:21',
|
||||
'default': None,
|
||||
'depends_on': None,
|
||||
'description': None,
|
||||
'docstatus': 0,
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'company',
|
||||
'fieldtype': 'Select',
|
||||
'hidden': None,
|
||||
'icon': None,
|
||||
'idx': 5,
|
||||
'in_filter': None,
|
||||
'label': 'Company',
|
||||
'modified': '2011-03-24 15:58:11',
|
||||
'modified_by': 'Administrator',
|
||||
'name': '000002690',
|
||||
'no_copy': None,
|
||||
'oldfieldname': None,
|
||||
'oldfieldtype': None,
|
||||
'options': 'link:Company',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Update Delivery Date',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'print_hide': None,
|
||||
'report_hide': None,
|
||||
'reqd': None,
|
||||
'search_index': None,
|
||||
'trigger': None,
|
||||
'width': None
|
||||
},
|
||||
{
|
||||
'allow_on_submit': None,
|
||||
'colour': None,
|
||||
'creation': '2010-11-30 17:30:40',
|
||||
'default': None,
|
||||
'depends_on': None,
|
||||
'description': None,
|
||||
'docstatus': 0,
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'territory',
|
||||
'fieldtype': 'Link',
|
||||
'hidden': None,
|
||||
'icon': None,
|
||||
'idx': 6,
|
||||
'in_filter': None,
|
||||
'label': 'Territory',
|
||||
'modified': '2011-03-24 15:58:11',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'FL00890',
|
||||
'no_copy': None,
|
||||
'oldfieldname': None,
|
||||
'oldfieldtype': None,
|
||||
'options': 'Territory',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Update Delivery Date',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': None,
|
||||
'reqd': None,
|
||||
'search_index': None,
|
||||
'trigger': None,
|
||||
'width': None
|
||||
},
|
||||
{
|
||||
'allow_on_submit': None,
|
||||
'colour': None,
|
||||
'creation': '2010-11-30 22:42:48',
|
||||
'default': None,
|
||||
'depends_on': None,
|
||||
'description': None,
|
||||
'docstatus': 0,
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'territory',
|
||||
'fieldtype': 'Link',
|
||||
'hidden': None,
|
||||
'icon': None,
|
||||
'idx': 6,
|
||||
'in_filter': None,
|
||||
'label': 'Territory',
|
||||
'modified': '2010-11-30 22:42:48',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'FL02955',
|
||||
'no_copy': None,
|
||||
'oldfieldname': None,
|
||||
'oldfieldtype': None,
|
||||
'options': 'Territory',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Update Delivery Date',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'print_hide': 1,
|
||||
'report_hide': None,
|
||||
'reqd': None,
|
||||
'search_index': None,
|
||||
'trigger': None,
|
||||
'width': None
|
||||
},
|
||||
{
|
||||
'allow_on_submit': None,
|
||||
'colour': None,
|
||||
'creation': '2010-11-30 22:42:48',
|
||||
'default': None,
|
||||
'depends_on': None,
|
||||
'description': None,
|
||||
'docstatus': 0,
|
||||
'doctype': 'DocField',
|
||||
'fieldname': None,
|
||||
'fieldtype': 'Button',
|
||||
'hidden': None,
|
||||
'icon': None,
|
||||
'idx': 7,
|
||||
'in_filter': None,
|
||||
'label': 'Get Open Sales Order',
|
||||
'modified': '2011-03-24 15:58:11',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'FL02956',
|
||||
'no_copy': None,
|
||||
'oldfieldname': None,
|
||||
'oldfieldtype': None,
|
||||
'options': 'get_open_sales_order',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Update Delivery Date',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'print_hide': None,
|
||||
'report_hide': None,
|
||||
'reqd': None,
|
||||
'search_index': None,
|
||||
'trigger': None,
|
||||
'width': None
|
||||
},
|
||||
{
|
||||
'allow_on_submit': None,
|
||||
'colour': None,
|
||||
'creation': '2010-11-30 17:30:33',
|
||||
'default': 'No Toolbar',
|
||||
'depends_on': None,
|
||||
'description': None,
|
||||
'docstatus': 0,
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'entries',
|
||||
'fieldtype': 'Table',
|
||||
'hidden': None,
|
||||
'icon': None,
|
||||
'idx': 8,
|
||||
'in_filter': None,
|
||||
'label': 'Entries',
|
||||
'modified': '2011-03-24 15:58:11',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'FL00658',
|
||||
'no_copy': None,
|
||||
'oldfieldname': None,
|
||||
'oldfieldtype': None,
|
||||
'options': 'Update Delivery Date Detail',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Update Delivery Date',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'print_hide': None,
|
||||
'report_hide': None,
|
||||
'reqd': None,
|
||||
'search_index': None,
|
||||
'trigger': None,
|
||||
'width': None
|
||||
},
|
||||
{
|
||||
'allow_on_submit': None,
|
||||
'colour': None,
|
||||
'creation': '2010-11-30 22:42:48',
|
||||
'default': 'No Toolbar',
|
||||
'depends_on': None,
|
||||
'description': None,
|
||||
'docstatus': 0,
|
||||
'doctype': 'DocField',
|
||||
'fieldname': 'entries',
|
||||
'fieldtype': 'Table',
|
||||
'hidden': None,
|
||||
'icon': None,
|
||||
'idx': 8,
|
||||
'in_filter': None,
|
||||
'label': 'Entries',
|
||||
'modified': '2010-11-30 22:42:48',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'FL02957',
|
||||
'no_copy': None,
|
||||
'oldfieldname': None,
|
||||
'oldfieldtype': None,
|
||||
'options': 'Update Delivery Date Detail',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Update Delivery Date',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'print_hide': None,
|
||||
'report_hide': None,
|
||||
'reqd': None,
|
||||
'search_index': None,
|
||||
'trigger': None,
|
||||
'width': ''
|
||||
},
|
||||
{
|
||||
'allow_on_submit': None,
|
||||
'colour': None,
|
||||
'creation': '2010-11-30 22:42:48',
|
||||
'default': None,
|
||||
'depends_on': None,
|
||||
'description': None,
|
||||
'docstatus': 0,
|
||||
'doctype': 'DocField',
|
||||
'fieldname': None,
|
||||
'fieldtype': 'Button',
|
||||
'hidden': None,
|
||||
'icon': None,
|
||||
'idx': 9,
|
||||
'in_filter': None,
|
||||
'label': 'Update Sales Order',
|
||||
'modified': '2011-03-24 15:58:11',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'FL02958',
|
||||
'no_copy': None,
|
||||
'oldfieldname': None,
|
||||
'oldfieldtype': None,
|
||||
'options': 'update_sales_order',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Update Delivery Date',
|
||||
'parentfield': 'fields',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'print_hide': None,
|
||||
'report_hide': None,
|
||||
'reqd': None,
|
||||
'search_index': None,
|
||||
'trigger': None,
|
||||
'width': None
|
||||
},
|
||||
{
|
||||
'amend': None,
|
||||
'cancel': None,
|
||||
'create': 1,
|
||||
'creation': '2010-11-30 22:42:48',
|
||||
'docstatus': 0,
|
||||
'doctype': 'DocPerm',
|
||||
'execute': None,
|
||||
'idx': 1,
|
||||
'match': None,
|
||||
'modified': '2010-11-30 22:42:48',
|
||||
'modified_by': 'Administrator',
|
||||
'name': 'PERM00482',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'parent': 'Update Delivery Date',
|
||||
'parentfield': 'permissions',
|
||||
'parenttype': 'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'role': 'Administrator',
|
||||
'submit': None,
|
||||
'write': 1
|
||||
}
|
||||
]
|
||||
File diff suppressed because one or more lines are too long
0
production/doctype/workstation/__init__.py
Normal file
0
production/doctype/workstation/__init__.py
Normal file
10
production/doctype/workstation/workstation.js
Normal file
10
production/doctype/workstation/workstation.js
Normal file
@@ -0,0 +1,10 @@
|
||||
$import(Tips Common)
|
||||
|
||||
//--------- ONLOAD -------------
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.get_tips(doc, cdt, cdn);
|
||||
}
|
||||
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.get_tips(doc, cdt, cdn);
|
||||
}
|
||||
33
production/doctype/workstation/workstation.py
Normal file
33
production/doctype/workstation/workstation.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# Please edit this list and import only required elements
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
|
||||
from webnotes.model import db_exists
|
||||
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
|
||||
from webnotes.model.doclist import getlist, copy_doclist
|
||||
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
|
||||
from webnotes import session, form, is_testing, msgprint, errprint
|
||||
|
||||
set = webnotes.conn.set
|
||||
sql = webnotes.conn.sql
|
||||
get_value = webnotes.conn.get_value
|
||||
in_transaction = webnotes.conn.in_transaction
|
||||
convert_to_lists = webnotes.conn.convert_to_lists
|
||||
|
||||
# -----------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DocType:
|
||||
def __init__(self, doc, doclist=[]):
|
||||
self.doc = doc
|
||||
self.doclist = doclist
|
||||
|
||||
def update_bom_operation(self):
|
||||
bom_list = sql(" select DISTINCT parent from `tabBOM Operation` where workstation = '%s'" % self.doc.name)
|
||||
for bom_no in bom_list:
|
||||
sql("update `tabBOM Operation` set hour_rate = '%s' where parent = '%s' and workstation = '%s'"%( self.doc.hour_rate, bom_no, self.doc.name))
|
||||
|
||||
def on_update(self):
|
||||
set(self.doc, 'overhead', flt(self.doc.hour_rate_electricity) + flt(self.doc.hour_rate_consumable) + flt(self.doc.hour_rate_rent))
|
||||
set(self.doc, 'hour_rate', flt(self.doc.hour_rate_labour) + flt(self.doc.overhead))
|
||||
self.update_bom_operation()
|
||||
1
production/doctype/workstation/workstation.txt
Normal file
1
production/doctype/workstation/workstation.txt
Normal file
File diff suppressed because one or more lines are too long
0
production/page/__init__.py
Normal file
0
production/page/__init__.py
Normal file
0
production/page/bill_of_materials/__init__.py
Normal file
0
production/page/bill_of_materials/__init__.py
Normal file
44
production/page/bill_of_materials/bill_of_materials.html
Normal file
44
production/page/bill_of_materials/bill_of_materials.html
Normal file
@@ -0,0 +1,44 @@
|
||||
<div style="margin:0px">
|
||||
<div id="bom_header"> </div>
|
||||
<!--
|
||||
<div style="color: #444444;" mce_style="color: #444444;">
|
||||
<table style="width: 100%;" border="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="standard_title" style="width: 70%;">Bill of Materials</td>
|
||||
<td style="width: 30%; text-align: right; vertical-align: top;"><span class="link_type" style="vertical-align:top" mce_style="vertical-align:top"> <img style="cursor:pointer" mce_style="cursor:pointer" onclick="nav_obj.show_last_open()" src="images/ui/close_btn.gif" mce_src="images/ui/close_btn.gif" alt="" /> </span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
--> <!-- table.coa_toolbar td { vertical-align: middle; } --> <!--
|
||||
<div style="margin-top: 16px; padding: 4px; background-color: #EEE; border: 1px solid #AAA;" mce_style="margin-top: 16px; padding: 4px; background-color: #EEE; border: 1px solid #AAA;">
|
||||
<table class="coa_toolbar" border="0" cellspacing="2px">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Item Group:</td>
|
||||
<td style="padding-right: 8px;" mce_style="padding-right: 8px;"><select id="bom_item_group"></select></td>
|
||||
<td>Enter Item Code:</td>
|
||||
<td style="padding-right: 8px;" mce_style="padding-right: 8px;"><select id="bom_item_code"></select></td>
|
||||
<td>Enter BOM No:</td>
|
||||
<td style="padding-right: 8px;" mce_style="padding-right: 8px;"><select id="bom_bom_no"></select></td>
|
||||
<td>
|
||||
<div id="bom_refresh"></div>
|
||||
</td>
|
||||
<td>
|
||||
<div id="bom_calculate_cost"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
--> <!--
|
||||
<div style="margin: 0px 16px 16px; overflow: auto; padding-top: 4px; height: 300px;">-->
|
||||
<div style="overflow: auto; margin-top: 8px; padding-top: 4px; height: 300px;">
|
||||
<div style="width: 900px;">
|
||||
<div id="bom_head_op" style="display: none;"></div>
|
||||
<div id="bom_head_it" style="display: none; border-bottom: 2px solid #444;"></div>
|
||||
<div id="bom_tree"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
508
production/page/bill_of_materials/bill_of_materials.js
Normal file
508
production/page/bill_of_materials/bill_of_materials.js
Normal file
@@ -0,0 +1,508 @@
|
||||
pscript['onload_Bill of Materials'] = function() {
|
||||
|
||||
// header and toolbar
|
||||
var h = new PageHeader('bom_header','Bill of Materials','BOM gives the breakdown of cost for product');
|
||||
|
||||
var dv = $a(h.toolbar_area,'div','',{margin:'4px 0px'});
|
||||
|
||||
var tbl = make_table(dv, 1,3,'480px',[],{padding:'4px', width:'160px'});
|
||||
|
||||
var sel = $a($td(tbl,0,0),'select','',{width:'160px'});
|
||||
sel.id = 'bom_item_group';
|
||||
|
||||
var sel = $a($td(tbl,0,1),'select','',{width:'160px'});
|
||||
sel.id = 'bom_item_code'; sel.innerHTML = 'Select Item Code...'; sel.disabled = 1;
|
||||
|
||||
var sel = $a($td(tbl,0,2),'select','',{width:'160px'});
|
||||
sel.id = 'bom_bom_no'; sel.innerHTML = 'Select Bom No...'; sel.disabled = 1;
|
||||
|
||||
h.add_button('Calculate Cost', function(){ pscript.bom_calculate_cost(pscript.bom_no); },1,'ui-icon-calculator');
|
||||
h.add_button('Refresh', function(){ pscript.bom_refresh(); },0,'ui-icon-refresh');
|
||||
h.add_button('Collapse All', function(){pscript.collapse_all();},0,'');
|
||||
|
||||
// select for Item Group
|
||||
//$i('bom_item_group').style.width = '180px';
|
||||
// $i('bom_item_code').style.width = '110px';
|
||||
// $i('bom_bom_no').style.width = '150px';
|
||||
$i('bom_tree').innerHTML = 'Please Select Item Group';
|
||||
add_sel_options($i('bom_item_group'), ['Loading ... ']);
|
||||
|
||||
$c('runserverobj', args={'doctype':'BOM Control', 'docname':'BOM Control', 'method':'get_item_group'}, function(r,rt) {
|
||||
pscript.item_group = r.message.split('~~~');
|
||||
empty_select($i('bom_item_group'));
|
||||
// add_sel_options($i('bom_item_group'), add_lists([' '], pscript.item_group), ' ');
|
||||
add_sel_options($i('bom_item_group'), add_lists(['Select Item Group...'], pscript.item_group), 'Select Item Group...');
|
||||
$i('bom_item_group').onchange = function() {
|
||||
|
||||
//$i('bom_item_code').innerHTML = '';
|
||||
// $i('bom_bom_no').innerHTML = '';
|
||||
$i('bom_head_op').innerHTML = '';
|
||||
$i('bom_head_it').innerHTML = '';
|
||||
$i('bom_tree').innerHTML = 'Please Select Item Code';
|
||||
pscript.bom_select_item_code(sel_val(this));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
pscript.bom_select_item_code = function(item_group) {
|
||||
|
||||
//select for Item Code
|
||||
|
||||
add_sel_options($i('bom_item_code'), ['Loading ... ']);
|
||||
|
||||
$c('runserverobj', args={'doctype':'BOM Control', 'docname':'BOM Control', 'method':'get_item_code', 'arg':item_group}, function(r,rt) {
|
||||
pscript.item_code = r.message.split('~~~');
|
||||
empty_select($i('bom_item_code'));
|
||||
add_sel_options($i('bom_item_code'), add_lists(['Select Item Code...'], pscript.item_code), 'Select Item Code...');
|
||||
if(sel_val($i('bom_item_code')) == 'Select Item Group...'){
|
||||
$i('bom_item_code').disabled = 1;
|
||||
$i('bom_bom_no').disabled = 1;
|
||||
}
|
||||
else{ $i('bom_item_code').disabled = 0; }
|
||||
|
||||
$i('bom_item_code').onchange = function() {
|
||||
// $i('bom_bom_no').innerHTML = '';
|
||||
$i('bom_head_op').innerHTML = '';
|
||||
$i('bom_head_it').innerHTML = '';
|
||||
$i('bom_tree').innerHTML = 'Please Select BOM NO.';
|
||||
pscript.bom_select_bom_no(sel_val(this));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
pscript.bom_select_bom_no = function(item_code) {
|
||||
|
||||
//select for BOM NO
|
||||
|
||||
add_sel_options($i('bom_bom_no'), ['Loading ... ']);
|
||||
|
||||
$c('runserverobj', args={'doctype':'BOM Control', 'docname':'BOM Control', 'method':'get_bom_no', 'arg':item_code}, function(r,rt) {
|
||||
var bom_list = r.message.split('~~~');
|
||||
empty_select($i('bom_bom_no'));
|
||||
empty_select($i('bom_bom_no'));
|
||||
add_sel_options($i('bom_bom_no'), add_lists(['Select Bom No...'], bom_list), 'Select Bom No...');
|
||||
if(sel_val($i('bom_item_code')) == 'Select Item Code...'){
|
||||
$i('bom_bom_no').disabled = 1;
|
||||
}
|
||||
else{
|
||||
$i('bom_bom_no').disabled = 0;
|
||||
}
|
||||
|
||||
$i('bom_bom_no').onchange = function() {
|
||||
$i('bom_head_op').innerHTML = '';
|
||||
$i('bom_head_it').innerHTML = '';
|
||||
$i('bom_tree').innerHTML = 'Loading...';
|
||||
pscript.show_bom(); }
|
||||
});
|
||||
}
|
||||
|
||||
// Refresh Function
|
||||
pscript.bom_refresh = function() {
|
||||
$i('bom_head_op').innerHTML = '';
|
||||
$i('bom_head_it').innerHTML = '';
|
||||
$i('bom_tree').innerHTML = 'Refreshing....';
|
||||
pscript.show_bom();
|
||||
}
|
||||
|
||||
//Calculate Cost Function
|
||||
pscript.bom_calculate_cost = function() {
|
||||
$i('bom_head_op').innerHTML = '';
|
||||
$i('bom_head_it').innerHTML = '';
|
||||
$i('bom_tree').innerHTML = ' Calculating Cost...';
|
||||
$c('runserverobj', args={'doctype':'BOM Control', 'docname':'BOM Control', 'method':'calculate_cost', 'arg':pscript.bom_no}, function(r,rt) {
|
||||
var calculated = r.message;
|
||||
if (calculated == 'calculated') {pscript.show_bom();}
|
||||
else {$i('bom_tree').innerHTML = "Sorry it's taking too long try next time....";}
|
||||
});
|
||||
}
|
||||
|
||||
pscript.collapse_all = function(){
|
||||
alert("In");
|
||||
pscript.bom_tree.collapseall()
|
||||
}
|
||||
|
||||
pscript.show_bom = function () {
|
||||
pscript.item_code = $i('bom_item_code').value;
|
||||
pscript.bom_no = $i('bom_bom_no').value;
|
||||
// $i('bom_refresh').innerHTML = '';
|
||||
//$i('bom_refresh').innerHTML = "<input type='button' value='Refresh' onClick='javascript:pscript.bom_refresh()' />";
|
||||
//$i('bom_calculate_cost').innerHTML = "<input type='button' value='Calculate Cost' onClick='javascript:pscript.bom_calculate_cost(pscript.bom_no)' />";
|
||||
if (pscript.item_code == "") {
|
||||
alert("Please Enter Item Code");
|
||||
return;
|
||||
}
|
||||
if (pscript.bom_no == "") {
|
||||
alert("Please Enter BOM No");
|
||||
return;
|
||||
}
|
||||
$ds('bom_head_op');
|
||||
$ds('bom_head_it');
|
||||
$ds('bom_tree');
|
||||
pscript.bom_onexp = function(node) {
|
||||
//alert("Server Call")
|
||||
if(!node.expanded_once) {
|
||||
$ds(node.loading_div);
|
||||
if (!node.is_item){
|
||||
// We will get List Of Items and BOM for particular Operation
|
||||
data = "{'op_no':'" + node.text[1] +"','bom_no':'" + node.text[3] +"'}";
|
||||
$c('runserverobj', args={'doctype':'BOM Control', 'docname':'BOM Control', 'method':'get_item_bom', 'arg':data},
|
||||
function(r,rt) {
|
||||
$dh(node.loading_div);
|
||||
var nl = r.message;
|
||||
for(var i=0; i<nl.length; i++) {
|
||||
if (nl[i][8] == 1) {
|
||||
pscript.bom_tree.addNode(node,$i('bom_head_op'), nl[i], 'images/icons/box.png', null, null);
|
||||
}
|
||||
else {
|
||||
pscript.bom_tree.addNode(node,$i('bom_head_op'), nl[i], 'images/icons/package.png', null, pscript.bom_onexp);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
//alert("bom_no:%s"%node.text[2])
|
||||
//We will get List Of Operations for particular Item and BOM
|
||||
$c('runserverobj', args={'doctype':'BOM Control', 'docname':'BOM Control', 'method':'get_operations', 'arg':node.text[3]},
|
||||
function(r,rt) {
|
||||
$dh(node.loading_div);
|
||||
var nl = r.message;
|
||||
for(var i=0; i<nl.length; i++) {
|
||||
pscript.bom_tree.addNode(node, $i('bom_head_op'), nl[i], 'images/icons/folder.png', null, pscript.bom_onexp);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
// First this function will execute and we will get list of operations
|
||||
$c('runserverobj', args={'doctype':'BOM Control', 'docname':'BOM Control', 'method':'get_operations', 'arg':pscript.bom_no}, function(r,rt) {
|
||||
var nl = r.message;
|
||||
|
||||
$i('bom_tree').innerHTML = '';
|
||||
var t = new Tree($i('bom_tree'),$i('bom_head_op'),$i('bom_head_it'));
|
||||
|
||||
pscript.bom_tree = t;
|
||||
pscript.bom_curnode = null;
|
||||
|
||||
for(var i=0; i<nl.length; i++) {
|
||||
t.addNode(null, $i('bom_head_op'), nl[i], 'images/icons/folder.png', null, pscript.bom_onexp);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Tree
|
||||
//
|
||||
|
||||
function Tree(parent,head_op,head_it) {
|
||||
this.container = parent;
|
||||
this.heading = head_op;
|
||||
this.nodes = {};
|
||||
this.all_nodes = [];
|
||||
|
||||
var me = this;
|
||||
|
||||
this.body = $a(parent, 'div');
|
||||
this.hopbody = $a(head_op, 'div');
|
||||
this.hitbody = $a(head_it, 'div');
|
||||
|
||||
// columns
|
||||
this.col_details = [
|
||||
['340px','Opn No', 'Opn Descr','Item Code', 'Description',1,2]
|
||||
,['150px','BOM' , 'BOM', 3]
|
||||
,['80px', 'Workstn', 'Qty', 4]
|
||||
,['45px', 'Hr Rate','Stock UOM',5]
|
||||
,['45px', 'Time','Scrap',6]
|
||||
,['50px', 'Mat Cost','Rate',7]
|
||||
,['45px', 'Op Cost','',8]
|
||||
,['50px', 'Tot Cost','',9]
|
||||
,['25px', 'Refresh']
|
||||
]
|
||||
|
||||
// Operation header
|
||||
this.hopbody_tab = $a(this.hopbody, 'table');
|
||||
$y(this.hopbody_tab, {borderCollapse:'collapse', tableLayout:'fixed'})
|
||||
|
||||
var r0 = this.hopbody_tab.insertRow(0);
|
||||
for(var i=0; i<this.col_details.length; i++) {
|
||||
var c = r0.insertCell(i);
|
||||
c.style.width = this.col_details[i][0];
|
||||
c.style.padding = '2px';
|
||||
c.style.border = '1px solid #DDD';
|
||||
if (i > 0 && this.col_details[i][1] != 'Refresh') c.innerHTML = this.col_details[i][1];
|
||||
}
|
||||
this.hopbody_label = $a(r0.cells[0], 'div');
|
||||
var hopbody_nodetab = $a(this.hopbody_label, 'table');
|
||||
$y(hopbody_nodetab, {borderCollapse:'collapse', tableLayout:'fixed'})
|
||||
|
||||
var r0 = hopbody_nodetab.insertRow(0);
|
||||
var c = r0.insertCell(0); c.style.width = '16px';
|
||||
var c = r0.insertCell(1); c.style.width = '20px'; c.innerHTML = "<img src='images/icons/wrench.png' />";
|
||||
var c = r0.insertCell(2); c.style.width = '80px'; c.innerHTML = this.col_details[0][1];
|
||||
l=340-116;
|
||||
var c = r0.insertCell(3); c.style.width = l+'px'; c.innerHTML = this.col_details[0][2];
|
||||
|
||||
// Item Header
|
||||
this.hitbody_tab = $a(this.hitbody, 'table');
|
||||
$y(this.hitbody_tab, {borderCollapse:'collapse', tableLayout:'fixed'})
|
||||
|
||||
var r0 = this.hitbody_tab.insertRow(0);
|
||||
for(var i=0; i<this.col_details.length; i++) {
|
||||
var c = r0.insertCell(i);
|
||||
c.style.width = this.col_details[i][0];
|
||||
c.style.padding = '2px';
|
||||
c.style.border = '1px solid #DDD';
|
||||
if (i > 0 && this.col_details[i][1] != 'Refresh') c.innerHTML = this.col_details[i][2];
|
||||
}
|
||||
this.hitbody_label = $a(r0.cells[0], 'div');
|
||||
var hitbody_nodetab = $a(this.hitbody_label, 'table');
|
||||
$y(hitbody_nodetab, {borderCollapse:'collapse', tableLayout:'fixed'})
|
||||
|
||||
var r0 = hitbody_nodetab.insertRow(0);
|
||||
var c = r0.insertCell(0); c.style.width = '16px';
|
||||
var c = r0.insertCell(1); c.style.width = '20px'; c.innerHTML = "<img src='images/icons/package.png' />";
|
||||
var c = r0.insertCell(2); c.style.width = '100px'; c.innerHTML = this.col_details[0][3];
|
||||
l=350-136;
|
||||
var c = r0.insertCell(3); c.style.width = l+'px'; c.innerHTML = this.col_details[0][4];
|
||||
|
||||
this.addNode = function(parent, head_op, label, imagesrc, onclick, onexpand) {
|
||||
var t = new TreeNode(me, parent, head_op, label, imagesrc, onclick, onexpand);
|
||||
if(!parent) {
|
||||
me.nodes[label]=t; // add to roots
|
||||
} else {
|
||||
parent.nodes[label] = t; // add to the node
|
||||
}
|
||||
|
||||
this.all_nodes.push(t);
|
||||
|
||||
// note: this will only be for groups
|
||||
if(onexpand)t.create_expimage();
|
||||
t.expanded_once = false;
|
||||
|
||||
return t;
|
||||
|
||||
}
|
||||
|
||||
this.deleteNode = function(node) {
|
||||
node.container.remove(node);
|
||||
|
||||
}
|
||||
var me = this;
|
||||
|
||||
this.collapseall = function() {
|
||||
//alert("collapseall")
|
||||
for(n in me.nodes) {
|
||||
if (me.nodes[n].expimage){
|
||||
l = me.nodes[n].get_list_of_child_nodes()
|
||||
for (var i=0; i < l.length; i++ ) l[i].collapse(l[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function TreeNode(tree, parent, head_op, label, imagesrc, onclick, onexpand) {
|
||||
|
||||
var me = this;
|
||||
this.parent = parent;
|
||||
this.head = head_op;
|
||||
this.nodes = {};
|
||||
this.onclick = onclick;
|
||||
this.onexpand = onexpand;
|
||||
this.text = label;
|
||||
|
||||
if(!parent) {
|
||||
var container = tree.body;
|
||||
}
|
||||
else {
|
||||
var container = parent.body;
|
||||
}
|
||||
var h_container = tree.hopbody;
|
||||
|
||||
var t = $a(container, "div");
|
||||
var ht = $a(h_container, "div");
|
||||
|
||||
t.style.display = "none";
|
||||
ht.style.display = "none";
|
||||
|
||||
this.node_area = $a(t, "div");
|
||||
this.node_area.style.cursor = 'pointer';
|
||||
|
||||
this.loading_div = $a(container, "div");
|
||||
this.loading_div.innerHTML = 'Loading...';
|
||||
$dh(this.loading_div);
|
||||
|
||||
// main table
|
||||
this.tab = $a(this.node_area, 'table');
|
||||
$y(this.tab, {borderCollapse:'collapse', tableLayout:'fixed'})
|
||||
|
||||
var r0 = this.tab.insertRow(0);
|
||||
for(var i=0; i<tree.col_details.length; i++) {
|
||||
var c = r0.insertCell(i);
|
||||
c.style.width = tree.col_details[i][0];
|
||||
c.style.padding = '2px';
|
||||
c.style.border = '1px solid #DDD';
|
||||
}
|
||||
|
||||
this.label = $a(r0.cells[0], 'div');
|
||||
|
||||
var m=0;
|
||||
var tn = this;
|
||||
|
||||
while(tn.parent){m+=16;tn=tn.parent;}
|
||||
this.label.style.marginLeft = m+'px';
|
||||
this.loading_div.style.marginLeft = m+40+'px';
|
||||
var l = 350 - m;
|
||||
this.body = $a(t, 'div'); // children will come here
|
||||
|
||||
// make the node
|
||||
var nodetab = $a(this.label, 'table');
|
||||
$y(nodetab, {borderCollapse:'collapse', tableLayout:'fixed'})
|
||||
|
||||
var r0 = nodetab.insertRow(0);
|
||||
var c = r0.insertCell(0); c.style.width = '16px';
|
||||
var c = r0.insertCell(1); c.style.width = '20px';
|
||||
var c = r0.insertCell(2); c.style.width = '100px';
|
||||
l=l-136;
|
||||
|
||||
var c = r0.insertCell(3); c.style.width = l+'px';
|
||||
// BOM - is it item or operation
|
||||
this.is_item = 1;
|
||||
if(label[0] == 'operation') {
|
||||
this.is_item = 0;
|
||||
imagesrc = 'images/icons/wrench.png';
|
||||
}
|
||||
|
||||
if(!imagesrc) imagesrc = "images/icons/folder.png";
|
||||
this.usrimg = $a(nodetab.rows[0].cells[1], 'img');
|
||||
this.usrimg.src = imagesrc;
|
||||
|
||||
|
||||
//this.node_area.onmouseover = function() {this.style.backgroundColor = '#DEF'; }
|
||||
//this.node_area.onmouseout = function() { this.style.backgroundColor = '#FFF'; }
|
||||
|
||||
this.create_expimage = function() {
|
||||
if(!me.expimage) {
|
||||
me.expimage = $a(nodetab.rows[0].cells[0], 'img');
|
||||
me.expimage.style.marginTop = "3px";
|
||||
me.expimage.src = "images/icons/plus.gif";
|
||||
me.expimage.onclick = me.toggle;
|
||||
me.expimage.node = me;
|
||||
}
|
||||
}
|
||||
|
||||
this.get_list_of_child_nodes = function() {
|
||||
var main_l = [];
|
||||
for (n in me.nodes){
|
||||
if(!me.expimage){}
|
||||
else{
|
||||
var l = [];
|
||||
if (me.nodes[n].get_list_of_child_nodes()) l = me.nodes[n].get_list_of_child_nodes();
|
||||
for(var i=0 ; i < l.length; i ++){
|
||||
main_l.push(l[i]);
|
||||
}
|
||||
alert(1);
|
||||
main_l.push(me.nodes[n]);
|
||||
alert(2);
|
||||
}
|
||||
}
|
||||
return main_l
|
||||
}
|
||||
|
||||
this.select = function() {
|
||||
me.show_selected();
|
||||
if(this.onclick)this.onclick(this);
|
||||
}
|
||||
this.show_selected = function() {
|
||||
if(pscript.bom_curnode)pscript.bom_curnode.deselect();
|
||||
me.tab.style.backgroundColor = '#DEF';
|
||||
if(me.is_item == 1) tree.hitbody_tab.style.backgroundColor = '#DEF';
|
||||
if(me.is_item == 0) tree.hopbody_tab.style.backgroundColor = '#DEF';
|
||||
me.tab.style.fontWeight = 'bold';
|
||||
pscript.bom_curnode = me;
|
||||
$ds(me.refresh);
|
||||
}
|
||||
|
||||
this.deselect = function() {
|
||||
me.tab.style.fontWeight = 'normal';
|
||||
pscript.bom_curnode=null;
|
||||
me.tab.style.backgroundColor = '#FFF';
|
||||
tree.hopbody_tab.style.backgroundColor = '#FFF';
|
||||
tree.hitbody_tab.style.backgroundColor = '#FFF';
|
||||
$dh(me.refresh);
|
||||
}
|
||||
|
||||
|
||||
var expanded = 1;
|
||||
this.toggle = function(node) {
|
||||
//alert("toggle")
|
||||
if(!me.expimage)return;
|
||||
if(me.expanded)me.collapse(this.node);
|
||||
else me.expand(this.node);
|
||||
}
|
||||
this.collapse = function(node) {
|
||||
//alert("collapse")
|
||||
if(!node.expimage)return;
|
||||
node.body.style.display = 'none';
|
||||
if(node.expimage.src)node.expimage.src = "images/icons/plus.gif";
|
||||
node.expanded = 0;
|
||||
}
|
||||
this.expand = function(node) {
|
||||
//alert("expand")
|
||||
if(!node.expimage)return;
|
||||
if(node.onexpand)node.onexpand(node);
|
||||
node.body.style.display = 'block';
|
||||
if(node.expimage.src)node.expimage.src = "images/icons/minus.gif";
|
||||
node.expanded = 1;
|
||||
node.expanded_once = 1;
|
||||
}
|
||||
|
||||
// BOM - Set values
|
||||
for(var i=0;i<tree.col_details.length; i++) {
|
||||
if ( i == 0) {
|
||||
if(this.is_item == 1) {
|
||||
var c = $a( nodetab.rows[0].cells[2], 'span', 'link_type');
|
||||
c.item_code = label[tree.col_details[i][5]]
|
||||
c.onclick = function() { loaddoc("Item", this.item_code); }
|
||||
}
|
||||
if(this.is_item == 0) var c = nodetab.rows[0].cells[2];
|
||||
var d = nodetab.rows[0].cells[3];
|
||||
c.innerHTML = label[tree.col_details[i][5]];
|
||||
d.innerHTML = label[tree.col_details[i][6]].substring(0,15) + '...';
|
||||
}
|
||||
if(i==1) {
|
||||
var c = $a(this.tab.rows[0].cells[i], 'div', 'link_type', {overflow:'hidden', width:'100%'});
|
||||
c.bom_no = label[tree.col_details[i][3]]
|
||||
c.onclick = function() { loaddoc("Bill Of Materials", this.bom_no); }
|
||||
c.innerHTML = label[tree.col_details[i][3]];
|
||||
}
|
||||
if(this.is_item == 1 && i > 1 && i < 6) {
|
||||
var c = this.tab.rows[0].cells[i];
|
||||
c.innerHTML = label[tree.col_details[i][3]];
|
||||
}
|
||||
if(this.is_item == 0 && i > 1 && tree.col_details[i][1] != 'Refresh') {
|
||||
var c = this.tab.rows[0].cells[i];
|
||||
c.innerHTML = label[tree.col_details[i][3]];
|
||||
}
|
||||
if(tree.col_details[i][1] == 'Refresh') {
|
||||
this.refresh = $a(this.tab.rows[0].cells[i], 'span', 'link_type');
|
||||
this.refresh.onclick = function() {
|
||||
me.node = me
|
||||
if(me.node.expanded_once){
|
||||
me.node.body.innerHTML = '';
|
||||
me.node.expanded_once = 0
|
||||
me.expanded = 0
|
||||
me.toggle();
|
||||
}
|
||||
else {me.toggle()}
|
||||
}
|
||||
this.refresh.innerHTML = "<img src='images/icons/page_refresh.gif' />"
|
||||
$dh(this.refresh);
|
||||
}
|
||||
}
|
||||
|
||||
this.tab.onclick= function(e) { me.select(); }
|
||||
this.tab.ondblclick = function(e) { me.select(); if(me.ondblclick)me.ondblclick(me); }
|
||||
t.style.display = "block";
|
||||
ht.style.display = "block";
|
||||
}
|
||||
1
production/page/bill_of_materials/bill_of_materials.txt
Normal file
1
production/page/bill_of_materials/bill_of_materials.txt
Normal file
@@ -0,0 +1 @@
|
||||
[{'creation': '2009-08-31 15:26:19', 'module': 'Production', 'doctype': 'Page', 'owner': 'Administrator', 'style': None, 'modified_by': 'Administrator', 'script': None, 'show_in_menu': 1, 'content': None, 'page_name': 'Bill of Materials', 'menu_index': None, 'docstatus': 0, 'parent': None, 'standard': 'Yes', 'icon': '', 'name': 'Bill of Materials', 'idx': None, 'static_content': None, 'modified': '2010-09-25 00:00:00', 'parenttype': None, 'parent_node': None, 'parentfield': None}, {'modified_by': 'Administrator', 'name': 'PR000040', 'parent': 'Bill of Materials', 'creation': '2009-08-31 15:26:19', 'modified': '2010-05-10 09:41:53', 'doctype': 'Page Role', 'idx': 1, 'parenttype': 'Page', 'role': 'Administrator', 'owner': 'Administrator', 'docstatus': 0, 'parentfield': 'roles'}, {'modified_by': 'Administrator', 'name': 'PR000111', 'parent': 'Bill of Materials', 'creation': '2010-03-15 13:25:15', 'modified': '2010-05-10 09:41:53', 'doctype': 'Page Role', 'idx': 2, 'parenttype': 'Page', 'role': 'Production User', 'owner': 'jai@webnotestech.com', 'docstatus': 0, 'parentfield': 'roles'}, {'modified_by': 'Administrator', 'name': 'PR000112', 'parent': 'Bill of Materials', 'creation': '2010-03-15 13:25:15', 'modified': '2010-05-10 09:41:53', 'doctype': 'Page Role', 'idx': 3, 'parenttype': 'Page', 'role': 'Production Manager', 'owner': 'jai@webnotestech.com', 'docstatus': 0, 'parentfield': 'roles'}]
|
||||
0
production/search_criteria/__init__.py
Normal file
0
production/search_criteria/__init__.py
Normal file
@@ -0,0 +1,37 @@
|
||||
[
|
||||
{
|
||||
'add_col': '`tabProduction Order`.consider_sa_items',
|
||||
'add_cond': '`tabProduction Order`.name = `tabStock Entry`.production_order',
|
||||
'add_tab': '`tabProduction Order`',
|
||||
'columns': 'Stock Entry\x01ID,Stock Entry\x01Production Order,Stock Entry\x01Process,Stock Entry\x01Posting Date,Stock Entry\x01Company,Stock Entry Detail\x01Source Warehouse,Stock Entry Detail\x01Target Warehouse,Stock Entry Detail\x01FG Item,Stock Entry Detail\x01Item Code,Stock Entry Detail\x01Description,Stock Entry Detail\x01Reqd Qty,Stock Entry Detail\x01Transfer Quantity',
|
||||
'creation': '2010-08-08 17:09:32',
|
||||
'criteria_name': 'Consumption Against Production',
|
||||
'custom_query': '',
|
||||
'description': None,
|
||||
'dis_filters': None,
|
||||
'disabled': None,
|
||||
'doc_type': 'Stock Entry Detail',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Stock Entry\x01Submitted':1,'Stock Entry\x01Purpose':'Production Order','Stock Entry\x01Process':''}",
|
||||
'graph_series': None,
|
||||
'graph_values': None,
|
||||
'group_by': None,
|
||||
'idx': None,
|
||||
'modified': '2010-06-11 16:32:48',
|
||||
'modified_by': 'Administrator',
|
||||
'module': 'Production',
|
||||
'name': 'consumption_against_production',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'page_len': 50,
|
||||
'parent': None,
|
||||
'parent_doc_type': 'Stock Entry',
|
||||
'parentfield': None,
|
||||
'parenttype': None,
|
||||
'report_script': '',
|
||||
'server_script': None,
|
||||
'sort_by': '`tabStock Entry`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
}
|
||||
]
|
||||
18
production/search_criteria/delivery_plan/delivery_plan.js
Normal file
18
production/search_criteria/delivery_plan/delivery_plan.js
Normal file
@@ -0,0 +1,18 @@
|
||||
report.customize_filters = function() {
|
||||
|
||||
//to hide all filters
|
||||
//this.hide_all_filters();
|
||||
|
||||
// to disable a filter from query set
|
||||
this.filter_fields_dict['Sales Order'+FILTER_SEP +'Status'].df.ignore = 1;
|
||||
|
||||
// to unhide required filters
|
||||
this.filter_fields_dict['Sales Order'+FILTER_SEP +'Customer'].df.filter_hide = 0;
|
||||
this.filter_fields_dict['Sales Order'+FILTER_SEP +'Customer Name'].df.filter_hide = 0;
|
||||
this.filter_fields_dict['Sales Order Detail'+FILTER_SEP +'From Confirmed Delivery Date'].df.filter_hide = 0;
|
||||
this.filter_fields_dict['Sales Order Detail'+FILTER_SEP +'To Confirmed Delivery Date'].df.filter_hide = 0;
|
||||
|
||||
|
||||
this.filter_fields_dict['Sales Order'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
|
||||
this.filter_fields_dict['Sales Order'+FILTER_SEP +'Fiscal Year'].df['report_default'] = sys_defaults.fiscal_year;
|
||||
}
|
||||
37
production/search_criteria/delivery_plan/delivery_plan.txt
Normal file
37
production/search_criteria/delivery_plan/delivery_plan.txt
Normal file
@@ -0,0 +1,37 @@
|
||||
[
|
||||
{
|
||||
'add_col': "SUM(`tabSales Order Detail`.`pending_qty` * `tabSales Order Detail`.`basic_rate` ) AS 'Amount'",
|
||||
'add_cond': "`tabSales Order Detail`.pending_qty > 0 and (`tabSales Order Detail`.confirmation_date is not null or `tabSales Order Detail`.confirmation_date!='' or `tabSales Order Detail`.confirmation_date != '00-00-0000')",
|
||||
'add_tab': None,
|
||||
'columns': 'Sales Order\x01ID,Sales Order\x01Customer,Sales Order\x01Customer Name',
|
||||
'creation': '2010-09-01 15:47:57',
|
||||
'criteria_name': 'Delivery Plan',
|
||||
'custom_query': '',
|
||||
'description': None,
|
||||
'dis_filters': None,
|
||||
'disabled': None,
|
||||
'doc_type': 'Sales Order Detail',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Sales Order\x01Saved':1,'Sales Order\x01Submitted':1,'Sales Order\x01Status':'','Sales Order\x01Fiscal Year':''}",
|
||||
'graph_series': None,
|
||||
'graph_values': None,
|
||||
'group_by': '`tabSales Order Detail`.`confirmation_date`, `tabSales Order`.`name`',
|
||||
'idx': None,
|
||||
'modified': '2010-08-30 14:06:22',
|
||||
'modified_by': 'Administrator',
|
||||
'module': 'Production',
|
||||
'name': 'delivery_plan',
|
||||
'owner': 'Administrator',
|
||||
'page_len': 50,
|
||||
'parent': None,
|
||||
'parent_doc_type': 'Sales Order',
|
||||
'parentfield': None,
|
||||
'parenttype': None,
|
||||
'report_script': None,
|
||||
'server_script': '',
|
||||
'sort_by': '`tabSales Order`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,16 @@
|
||||
report.customize_filters = function() {
|
||||
|
||||
//to hide all filters
|
||||
this.hide_all_filters();
|
||||
|
||||
// to unhide required filters
|
||||
this.filter_fields_dict['Stock Entry'+FILTER_SEP +'ID'].df.filter_hide = 0;
|
||||
this.filter_fields_dict['Stock Entry'+FILTER_SEP +'Production Order'].df.filter_hide = 0;
|
||||
|
||||
this.filter_fields_dict['Stock Entry'+FILTER_SEP +'From Posting Date'].df.filter_hide = 0;
|
||||
this.filter_fields_dict['Stock Entry'+FILTER_SEP +'To Posting Date'].df.filter_hide = 0;
|
||||
|
||||
this.filter_fields_dict['Stock Entry Detail'+FILTER_SEP +'Target Warehouse'].df.filter_hide = 0;
|
||||
|
||||
this.filter_fields_dict['Stock Entry Detail'+FILTER_SEP +'Item Code'].df.filter_hide = 0;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
[
|
||||
{
|
||||
'add_col': None,
|
||||
'add_cond': None,
|
||||
'add_tab': None,
|
||||
'columns': 'Stock Entry\x01ID,Stock Entry\x01Posting Date,Stock Entry\x01Production Order,Stock Entry\x01Process,Stock Entry\x01Company,Stock Entry Detail\x01Target Warehouse,Stock Entry Detail\x01Item Code,Stock Entry Detail\x01Description,Stock Entry Detail\x01Stock UOM,Stock Entry Detail\x01Transfer Quantity',
|
||||
'creation': '2010-08-08 17:09:32',
|
||||
'criteria_name': 'Itemwise Production Report',
|
||||
'custom_query': '',
|
||||
'description': None,
|
||||
'dis_filters': None,
|
||||
'disabled': None,
|
||||
'doc_type': 'Stock Entry Detail',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Stock Entry\x01Saved':1,'Stock Entry\x01Submitted':1,'Stock Entry\x01Purpose':'Production Order','Stock Entry\x01Process':'Backflush','Stock Entry Detail\x01FG Item':1}",
|
||||
'graph_series': None,
|
||||
'graph_values': None,
|
||||
'group_by': None,
|
||||
'idx': None,
|
||||
'modified': '2010-06-14 15:50:44',
|
||||
'modified_by': 'Administrator',
|
||||
'module': 'Production',
|
||||
'name': 'itemwise_production_report',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'page_len': 50,
|
||||
'parent': None,
|
||||
'parent_doc_type': 'Stock Entry',
|
||||
'parentfield': None,
|
||||
'parenttype': None,
|
||||
'report_script': None,
|
||||
'server_script': None,
|
||||
'sort_by': '`tabStock Entry`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,37 @@
|
||||
[
|
||||
{
|
||||
'add_col': None,
|
||||
'add_cond': '`tabProduction Order`.qty > `tabProduction Order`.produced_qty',
|
||||
'add_tab': None,
|
||||
'columns': 'Production Order\x01ID,Production Order\x01Origin,Production Order\x01Status,Production Order\x01Posting Date,Production Order\x01Production Item,Production Order\x01BOM No,Production Order\x01Description,Production Order\x01Stock UOM,Production Order\x01Qty,Production Order\x01Produced Qty,Production Order\x01FG Warehouse,Production Order\x01WIP Warehouse,Production Order\x01Consider SA Items,Production Order\x01Fiscal Year,Production Order\x01Company',
|
||||
'creation': '2010-08-08 17:09:32',
|
||||
'criteria_name': 'Production Orders In Process',
|
||||
'custom_query': '',
|
||||
'description': None,
|
||||
'dis_filters': None,
|
||||
'disabled': None,
|
||||
'doc_type': 'Production Order',
|
||||
'docstatus': 0,
|
||||
'doctype': 'Search Criteria',
|
||||
'filters': "{'Production Order\x01Submitted':1,'Production Order\x01Origin':'','Production Order\x01Status':'','Production Order\x01Consider SA Items':'','Production Order\x01Fiscal Year':''}",
|
||||
'graph_series': None,
|
||||
'graph_values': None,
|
||||
'group_by': None,
|
||||
'idx': None,
|
||||
'modified': '2010-06-15 10:01:15',
|
||||
'modified_by': 'Administrator',
|
||||
'module': 'Production',
|
||||
'name': 'production_orders_in_process',
|
||||
'owner': 'jai@webnotestech.com',
|
||||
'page_len': 50,
|
||||
'parent': None,
|
||||
'parent_doc_type': None,
|
||||
'parentfield': None,
|
||||
'parenttype': None,
|
||||
'report_script': '',
|
||||
'server_script': None,
|
||||
'sort_by': '`tabProduction Order`.`name`',
|
||||
'sort_order': 'DESC',
|
||||
'standard': 'Yes'
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user