Merge branch 'master' of github.com:webnotes/erpnext

This commit is contained in:
Rushabh Mehta 2012-12-03 13:16:10 +01:00
commit 6ca6b7e105
33 changed files with 808 additions and 934 deletions

View File

@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2012-07-03 13:29:51",
"modified_by": "Administrator",
"modified": "2012-03-27 14:35:41"
"modified": "2012-12-03 17:10:41"
},
{
"in_create": 0,

View File

@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2012-10-16 12:29:32",
"modified_by": "Administrator",
"modified": "2012-10-15 12:38:42"
"modified": "2012-12-03 17:10:41"
},
{
"is_submittable": 1,

View File

@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2012-11-28 11:26:17",
"modified_by": "Administrator",
"modified": "2012-11-26 11:52:32"
"modified": "2012-12-03 17:10:41"
},
{
"is_submittable": 1,

View File

@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2012-09-10 12:22:26",
"modified_by": "Administrator",
"modified": "2012-11-30 16:39:08"
"modified": "2012-12-03 17:10:41"
},
{
"is_submittable": 1,

View File

@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2012-08-06 20:00:37",
"modified_by": "Administrator",
"modified": "2012-08-06 17:14:18"
"modified": "2012-12-03 17:10:41"
},
{
"is_submittable": 1,

View File

@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2012-07-03 13:29:58",
"modified_by": "Administrator",
"modified": "2012-05-01 13:02:17"
"modified": "2012-12-03 17:10:41"
},
{
"is_submittable": 1,

View File

@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2012-12-03 10:31:02",
"modified_by": "Administrator",
"modified": "2012-12-03 11:25:12"
"modified": "2012-12-03 17:10:41"
},
{
"autoname": "naming_series:",

View File

@ -5,7 +5,7 @@
{
'creation': '2012-08-07 14:52:42',
'docstatus': 0,
'modified': '2012-08-07 14:57:57',
'modified': '2012-12-03 17:10:41',
'modified_by': u'Administrator',
'owner': u'Administrator'
},

View File

@ -48,7 +48,7 @@ class DocType:
from `tabEmployee` t1, `tabSalary Structure` t2
where t1.docstatus!=2 and t2.docstatus != 2
and t1.name = t2.employee
%s """% cond, debug=1)
%s """% cond)
return emp_list

View File

@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2012-07-03 13:29:40",
"modified_by": "Administrator",
"modified": "2012-03-27 14:45:51"
"modified": "2012-12-03 17:10:41"
},
{
"is_submittable": 1,

View File

@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2012-07-03 13:29:41",
"modified_by": "Administrator",
"modified": "2012-03-27 14:36:00"
"modified": "2012-12-03 17:10:41"
},
{
"name": "__common__",

View File

@ -2,6 +2,7 @@ import webnotes
import email.utils
def execute():
webnotes.reload_doc("core", "doctype", "communication")
webnotes.conn.commit()
for d in webnotes.conn.sql("""select owner, creation, modified, modified_by, parent,
from_email, mail from `tabSupport Ticket Response`""", as_dict=1):

View File

@ -16,12 +16,7 @@
// On REFRESH
cur_frm.cscript.refresh = function(doc,dt,dn){
if(!doc.__islocal) {
set_field_permlevel('item',1);
unhide_field('update_cost_as_on_today');
} else {
hide_field('update_cost_as_on_today');
}
cur_frm.toggle_enable("item", doc.__islocal);
}
@ -137,9 +132,6 @@ var calculate_total = function(doc) {
}
// Get Query
//-----------------------------------------------------------------------------------------------------
cur_frm.fields_dict['item'].get_query = function(doc) {
return 'SELECT DISTINCT `tabItem`.`name`, `tabItem`.description FROM `tabItem` WHERE is_manufactured_item = "Yes" and (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';
}

View File

@ -152,7 +152,6 @@ class DocType:
sql("update `tabItem` set default_bom = %s where name = %s", (self.doc.name, self.doc.item))
else:
sql("update `tabItem` set default_bom = '' where name = %s and default_bom = %s", (self.doc.item, self.doc.name))
def manage_active_bom(self):
@ -193,24 +192,22 @@ class DocType:
total_op_cost = 0
for d in getlist(self.doclist, 'bom_operations'):
hour_rate = sql("select hour_rate from `tabWorkstation` where name = %s", cstr(d.workstation))
d.hour_rate = hour_rate and flt(hour_rate[0][0]) or 0
d.operating_cost = flt(d.hour_rate) * flt(d.time_in_mins) / 60
d.hour_rate = hour_rate and flt(hour_rate[0][0]) or d.hour_rate or 0
d.operating_cost = d.hour_rate and d.time_in_mins and \
flt(d.hour_rate) * flt(d.time_in_mins) / 60 or d.operating_cost
d.save()
total_op_cost += d.operating_cost
self.doc.operating_cost = total_op_cost
def calculate_rm_cost(self):
"""Fetch RM rate as per today's valuation rate and calculate totals"""
total_rm_cost = 0
for d in getlist(self.doclist, 'bom_materials'):
#if self.doc.rm_cost_as_per == 'Valuation Rate':
arg = {'item_code': d.item_code, 'qty': d.qty, 'bom_no': d.bom_no}
ret = self.get_bom_material_detail(cstr(arg))
for k in ret:
d.fields[k] = ret[k]
d.amount = flt(d.rate) * flt(d.qty)
d.save()
total_rm_cost += d.amount
@ -284,15 +281,11 @@ class DocType:
check_list.append([cstr(item), cstr(op)])
#----- Document on Save function------
def validate(self):
self.validate_main_item()
self.validate_operations()
self.validate_materials()
def check_recursion(self):
""" Check whether reqursion occurs in any bom"""

View File

@ -1,462 +1,347 @@
# DocType, BOM
[
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:02',
'docstatus': 0,
'modified': '2012-03-27 14:45:46',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'_last_update': u'1326963484',
'allow_attach': 0,
'allow_copy': 0,
'allow_email': 0,
'allow_print': 0,
'allow_rename': 0,
'allow_trash': 1,
'colour': u'White:FFF',
'default_print_format': u'Standard',
'doctype': 'DocType',
'document_type': u'Master',
'hide_heading': 0,
'hide_toolbar': 0,
'in_create': 0,
'is_submittable': 1,
'issingle': 0,
'istable': 0,
'module': u'Production',
'name': '__common__',
'read_only': 0,
'search_fields': u'item',
'section_style': u'Simple',
'server_code_error': u' ',
'show_in_menu': 0,
'subject': u'%(item)s',
'version': 196
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'BOM',
'parentfield': u'fields',
'parenttype': u'DocType'
},
# These values are common for all DocPerm
{
'doctype': u'DocPerm',
'name': '__common__',
'parent': u'BOM',
'parentfield': u'permissions',
'parenttype': u'DocType',
'read': 1
},
# DocType, BOM
{
'doctype': 'DocType',
'name': u'BOM'
},
# DocPerm
{
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'System Manager',
'submit': 1,
'write': 1
},
# DocPerm
{
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'System Manager'
},
# DocPerm
{
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Production Manager',
'submit': 1,
'write': 1
},
# DocPerm
{
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Production Manager'
},
# DocPerm
{
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Production User',
'submit': 1,
'write': 1
},
# DocPerm
{
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Production User'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break0',
'fieldtype': u'Column Break',
'oldfieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'colour': u'White:FFF',
'description': u'Select the item code for which Bill of Material is being created',
'doctype': u'DocField',
'fieldname': u'item',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'Item',
'oldfieldname': u'item',
'oldfieldtype': u'Link',
'options': u'Item',
'permlevel': 0,
'reqd': 1,
'search_index': 1,
'trigger': u'Client'
},
# DocField
{
'colour': u'White:FFF',
'description': u'Total quantity of items for which raw materials required and operations done will be defined',
'doctype': u'DocField',
'fieldname': u'quantity',
'fieldtype': u'Currency',
'label': u'Quantity',
'oldfieldname': u'quantity',
'oldfieldtype': u'Currency',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'uom',
'fieldtype': u'Select',
'label': u'UOM',
'options': u'link:UOM',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'description',
'fieldtype': u'Text',
'label': u'Description',
'oldfieldname': u'description',
'oldfieldtype': u'Text',
'permlevel': 0,
'width': u'300px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break1',
'fieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'description': u'Select name of the project if BOM need to be created against any project',
'doctype': u'DocField',
'fieldname': u'project_name',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'Project Name',
'oldfieldname': u'project_name',
'oldfieldtype': u'Link',
'options': u'Project',
'permlevel': 0,
'trigger': u'Client'
},
# DocField
{
'allow_on_submit': 1,
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'is_active',
'fieldtype': u'Select',
'hidden': 0,
'label': u'Is Active',
'no_copy': 1,
'oldfieldname': u'is_active',
'oldfieldtype': u'Select',
'options': u'\nYes\nNo',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'allow_on_submit': 1,
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'is_default',
'fieldtype': u'Check',
'label': u'Is Default',
'no_copy': 1,
'oldfieldname': u'is_default',
'oldfieldtype': u'Check',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'maintained_by',
'fieldtype': u'Data',
'label': u'Maintained By',
'oldfieldname': u'maintained_by',
'oldfieldtype': u'Data',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'remarks',
'fieldtype': u'Text',
'label': u'Remarks',
'no_copy': 1,
'oldfieldname': u'remarks',
'oldfieldtype': u'Text',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'operations',
'fieldtype': u'Section Break',
'label': u'Operations',
'oldfieldtype': u'Section Break',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'description': u'Specify the operations, operating cost and give a unique Operation no to your operations.',
'doctype': u'DocField',
'fieldname': u'bom_operations',
'fieldtype': u'Table',
'label': u'BOM Operations',
'oldfieldname': u'bom_operations',
'oldfieldtype': u'Table',
'options': u'BOM Operation',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'materials',
'fieldtype': u'Section Break',
'label': u'Materials',
'oldfieldtype': u'Section Break',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'description': u'Enter the raw materials required to manufacture the BOM item. Specify the operation no as entered in the previous tab which will be performed on the raw materials entered.',
'doctype': u'DocField',
'fieldname': u'bom_materials',
'fieldtype': u'Table',
'label': u'BOM Item',
'oldfieldname': u'bom_materials',
'oldfieldtype': u'Table',
'options': u'BOM Item',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'costing',
'fieldtype': u'Section Break',
'label': u'Costing',
'oldfieldtype': u'Section Break',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break2',
'fieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'rm_cost_as_per',
'fieldtype': u'Select',
'label': u'Consider Raw Material Cost As Per',
'options': u'Valuation Rate\nLast Purchase Rate\nStandard Rate',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'costing_date',
'fieldtype': u'Date',
'label': u'Costing Date',
'permlevel': 1
},
# DocField
{
'allow_on_submit': 1,
'doctype': u'DocField',
'fieldname': u'update_cost_as_on_today',
'fieldtype': u'Button',
'label': u'Update Cost as on today',
'options': u'calculate_cost',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break3',
'fieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'raw_material_cost',
'fieldtype': u'Float',
'label': u'Raw Material Cost',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'operating_cost',
'fieldtype': u'Float',
'label': u'Operating Cost',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'total_cost',
'fieldtype': u'Float',
'label': u'Total Cost',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'section_break0',
'fieldtype': u'Section Break',
'hidden': 1,
'options': u'Simple',
'permlevel': 0,
'print_hide': 0
},
# DocField
{
'colour': u'White:FFF',
'default': u'No Toolbar',
'doctype': u'DocField',
'fieldname': u'flat_bom_details',
'fieldtype': u'Table',
'hidden': 1,
'label': u'BOM Explosion Item',
'no_copy': 1,
'oldfieldname': u'flat_bom_details',
'oldfieldtype': u'Table',
'options': u'BOM Explosion Item',
'permlevel': 0,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'trash_reason',
'fieldtype': u'Small Text',
'hidden': 1,
'label': u'Trash Reason',
'oldfieldname': u'trash_reason',
'oldfieldtype': u'Small Text',
'permlevel': 1
},
# DocField
{
'depends_on': u'eval:doc.amended_from',
'description': u'The date at which current entry is corrected in the system.',
'doctype': u'DocField',
'fieldname': u'amendment_date',
'fieldtype': u'Date',
'label': u'Amendment Date',
'no_copy': 1,
'permlevel': 0,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'amended_from',
'fieldtype': u'Link',
'label': u'Amended From',
'no_copy': 1,
'options': u'Sales Invoice',
'permlevel': 1,
'print_hide': 1
}
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-07-03 13:30:03",
"modified_by": "Administrator",
"modified": "2012-12-03 13:29:26"
},
{
"istable": 0,
"in_create": 0,
"allow_print": 0,
"search_fields": "item",
"module": "Production",
"document_type": "Master",
"allow_attach": 0,
"read_only": 0,
"allow_email": 0,
"hide_heading": 0,
"issingle": 0,
"name": "__common__",
"default_print_format": "Standard",
"allow_rename": 0,
"doctype": "DocType",
"is_submittable": 1,
"hide_toolbar": 0,
"allow_copy": 0
},
{
"name": "__common__",
"parent": "BOM",
"doctype": "DocField",
"parenttype": "DocType",
"parentfield": "fields"
},
{
"name": "__common__",
"parent": "BOM",
"read": 1,
"doctype": "DocPerm",
"parenttype": "DocType",
"parentfield": "permissions"
},
{
"name": "BOM",
"doctype": "DocType"
},
{
"oldfieldtype": "Column Break",
"doctype": "DocField",
"width": "50%",
"fieldname": "column_break0",
"fieldtype": "Column Break",
"permlevel": 0
},
{
"description": "Select the item code for which Bill of Material is being created",
"oldfieldtype": "Link",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Item",
"oldfieldname": "item",
"permlevel": 0,
"trigger": "Client",
"fieldname": "item",
"fieldtype": "Link",
"search_index": 1,
"reqd": 1,
"in_filter": 1,
"options": "Item"
},
{
"description": "Total quantity of items for which raw materials required and operations done will be defined",
"oldfieldtype": "Currency",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Quantity",
"oldfieldname": "quantity",
"fieldname": "quantity",
"fieldtype": "Currency",
"reqd": 1,
"permlevel": 0
},
{
"doctype": "DocField",
"width": "50%",
"fieldname": "column_break1",
"fieldtype": "Column Break",
"permlevel": 0
},
{
"no_copy": 1,
"oldfieldtype": "Select",
"colour": "White:FFF",
"allow_on_submit": 1,
"doctype": "DocField",
"label": "Is Active",
"oldfieldname": "is_active",
"permlevel": 0,
"fieldname": "is_active",
"fieldtype": "Select",
"reqd": 1,
"hidden": 0,
"options": "\nYes\nNo"
},
{
"allow_on_submit": 1,
"no_copy": 1,
"oldfieldtype": "Check",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Is Default",
"oldfieldname": "is_default",
"fieldname": "is_default",
"fieldtype": "Check",
"permlevel": 0
},
{
"oldfieldtype": "Section Break",
"doctype": "DocField",
"label": "Operations",
"fieldname": "operations",
"fieldtype": "Section Break",
"permlevel": 0
},
{
"description": "Specify the operations, operating cost and give a unique Operation no to your operations.",
"oldfieldtype": "Table",
"colour": "White:FFF",
"doctype": "DocField",
"label": "BOM Operations",
"oldfieldname": "bom_operations",
"options": "BOM Operation",
"fieldname": "bom_operations",
"fieldtype": "Table",
"permlevel": 0
},
{
"oldfieldtype": "Section Break",
"doctype": "DocField",
"label": "Materials",
"fieldname": "materials",
"fieldtype": "Section Break",
"permlevel": 0
},
{
"doctype": "DocField",
"label": "Consider Raw Material Cost As Per",
"options": "Valuation Rate\nLast Purchase Rate\nStandard Rate",
"fieldname": "rm_cost_as_per",
"fieldtype": "Select",
"permlevel": 0
},
{
"description": "Enter the raw materials required to manufacture the BOM item. Specify the operation no as entered in the previous tab which will be performed on the raw materials entered.",
"oldfieldtype": "Table",
"colour": "White:FFF",
"doctype": "DocField",
"label": "BOM Item",
"oldfieldname": "bom_materials",
"options": "BOM Item",
"fieldname": "bom_materials",
"fieldtype": "Table",
"permlevel": 0
},
{
"oldfieldtype": "Section Break",
"doctype": "DocField",
"label": "Costing",
"fieldname": "costing",
"fieldtype": "Section Break",
"permlevel": 0
},
{
"doctype": "DocField",
"label": "Raw Material Cost",
"fieldname": "raw_material_cost",
"fieldtype": "Float",
"permlevel": 1
},
{
"doctype": "DocField",
"label": "Operating Cost",
"fieldname": "operating_cost",
"fieldtype": "Float",
"permlevel": 1
},
{
"doctype": "DocField",
"label": "Total Cost",
"fieldname": "total_cost",
"fieldtype": "Float",
"permlevel": 1
},
{
"doctype": "DocField",
"label": "More Info",
"fieldname": "more_info_section",
"fieldtype": "Section Break",
"permlevel": 0
},
{
"description": "Select name of the project if BOM need to be created against any project",
"oldfieldtype": "Link",
"label": "Project Name",
"oldfieldname": "project_name",
"trigger": "Client",
"fieldname": "project_name",
"fieldtype": "Link",
"doctype": "DocField",
"options": "Project",
"permlevel": 0,
"in_filter": 1
},
{
"doctype": "DocField",
"label": "Item UOM",
"options": "link:UOM",
"fieldname": "uom",
"fieldtype": "Select",
"permlevel": 1
},
{
"oldfieldtype": "Text",
"doctype": "DocField",
"label": "Item Description",
"oldfieldname": "description",
"width": "300px",
"fieldname": "description",
"fieldtype": "Small Text",
"permlevel": 0
},
{
"doctype": "DocField",
"fieldname": "col_break23",
"fieldtype": "Column Break",
"permlevel": 0
},
{
"oldfieldtype": "Data",
"doctype": "DocField",
"label": "Maintained By",
"oldfieldname": "maintained_by",
"fieldname": "maintained_by",
"fieldtype": "Data",
"permlevel": 0
},
{
"print_hide": 1,
"no_copy": 1,
"doctype": "DocField",
"label": "Amended From",
"options": "Sales Invoice",
"fieldname": "amended_from",
"fieldtype": "Link",
"permlevel": 1
},
{
"print_hide": 1,
"description": "The date at which current entry is corrected in the system.",
"no_copy": 1,
"depends_on": "eval:doc.amended_from",
"doctype": "DocField",
"label": "Amendment Date",
"fieldname": "amendment_date",
"fieldtype": "Date",
"permlevel": 0
},
{
"no_copy": 1,
"oldfieldtype": "Text",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Remarks",
"oldfieldname": "remarks",
"fieldname": "remarks",
"fieldtype": "Small Text",
"permlevel": 0
},
{
"print_hide": 0,
"doctype": "DocField",
"label": "BOM Explosion Items",
"options": "Simple",
"fieldname": "section_break0",
"fieldtype": "Section Break",
"hidden": 0,
"permlevel": 0
},
{
"print_hide": 1,
"permlevel": 1,
"no_copy": 1,
"oldfieldtype": "Table",
"colour": "White:FFF",
"doctype": "DocField",
"label": "BOM Explosion Item",
"oldfieldname": "flat_bom_details",
"default": "No Toolbar",
"fieldname": "flat_bom_details",
"fieldtype": "Table",
"hidden": 0,
"options": "BOM Explosion Item"
},
{
"create": 1,
"doctype": "DocPerm",
"submit": 1,
"write": 1,
"role": "System Manager",
"cancel": 1,
"permlevel": 0
},
{
"doctype": "DocPerm",
"role": "System Manager",
"permlevel": 1
},
{
"create": 1,
"doctype": "DocPerm",
"submit": 1,
"write": 1,
"role": "Production Manager",
"cancel": 1,
"permlevel": 0
},
{
"doctype": "DocPerm",
"role": "Production Manager",
"permlevel": 1
},
{
"create": 1,
"doctype": "DocPerm",
"submit": 1,
"write": 1,
"role": "Production User",
"cancel": 1,
"permlevel": 0
},
{
"doctype": "DocPerm",
"role": "Production User",
"permlevel": 1
}
]

View File

@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2012-07-03 13:30:03",
"modified_by": "Administrator",
"modified": "2012-11-30 14:28:03"
"modified": "2012-12-03 15:38:54"
},
{
"is_submittable": 1,
@ -139,7 +139,7 @@
"oldfieldname": "consider_sa_items",
"fieldname": "use_multi_level_bom",
"fieldtype": "Check",
"reqd": 1,
"reqd": 0,
"in_filter": 1,
"permlevel": 0
},

View File

@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2012-07-03 13:30:03",
"modified_by": "Administrator",
"modified": "2012-11-30 14:08:55"
"modified": "2012-12-03 15:39:44"
},
{
"read_only": 1,
@ -164,7 +164,7 @@
"colour": "White:FFF",
"doctype": "DocField",
"label": "Use Multi-Level BOM",
"reqd": 1,
"reqd": 0,
"fieldname": "use_multi_level_bom",
"fieldtype": "Check"
},

View File

@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2012-11-28 11:26:18",
"modified_by": "Administrator",
"modified": "2012-11-14 17:04:57"
"modified": "2012-12-03 17:10:41"
},
{
"autoname": "field:project_name",

View File

@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2012-12-03 10:31:05",
"modified_by": "Administrator",
"modified": "2012-12-03 11:25:29"
"modified": "2012-12-03 17:10:41"
},
{
"description": "Buyer of Goods and Services.",

View File

@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2012-12-03 10:31:06",
"modified_by": "Administrator",
"modified": "2012-12-03 13:57:32"
"modified": "2012-12-03 17:10:41"
},
{
"is_submittable": 1,

View File

@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2012-11-28 11:26:20",
"modified_by": "Administrator",
"modified": "2012-11-26 11:57:10"
"modified": "2012-12-03 17:10:41"
},
{
"is_submittable": 1,

View File

@ -304,6 +304,29 @@ cur_frm.cscript.barcode = function(doc, cdt, cdn) {
get_server_fields('get_barcode_details', d.barcode, cur_frm.cscript.fname, doc, cdt, cdn, 1, callback);
}
cur_frm.fields_dict[cur_frm.cscript.fname].grid.get_field('batch_no').get_query =
function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(d.item_code) {
if (d.warehouse) {
return "select batch_no from `tabStock Ledger Entry` sle \
where item_code = '" + d.item_code + "' and warehouse = '" + d.warehouse +
"' and ifnull(is_cancelled, 'No') = 'No' and batch_no like '%s' \
and exists(select * from `tabBatch` where \
name = sle.batch_no and expiry_date >= '" + doc.posting_date +
"' and docstatus != 2) group by batch_no having sum(actual_qty) > 0 \
order by batch_no desc limit 50";
} else {
return "SELECT name FROM tabBatch WHERE docstatus != 2 AND item = '" +
d.item_code + "' and expiry_date >= '" + doc.posting_date +
"' AND name like '%s' ORDER BY name DESC LIMIT 50";
}
} else {
msgprint("Please enter Item Code to get batch no");
}
}
// *********************** QUANTITY ***************************
cur_frm.cscript.qty = function(doc, cdt, cdn) { cur_frm.cscript.recalc(doc, 1); }

View File

@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2012-11-28 11:26:20",
"modified_by": "Administrator",
"modified": "2012-11-26 11:56:33"
"modified": "2012-12-03 17:10:41"
},
{
"is_submittable": 1,

View File

@ -134,16 +134,6 @@ cur_frm.cscript.new_contact = function(){
loaddoc('Contact', tn);
}
//========================= Overloaded query for link batch_no =============================================================
cur_frm.fields_dict['delivery_note_details'].grid.get_field('batch_no').get_query= function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(d.item_code){
return "SELECT tabBatch.name, tabBatch.description FROM tabBatch WHERE tabBatch.docstatus != 2 AND tabBatch.item = '"+ d.item_code +"' AND `tabBatch`.`name` like '%s' ORDER BY `tabBatch`.`name` DESC LIMIT 50"
}
else{
alert("Please enter Item Code.");
}
}
// ***************** Get project name *****************
cur_frm.fields_dict['project_name'].get_query = function(doc, cdt, cdn) {

View File

@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2012-11-28 11:26:21",
"modified_by": "Administrator",
"modified": "2012-11-26 11:56:10"
"modified": "2012-12-03 17:10:41"
},
{
"is_submittable": 1,

View File

@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2012-07-17 13:24:57",
"modified_by": "Administrator",
"modified": "2012-07-16 16:26:24"
"modified": "2012-12-03 17:10:41"
},
{
"is_submittable": 1,

View File

@ -8,68 +8,77 @@
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// along with this program. If not, see <http://www.gnu.org/licenses/>.
cur_frm.cscript.onload = function(doc, cdt, cdn) {
if (!doc.posting_date) doc.posting_date = dateutil.obj_to_str(new Date());
if (!doc.transfer_date) doc.transfer_date = dateutil.obj_to_str(new Date());
if(!doc.purpose) set_multiple(cdt, cdn, {purpose:'Material Issue'});
cfn_set_fields(doc, cdt, cdn);
if (!doc.posting_date) doc.posting_date = dateutil.obj_to_str(new Date());
if (!doc.transfer_date) doc.transfer_date = dateutil.obj_to_str(new Date());
if(!doc.purpose) set_multiple(cdt, cdn, {purpose:'Material Issue'});
cfn_set_fields(doc, cdt, cdn);
}
var cfn_set_fields = function(doc, cdt, cdn) {
lst = ['supplier','supplier_name','supplier_address','customer','customer_name','customer_address'];
if (in_list(['Material Issue', 'Material Transfer', 'Material Receipt', 'Sales Return', 'Purchase Return', 'Production Order', 'Subcontracting', 'Other'], doc.purpose)) {
hide_field(lst);
$(cur_frm.fields_dict.contact_section.row.wrapper).toggle(false);
} else unhide_field(lst);
lst = ['supplier', 'supplier_name', 'supplier_address',
'customer', 'customer_name', 'customer_address'];
if (in_list(['Material Issue', 'Material Transfer', 'Material Receipt', 'Sales Return',
'Purchase Return', 'Production Order', 'Subcontracting', 'Other'], doc.purpose)) {
hide_field(lst);
$(cur_frm.fields_dict.contact_section.row.wrapper).toggle(false);
} else unhide_field(lst);
if (doc.purpose == 'Production Order' || doc.purpose == 'Other') {
unhide_field('get_items');
hide_field(['from_warehouse', 'to_warehouse','purchase_receipt_no',
'delivery_note_no', 'sales_invoice_no','warehouse_html',
'transporter', 'is_excisable_goods', 'excisable_goods']);
if (doc.purpose=='Production Order') unhide_field(['production_order', 'process']);
else {
doc.production_order = doc.process = '';
hide_field(['production_order', 'process']);
}
if (doc.purpose == 'Production Order' || doc.purpose == 'Other'){
unhide_field('get_items');
hide_field(['from_warehouse', 'to_warehouse','purchase_receipt_no','delivery_note_no', 'sales_invoice_no','warehouse_html', 'transporter', 'is_excisable_goods', 'excisable_goods']);
if (doc.purpose=='Production Order') unhide_field(['production_order', 'process']);
else hide_field(['production_order', 'process']);
doc.from_warehouse = '';
doc.to_warehouse = '';
refresh_field(['from_warehosue', 'to_warehouse']);
if (doc.process == 'Backflush' || doc.purpose == 'Other'){
unhide_field('fg_completed_qty');
}
else{
hide_field('fg_completed_qty');
doc.fg_completed_qty = 0;
}
}
else{
unhide_field(['from_warehouse', 'to_warehouse']);
hide_field(['production_order', 'process', 'get_items', 'fg_completed_qty','purchase_receipt_no','delivery_note_no', 'sales_invoice_no']);
doc.production_order = '';
doc.process = '';
doc.fg_completed_qty = 0;
}
doc.from_warehouse = '';
doc.to_warehouse = '';
refresh_field(['from_warehosue', 'to_warehouse']);
if (doc.process == 'Backflush' || doc.purpose == 'Other') {
unhide_field('fg_completed_qty');
}
else{
hide_field('fg_completed_qty');
doc.fg_completed_qty = 0;
}
} else {
unhide_field(['from_warehouse', 'to_warehouse']);
hide_field(['production_order', 'process', 'get_items', 'fg_completed_qty',
'purchase_receipt_no','delivery_note_no', 'sales_invoice_no']);
doc.production_order = '';
doc.process = '';
doc.fg_completed_qty = 0;
}
if(doc.purpose == 'Purchase Return'){
doc.customer=doc.customer_name = doc.customer_address=doc.delivery_note_no=doc.sales_invoice_no='';
unhide_field(['supplier','supplier_name','supplier_address','purchase_receipt_no']);
$(cur_frm.fields_dict.contact_section.row.wrapper).toggle(true);
}
else if(doc.purpose == 'Sales Return'){
doc.supplier=doc.supplier_name = doc.supplier_address=doc.purchase_receipt_no='';
unhide_field(['customer','customer_name','customer_address','delivery_note_no', 'sales_invoice_no']);
$(cur_frm.fields_dict.contact_section.row.wrapper).toggle(true);
} else{
doc.customer=doc.customer_name=doc.customer_address=doc.delivery_note_no=doc.sales_invoice_no='';
doc.supplier=doc.supplier_name = doc.supplier_address=doc.purchase_receipt_no='';
}
refresh_many(lst);
if(doc.purpose == 'Purchase Return') {
doc.customer = doc.customer_name = doc.customer_address =
doc.delivery_note_no = doc.sales_invoice_no = '';
unhide_field(['supplier','supplier_name','supplier_address','purchase_receipt_no']);
$(cur_frm.fields_dict.contact_section.row.wrapper).toggle(true);
}
else if(doc.purpose == 'Sales Return'){
doc.supplier=doc.supplier_name = doc.supplier_address=doc.purchase_receipt_no='';
unhide_field(['customer', 'customer_name', 'customer_address',
'delivery_note_no', 'sales_invoice_no']);
$(cur_frm.fields_dict.contact_section.row.wrapper).toggle(true);
} else{
doc.customer = doc.customer_name = doc.customer_address =
doc.delivery_note_no = doc.sales_invoice_no = doc.supplier =
doc.supplier_name = doc.supplier_address = doc.purchase_receipt_no = '';
}
refresh_many(lst);
}
//Refresh
@ -77,47 +86,44 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
erpnext.hide_naming_series();
//India related
excise_flds = ['is_excisable_goods', 'excisable_goods', 'under_rule']
excise_flds = ['is_excisable_goods', 'excisable_goods', 'under_rule'];
if(wn.control_panel.country == 'India') unhide_field(excise_flds);
else hide_field(excise_flds);
}
cur_frm.cscript.delivery_note_no = function(doc,cdt,cdn){
if(doc.delivery_note_no) get_server_fields('get_cust_values','','',doc,cdt,cdn,1);
if(doc.delivery_note_no) get_server_fields('get_cust_values','','',doc,cdt,cdn,1);
}
cur_frm.cscript.sales_invoice_no = function(doc,cdt,cdn){
if(doc.sales_invoice_no) get_server_fields('get_cust_values','','',doc,cdt,cdn,1);
if(doc.sales_invoice_no) get_server_fields('get_cust_values','','',doc,cdt,cdn,1);
}
cur_frm.cscript.customer = function(doc,cdt,cdn){
if(doc.customer) get_server_fields('get_cust_addr','','',doc,cdt,cdn,1);
if(doc.customer) get_server_fields('get_cust_addr','','',doc,cdt,cdn,1);
}
cur_frm.cscript.purchase_receipt_no = function(doc,cdt,cdn){
if(doc.purchase_receipt_no) get_server_fields('get_supp_values','','',doc,cdt,cdn,1);
if(doc.purchase_receipt_no) get_server_fields('get_supp_values','','',doc,cdt,cdn,1);
}
cur_frm.cscript.supplier = function(doc,cdt,cdn){
if(doc.supplier) get_server_fields('get_supp_addr','','',doc,cdt,cdn,1);
if(doc.supplier) get_server_fields('get_supp_addr','','',doc,cdt,cdn,1);
}
cur_frm.fields_dict['production_order'].get_query = function(doc) {
return 'SELECT DISTINCT `tabProduction Order`.`name` FROM `tabProduction Order` WHERE `tabProduction Order`.`docstatus` = 1 AND `tabProduction Order`.`qty` > ifnull(`tabProduction Order`.`produced_qty`,0) AND `tabProduction Order`.`name` like "%s" ORDER BY `tabProduction Order`.`name` DESC LIMIT 50';
return 'SELECT DISTINCT `tabProduction Order`.`name` FROM `tabProduction Order` WHERE `tabProduction Order`.`docstatus` = 1 AND `tabProduction Order`.`qty` > ifnull(`tabProduction Order`.`produced_qty`,0) AND `tabProduction Order`.`name` like "%s" ORDER BY `tabProduction Order`.`name` DESC LIMIT 50';
}
cur_frm.cscript.purpose = function(doc, cdt, cdn) {
cfn_set_fields(doc, cdt, cdn);
cfn_set_fields(doc, cdt, cdn);
}
cur_frm.cscript.process = function(doc, cdt, cdn) {
cfn_set_fields(doc, cdt, cdn);
cfn_set_fields(doc, cdt, cdn);
}
//
// item code - only if quantity present in source warehosue
//
var fld = cur_frm.fields_dict['mtn_details'].grid.get_field('item_code');
@ -147,9 +153,7 @@ fld.get_query = function(doc, cdt, cdn) {
}
}
//
// copy over source and target warehouses
//
cur_frm.fields_dict['mtn_details'].grid.onrowadd = function(doc, cdt, cdn){
var d = locals[cdt][cdn];
if(!d.s_warehouse && doc.from_warehouse) {
@ -162,73 +166,88 @@ cur_frm.fields_dict['mtn_details'].grid.onrowadd = function(doc, cdt, cdn){
}
}
//========================= Overloaded query for link batch_no =============================================================
cur_frm.fields_dict['mtn_details'].grid.get_field('batch_no').get_query= function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(d.item_code){
return "SELECT tabBatch.name, tabBatch.description FROM tabBatch WHERE tabBatch.docstatus != 2 AND tabBatch.item = '"+ d.item_code +"' AND `tabBatch`.`name` like '%s' ORDER BY `tabBatch`.`name` DESC LIMIT 50"
}
else{
alert("Please enter Item Code.");
}
// Overloaded query for link batch_no
cur_frm.fields_dict['mtn_details'].grid.get_field('batch_no').get_query = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(d.item_code) {
if (d.s_warehouse) {
return "select batch_no from `tabStock Ledger Entry` sle \
where item_code = '" + d.item_code + "' and warehouse = '" + d.s_warehouse +
"' and ifnull(is_cancelled, 'No') = 'No' and batch_no like '%s' \
and exists(select * from `tabBatch` where \
name = sle.batch_no and expiry_date >= '" + doc.posting_date +
"' and docstatus != 2) group by batch_no having sum(actual_qty) > 0 \
order by batch_no desc limit 50";
} else {
return "SELECT name FROM tabBatch WHERE docstatus != 2 AND item = '" +
d.item_code + "' and expiry_date >= '" + doc.posting_date +
"' AND name like '%s' ORDER BY name DESC LIMIT 50";
}
} else {
msgprint("Please enter Item Code to get batch no");
}
}
//==================================================================================================================
cur_frm.cscript.item_code = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
// get values
args = {
'item_code' : d.item_code,
'warehouse' : cstr(d.s_warehouse),
'transfer_qty' : d.transfer_qty,
'serial_no' : d.serial_no
};
get_server_fields('get_item_details',JSON.stringify(args),'mtn_details',doc,cdt,cdn,1);
var d = locals[cdt][cdn];
args = {
'item_code' : d.item_code,
'warehouse' : cstr(d.s_warehouse) || cstr(d.t_warehouse),
'transfer_qty' : d.transfer_qty,
'serial_no' : d.serial_no,
'fg_item' : d.fg_item,
'bom_no' : d.bom_no
};
get_server_fields('get_item_details',JSON.stringify(args),'mtn_details',doc,cdt,cdn,1);
}
//==================================================================================================================
cur_frm.cscript.s_warehouse = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
args = {
'item_code' : d.item_code,
'warehouse' : cstr(d.s_warehouse) || cstr(d.t_warehouse),
'transfer_qty' : d.transfer_qty,
'serial_no' : d.serial_no,
'fg_item' : d.fg_item,
'bom_no' : d.bom_no
}
get_server_fields('get_warehouse_details', JSON.stringify(args),
'mtn_details', doc, cdt, cdn, 1);
}
cur_frm.cscript.t_warehouse = cur_frm.cscript.s_warehouse;
cur_frm.cscript.transfer_qty = function(doc,cdt,cdn) {
var d = locals[cdt][cdn];
if (doc.from_warehouse && (flt(d.transfer_qty) > flt(d.actual_qty))) {
alert("Transfer Quantity is more than Available Qty");
}
var d = locals[cdt][cdn];
if (doc.from_warehouse && (flt(d.transfer_qty) > flt(d.actual_qty))) {
alert("Transfer Quantity is more than Available Qty");
}
}
//==================================================================================================================
cur_frm.cscript.qty = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
set_multiple('Stock Entry Detail', d.name, {'transfer_qty': flt(d.qty) * flt(d.conversion_factor)}, 'mtn_details');
refresh_field('mtn_details');
var d = locals[cdt][cdn];
set_multiple('Stock Entry Detail', d.name, {'transfer_qty': flt(d.qty) * flt(d.conversion_factor)}, 'mtn_details');
refresh_field('mtn_details');
}
//==================================================================================================================
cur_frm.cscript.uom = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if(d.uom && d.item_code){
var arg = {'item_code':d.item_code, 'uom':d.uom, 'qty':d.qty}
get_server_fields('get_uom_details',JSON.stringify(arg),'mtn_details', doc, cdt, cdn, 1);
}
var d = locals[cdt][cdn];
if(d.uom && d.item_code){
var arg = {'item_code':d.item_code, 'uom':d.uom, 'qty':d.qty}
get_server_fields('get_uom_details',JSON.stringify(arg),'mtn_details', doc, cdt, cdn, 1);
}
}
//==================================================================================================================
//validate
cur_frm.cscript.validate = function(doc, cdt, cdn) {
cur_frm.cscript.validate_items(doc);
cur_frm.cscript.validate_items(doc);
}
//==================================================================================================================
//validate items
cur_frm.cscript.validate_items = function(doc) {
cl = getchildren('Stock Entry Detail',doc.name,'mtn_details');
if (!cl.length) {
alert("Item table can not be blank");
validated = false;
}
cl = getchildren('Stock Entry Detail',doc.name,'mtn_details');
if (!cl.length) {
alert("Item table can not be blank");
validated = false;
}
}
cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;

View File

@ -35,8 +35,6 @@ class DocType(TransactionBase):
self.item_dict = {}
self.fname = 'mtn_details'
# get item details
# ----------------
def get_item_details(self, arg):
import json
arg, actual_qty, in_rate = json.loads(arg), 0, 0
@ -44,28 +42,24 @@ class DocType(TransactionBase):
item = sql("select stock_uom, description, item_name from `tabItem` where name = %s and (ifnull(end_of_life,'')='' or end_of_life ='0000-00-00' or end_of_life > now())", (arg.get('item_code')), as_dict = 1)
if not item:
msgprint("Item is not active", raise_exception=1)
if arg.get('warehouse'):
actual_qty = self.get_as_on_stock(arg.get('item_code'), arg.get('warehouse'), self.doc.posting_date, self.doc.posting_time)
in_rate = self.get_incoming_rate(arg.get('item_code'), arg.get('warehouse'), self.doc.posting_date, self.doc.posting_time, arg.get('transfer_qty'), arg.get('serial_no')) or 0
ret = {
'uom' : item and item[0]['stock_uom'] or '',
'stock_uom' : item and item[0]['stock_uom'] or '',
'description' : item and item[0]['description'] or '',
'item_name' : item and item[0]['item_name'] or '',
'actual_qty' : actual_qty,
'qty' : 0,
'transfer_qty' : 0,
'incoming_rate' : in_rate,
'conversion_factor' : 1,
'batch_no' : ''
'batch_no' : '',
'actual_qty' : 0,
'incoming_rate' : 0
}
stock_and_rate = arg.get('warehouse') and self.get_warehouse_details(json.dumps(arg)) or {}
ret.update(stock_and_rate)
return ret
# Get UOM Details
# ----------------
def get_uom_details(self, arg = ''):
arg, ret = eval(arg), {}
uom = sql("select conversion_factor from `tabUOM Conversion Detail` where parent = %s and uom = %s", (arg['item_code'],arg['uom']), as_dict = 1)
@ -78,28 +72,44 @@ class DocType(TransactionBase):
'transfer_qty' : flt(arg['qty']) * flt(uom[0]['conversion_factor']),
}
return ret
# get stock and incoming rate on posting date
# ---------------------------------------------
def get_warehouse_details(self, arg):
import json
arg, actual_qty, in_rate = json.loads(arg), 0, 0
ret = {
"actual_qty" : self.get_as_on_stock(arg.get('item_code'), arg.get('warehouse'),
self.doc.posting_date, self.doc.posting_time),
"incoming_rate" : self.get_incoming_rate(arg.get('item_code'),
arg.get('warehouse'), self.doc.posting_date, self.doc.posting_time,
arg.get('transfer_qty'), arg.get('serial_no'), arg.get('fg_item'),
arg.get('bom_no')) or 0
}
return ret
def get_stock_and_rate(self, bom_no = ''):
""" get stock and incoming rate on posting date"""
for d in getlist(self.doclist, 'mtn_details'):
# assign parent warehouse
d.s_warehouse = cstr(d.s_warehouse) or self.doc.purpose != 'Production Order' and self.doc.from_warehouse or ''
d.t_warehouse = cstr(d.t_warehouse) or self.doc.purpose != 'Production Order' and self.doc.to_warehouse or ''
d.s_warehouse = cstr(d.s_warehouse) or self.doc.purpose != 'Production Order' \
and self.doc.from_warehouse or ''
d.t_warehouse = cstr(d.t_warehouse) or self.doc.purpose != 'Production Order' \
and self.doc.to_warehouse or ''
# get current stock at source warehouse
d.actual_qty = d.s_warehouse and self.get_as_on_stock(d.item_code, d.s_warehouse, self.doc.posting_date, self.doc.posting_time) or 0
d.actual_qty = self.get_as_on_stock(d.item_code, d.s_warehouse or d.t_warehouse,
self.doc.posting_date, self.doc.posting_time) or 0
# get incoming rate
if not flt(d.incoming_rate):
d.incoming_rate = self.get_incoming_rate(d.item_code, d.s_warehouse, self.doc.posting_date, self.doc.posting_time, d.transfer_qty, d.serial_no, d.fg_item, d.bom_no or bom_no)
d.incoming_rate = self.get_incoming_rate(d.item_code,
d.s_warehouse or d.t_warehouse, self.doc.posting_date,
self.doc.posting_time, d.transfer_qty, d.serial_no,
d.fg_item, d.bom_no or bom_no)
# Get stock qty on any date
# ---------------------------
def get_as_on_stock(self, item, wh, dt, tm):
"""Get stock qty on any date"""
bin = sql("select name from tabBin where item_code = %s and warehouse = %s", (item, wh))
bin_id = bin and bin[0][0] or ''
prev_sle = bin_id and get_obj('Bin', bin_id).get_prev_sle(dt, tm) or {}
@ -107,17 +117,15 @@ class DocType(TransactionBase):
return qty
# Get incoming rate
# -------------------
def get_incoming_rate(self, item, wh, dt, tm, qty = 0, serial_no = '', fg_item = 0, bom_no = ''):
def get_incoming_rate(self, item, wh, dt, tm, qty=0, serial_no='', fg_item=0, bom_no=''):
in_rate = 0
if fg_item and bom_no:
# re-calculate cost for production item from bom
get_obj('BOM Control').calculate_cost(bom_no)
bom_obj = get_obj('BOM', bom_no)
in_rate = flt(bom_obj.doc.total_cost) / (flt(bom_obj.doc.quantity) or 1)
in_rate = webnotes.conn.sql("""select ifnull(total_cost, 0) / ifnull(quantity, 1)
from `tabBOM` where name = %s and docstatus=1""", bom_no, debug=1)
in_rate = in_rate and in_rate[0][0] or 0
elif wh:
in_rate = get_obj('Valuation Control').get_incoming_rate(dt, tm, item, wh, qty, serial_no)
in_rate = get_obj('Valuation Control').get_incoming_rate(dt, tm,
item, wh, qty, serial_no)
return in_rate
@ -205,6 +213,10 @@ class DocType(TransactionBase):
def validate_bom_no(self):
if self.doc.bom_no:
if not webnotes.conn.sql("""select name from tabBOM where name = %s and docstatus = 1
and ifnull(is_active, 'No') = 'Yes'""", self.doc.bom_no):
msgprint("""BOM: %s not found, may be it has been cancelled or inactivated""" %
self.doc.bom_no, raise_exception=1)
if not self.doc.fg_completed_qty:
msgprint("Please enter FG Completed Qty", raise_exception=1)
@ -215,7 +227,8 @@ class DocType(TransactionBase):
self.validate_for_production_order(pro_obj)
bom_no = pro_obj.doc.bom_no
fg_qty = (self.doc.process == 'Backflush') and flt(self.doc.fg_completed_qty) or flt(pro_obj.doc.qty)
fg_qty = (self.doc.process == 'Backflush') and flt(self.doc.fg_completed_qty) \
or flt(pro_obj.doc.qty)
use_multi_level_bom = pro_obj.doc.use_multi_level_bom
elif self.doc.purpose == 'Other':
self.validate_bom_no()
@ -234,22 +247,30 @@ class DocType(TransactionBase):
if self.doc.process == 'Backflush':
sw = ''
tw = cstr(pro_obj.doc.fg_warehouse)
fg_item_dict = {cstr(pro_obj.doc.production_item) : [self.doc.fg_completed_qty, pro_obj.doc.description, pro_obj.doc.stock_uom]}
fg_item_dict = {
cstr(pro_obj.doc.production_item) : [self.doc.fg_completed_qty,
pro_obj.doc.description, pro_obj.doc.stock_uom]
}
elif self.doc.purpose == 'Other' and self.doc.bom_no:
sw, tw = '', ''
item = sql("select item, description, uom from `tabBOM` where name = %s", self.doc.bom_no, as_dict=1)
fg_item_dict = {item[0]['item'] : [self.doc.fg_completed_qty, item[0]['description'], item[0]['uom']]}
fg_item_dict = {
item[0]['item'] : [self.doc.fg_completed_qty,
item[0]['description'], item[0]['uom']]
}
if fg_item_dict:
self.add_to_stock_entry_detail(sw, tw, fg_item_dict, fg_item = 1, bom_no = bom_no)
self.get_stock_and_rate()
def validate_transfer_qty(self):
for d in getlist(self.doclist, 'mtn_details'):
if flt(d.transfer_qty) <= 0:
msgprint("Transfer Quantity can not be less than or equal to zero at Row No " + cstr(d.idx))
raise Exception
msgprint("Transfer Quantity can not be less than or equal to zero \
at Row No " + cstr(d.idx), raise_exception=1)
def calc_amount(self):
@ -326,8 +347,10 @@ class DocType(TransactionBase):
self.validate_incoming_rate()
self.validate_bom_belongs_to_item()
self.calc_amount()
get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.posting_date,'Posting Date')
get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year,
self.doc.posting_date, 'Posting Date')
if self.doc.purpose == 'Other':
self.validate_bom_no()
# If target warehouse exists, incoming rate is mandatory
# --------------------------------------------------------

View File

@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2012-11-28 11:26:22",
"modified_by": "Administrator",
"modified": "2012-11-30 14:10:02"
"modified": "2012-12-03 12:00:59"
},
{
"is_submittable": 1,
@ -414,7 +414,9 @@
},
{
"print_hide": 1,
"description": "Get valuation rate and available stock at source/target warehouse on mentioned posting date-time. If serialized item, please press this button after entering serial nos.",
"oldfieldtype": "Button",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Get Stock and Rate",
"options": "get_stock_and_rate",

View File

@ -1,266 +1,218 @@
# DocType, Stock Entry Detail
[
# These values are common in all dictionaries
{
'creation': '2012-04-13 11:56:38',
'docstatus': 0,
'modified': '2012-05-01 16:16:20',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'autoname': u'MTND/.######',
'colour': u'White:FFF',
'default_print_format': u'Standard',
'doctype': 'DocType',
'istable': 1,
'module': u'Stock',
'name': '__common__',
'section_style': u'Tray',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 1
},
# These values are common for all DocField
{
'doctype': u'DocField',
'name': '__common__',
'parent': u'Stock Entry Detail',
'parentfield': u'fields',
'parenttype': u'DocType'
},
# DocType, Stock Entry Detail
{
'doctype': 'DocType',
'name': u'Stock Entry Detail'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u's_warehouse',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'Source Warehouse',
'oldfieldname': u's_warehouse',
'oldfieldtype': u'Link',
'options': u'Warehouse',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u't_warehouse',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'Target Warehouse',
'oldfieldname': u't_warehouse',
'oldfieldtype': u'Link',
'options': u'Warehouse',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'item_code',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'Item Code',
'oldfieldname': u'item_code',
'oldfieldtype': u'Link',
'options': u'Item',
'permlevel': 0,
'reqd': 1,
'search_index': 1,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'description',
'fieldtype': u'Text',
'label': u'Description',
'oldfieldname': u'description',
'oldfieldtype': u'Text',
'permlevel': 0,
'width': u'300px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'qty',
'fieldtype': u'Currency',
'label': u'Qty',
'oldfieldname': u'qty',
'oldfieldtype': u'Currency',
'permlevel': 0,
'reqd': 1,
'trigger': u'Client'
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'uom',
'fieldtype': u'Link',
'label': u'UOM',
'oldfieldname': u'uom',
'oldfieldtype': u'Link',
'options': u'UOM',
'permlevel': 0,
'reqd': 1,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'incoming_rate',
'fieldtype': u'Currency',
'label': u'Incoming Rate',
'oldfieldname': u'incoming_rate',
'oldfieldtype': u'Currency',
'permlevel': 0,
'reqd': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'amount',
'fieldtype': u'Currency',
'label': u'Amount',
'oldfieldname': u'amount',
'oldfieldtype': u'Currency',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'serial_no',
'fieldtype': u'Text',
'label': u'Serial No',
'no_copy': 1,
'oldfieldname': u'serial_no',
'oldfieldtype': u'Text',
'permlevel': 0,
'reqd': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'batch_no',
'fieldtype': u'Link',
'label': u'Batch No',
'oldfieldname': u'batch_no',
'oldfieldtype': u'Link',
'options': u'Batch',
'permlevel': 0,
'print_hide': 1,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'reqd_qty',
'fieldtype': u'Currency',
'in_filter': 0,
'label': u'Reqd Qty',
'oldfieldname': u'reqd_qty',
'oldfieldtype': u'Currency',
'permlevel': 3,
'print_hide': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'actual_qty',
'fieldtype': u'Read Only',
'in_filter': 1,
'label': u'Actual Qty (at source)',
'no_copy': 1,
'oldfieldname': u'actual_qty',
'oldfieldtype': u'Read Only',
'permlevel': 1,
'print_hide': 1,
'reqd': 0,
'search_index': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'conversion_factor',
'fieldtype': u'Currency',
'label': u'Conversion Factor',
'oldfieldname': u'conversion_factor',
'oldfieldtype': u'Currency',
'permlevel': 1,
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'transfer_qty',
'fieldtype': u'Currency',
'label': u'Stock Qty',
'oldfieldname': u'transfer_qty',
'oldfieldtype': u'Currency',
'permlevel': 1,
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'stock_uom',
'fieldtype': u'Link',
'in_filter': 0,
'label': u'Stock UOM',
'oldfieldname': u'stock_uom',
'oldfieldtype': u'Link',
'options': u'UOM',
'permlevel': 1,
'reqd': 1,
'search_index': 0
},
# DocField
{
'description': u'BOM No. for a Finished Good Item',
'doctype': u'DocField',
'fieldname': u'bom_no',
'fieldtype': u'Link',
'label': u'BOM No.',
'options': u'BOM',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'fg_item',
'fieldtype': u'Check',
'in_filter': 1,
'label': u'FG Item',
'oldfieldname': u'fg_item',
'oldfieldtype': u'Check',
'permlevel': 0,
'print_hide': 1
}
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-07-03 13:29:47",
"modified_by": "Administrator",
"modified": "2012-12-03 11:37:17"
},
{
"istable": 1,
"autoname": "MTND/.######",
"name": "__common__",
"default_print_format": "Standard",
"doctype": "DocType",
"module": "Stock"
},
{
"name": "__common__",
"parent": "Stock Entry Detail",
"doctype": "DocField",
"parenttype": "DocType",
"parentfield": "fields"
},
{
"name": "Stock Entry Detail",
"doctype": "DocType"
},
{
"oldfieldtype": "Link",
"doctype": "DocField",
"label": "Source Warehouse",
"oldfieldname": "s_warehouse",
"options": "Warehouse",
"fieldname": "s_warehouse",
"fieldtype": "Link",
"permlevel": 0,
"in_filter": 1
},
{
"oldfieldtype": "Link",
"doctype": "DocField",
"label": "Target Warehouse",
"oldfieldname": "t_warehouse",
"options": "Warehouse",
"fieldname": "t_warehouse",
"fieldtype": "Link",
"permlevel": 0,
"in_filter": 1
},
{
"oldfieldtype": "Link",
"doctype": "DocField",
"label": "Item Code",
"oldfieldname": "item_code",
"permlevel": 0,
"trigger": "Client",
"fieldname": "item_code",
"fieldtype": "Link",
"search_index": 1,
"reqd": 1,
"options": "Item",
"in_filter": 1
},
{
"oldfieldtype": "Text",
"doctype": "DocField",
"label": "Description",
"oldfieldname": "description",
"width": "300px",
"fieldname": "description",
"fieldtype": "Text",
"permlevel": 0
},
{
"oldfieldtype": "Currency",
"doctype": "DocField",
"label": "Qty",
"oldfieldname": "qty",
"trigger": "Client",
"fieldname": "qty",
"fieldtype": "Currency",
"reqd": 1,
"permlevel": 0
},
{
"oldfieldtype": "Link",
"colour": "White:FFF",
"doctype": "DocField",
"label": "UOM",
"oldfieldname": "uom",
"trigger": "Client",
"fieldname": "uom",
"fieldtype": "Link",
"reqd": 1,
"options": "UOM",
"permlevel": 0
},
{
"oldfieldtype": "Currency",
"doctype": "DocField",
"label": "Valuation Rate",
"oldfieldname": "incoming_rate",
"fieldname": "incoming_rate",
"fieldtype": "Currency",
"reqd": 0,
"permlevel": 0
},
{
"oldfieldtype": "Currency",
"doctype": "DocField",
"label": "Amount",
"oldfieldname": "amount",
"fieldname": "amount",
"fieldtype": "Currency",
"permlevel": 1
},
{
"no_copy": 1,
"oldfieldtype": "Text",
"doctype": "DocField",
"label": "Serial No",
"oldfieldname": "serial_no",
"fieldname": "serial_no",
"fieldtype": "Text",
"reqd": 0,
"permlevel": 0
},
{
"print_hide": 1,
"oldfieldtype": "Link",
"doctype": "DocField",
"label": "Batch No",
"oldfieldname": "batch_no",
"trigger": "Client",
"fieldname": "batch_no",
"fieldtype": "Link",
"options": "Batch",
"permlevel": 0
},
{
"print_hide": 1,
"oldfieldtype": "Currency",
"doctype": "DocField",
"label": "Reqd Qty",
"oldfieldname": "reqd_qty",
"fieldname": "reqd_qty",
"fieldtype": "Currency",
"permlevel": 3,
"in_filter": 0
},
{
"print_hide": 1,
"no_copy": 1,
"oldfieldtype": "Read Only",
"doctype": "DocField",
"label": "Actual Qty (at source/target)",
"oldfieldname": "actual_qty",
"fieldname": "actual_qty",
"fieldtype": "Read Only",
"search_index": 1,
"reqd": 0,
"permlevel": 1,
"in_filter": 1
},
{
"oldfieldtype": "Currency",
"doctype": "DocField",
"label": "Conversion Factor",
"oldfieldname": "conversion_factor",
"fieldname": "conversion_factor",
"fieldtype": "Currency",
"reqd": 1,
"permlevel": 1
},
{
"oldfieldtype": "Currency",
"doctype": "DocField",
"label": "Stock Qty",
"oldfieldname": "transfer_qty",
"fieldname": "transfer_qty",
"fieldtype": "Currency",
"reqd": 1,
"permlevel": 1
},
{
"oldfieldtype": "Link",
"doctype": "DocField",
"label": "Stock UOM",
"oldfieldname": "stock_uom",
"options": "UOM",
"fieldname": "stock_uom",
"fieldtype": "Link",
"search_index": 0,
"reqd": 1,
"permlevel": 1,
"in_filter": 0
},
{
"description": "BOM No. for a Finished Good Item",
"doctype": "DocField",
"label": "BOM No",
"options": "BOM",
"fieldname": "bom_no",
"fieldtype": "Link",
"permlevel": 0
},
{
"print_hide": 1,
"oldfieldtype": "Check",
"doctype": "DocField",
"label": "FG Item",
"oldfieldname": "fg_item",
"fieldname": "fg_item",
"fieldtype": "Check",
"permlevel": 0,
"in_filter": 1
}
]

View File

@ -37,15 +37,12 @@ class DocType:
if (batch_bal + self.doc.actual_qty) < 0:
msgprint("""Not enough quantity (requested: %(actual_qty)s, current: %(batch_bal)s in Batch
<b>%(batch_no)s</b> for Item <b>%(item_code)s</b> at Warehouse<b>%(warehouse)s</b>
<b>%(batch_no)s</b> for Item <b>%(item_code)s</b> at Warehouse <b>%(warehouse)s</b>
as on %(posting_date)s %(posting_time)s""" % self.doc.fields, raise_exception = 1)
self.doc.fields.pop('batch_bal')
# mandatory
# ---------
def validate_mandatory(self):
mandatory = ['warehouse','transaction_date','posting_date','voucher_type','voucher_no','actual_qty','company','fiscal_year']
for k in mandatory:
@ -55,9 +52,6 @@ class DocType:
if not sql("select name from tabWarehouse where name = '%s'" % self.doc.fields.get(k)):
msgprint("Warehouse: '%s' does not exist in the system. Please check." % self.doc.fields.get(k), raise_exception = 1)
# validate for item
# -----------------
def validate_item(self):
item_det = sql("select name, has_batch_no, docstatus from tabItem where name = '%s'" % self.doc.item_code)

View File

@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2012-11-28 11:26:23",
"modified_by": "Administrator",
"modified": "2012-11-26 11:19:39"
"modified": "2012-12-03 17:10:41"
},
{
"is_submittable": 1,

View File

@ -4,7 +4,7 @@
"docstatus": 0,
"creation": "2012-11-28 11:26:23",
"modified_by": "Administrator",
"modified": "2012-11-26 11:18:43"
"modified": "2012-12-03 17:10:41"
},
{
"autoname": "naming_series:",