sales bom amendment issue fixed

This commit is contained in:
Nabin Hait 2012-04-27 11:06:12 +05:30
parent 5a6e641565
commit 762056aaa8
2 changed files with 288 additions and 190 deletions

View File

@ -67,7 +67,7 @@ class DocType:
msgprint("Sales Bom Item " + d.item_code +" cannot be child item.")
raise Exception
# Check if is_main_item is modified once saved
if not self.doc.fields.get('__islocal') and d.is_main_item == "Yes" and cstr(d.item_code) != cstr(self.doc.name)[:-3] :
if not self.doc.fields.get('__islocal') and d.is_main_item == "Yes" and cstr(d.item_code) != cstr(self.doc.new_item_code)[:-3]:
msgprint("Modifying the main item is not allowed.")
raise Exception
if len(is_main_item) > 1:
@ -193,19 +193,17 @@ class DocType:
return
# get all Sales BOM that have the first item
sbl = sql("select distinct parent from `tabSales BOM Detail` where item_code=%s", il[0].item_code)
sbl = sql("select distinct parent from `tabSales BOM Detail` where item_code=%s and parent != %s and docstatus != 2", (il[0].item_code, self.doc.name))
# check all siblings
sub_items = [[d.item_code, flt(d.qty)] for d in il]
for s in sbl:
if not cstr(s[0]) == cstr(self.doc.name) :
t = sql("select item_code, qty from `tabSales BOM Detail` where parent=%s", s[0])
t = [[d[0], flt(d[1])] for d in t]
t = sql("select item_code, qty from `tabSales BOM Detail` where parent=%s and docstatus != 2", s[0])
t = [[d[0], flt(d[1])] for d in t]
if self.has_same_items(sub_items, t):
msgprint("%s has the same Sales BOM details" % s[0])
raise Exception
if self.has_same_items(sub_items, t):
msgprint("%s has the same Sales BOM details" % s[0])
raise Exception
if finder:
msgprint("There is no Sales BOM present with the following Combination.")
@ -218,4 +216,4 @@ class DocType:
for l in l1:
if l not in l2:
return 0
return 1
return 1

View File

@ -3,50 +3,78 @@
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:09:21',
'creation': '2009-05-12 16:47:47',
'docstatus': 0,
'modified': '2010-12-23 11:43:34',
'modified_by': 'umair@iwebnotes.com',
'owner': 'Administrator'
'modified': '2012-04-27 10:32:49',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'_last_update': u'1332222225',
'allow_attach': 0,
'allow_copy': 0,
'allow_email': 0,
'allow_print': 0,
'allow_rename': 0,
'allow_trash': 1,
'colour': 'White:FFF',
'colour': u'White:FFF',
'doctype': 'DocType',
'document_type': 'Master',
'module': 'Stock',
'document_type': u'Master',
'hide_heading': 0,
'hide_toolbar': 0,
'in_create': 0,
'in_dialog': 0,
'is_transaction_doc': 0,
'issingle': 0,
'max_attachments': 0,
'module': u'Stock',
'name': '__common__',
'section_style': 'Simple',
'server_code_error': ' ',
'read_only': 0,
'read_only_onload': 0,
'section_style': u'Simple',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 37
'use_template': 0,
'version': 1
},
# These values are common for all DocField
{
'doctype': 'DocField',
'doctype': u'DocField',
'name': '__common__',
'parent': 'Sales BOM',
'parentfield': 'fields',
'parenttype': 'DocType'
'parent': u'Sales BOM',
'parentfield': u'fields',
'parenttype': u'DocType'
},
# These values are common for all DocPerm
{
'doctype': 'DocPerm',
'doctype': u'DocPerm',
'name': '__common__',
'parent': 'Sales BOM',
'parentfield': 'permissions',
'parenttype': 'DocType',
'parent': u'Sales BOM',
'parentfield': u'permissions',
'parenttype': u'DocType',
'read': 1
},
# DocType, Sales BOM
{
'doctype': 'DocType',
'name': 'Sales BOM'
'name': u'Sales BOM'
},
# DocPerm
{
'amend': 0,
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Sales User',
'submit': 0,
'write': 1
},
# DocPerm
@ -54,10 +82,21 @@
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 1,
'doctype': u'DocPerm',
'permlevel': 1,
'role': 'Material Manager',
'role': u'Sales User',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Material Manager',
'submit': 0,
'write': 0
},
@ -67,10 +106,9 @@
'amend': 1,
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'idx': 2,
'doctype': u'DocPerm',
'permlevel': 0,
'role': 'Material Manager',
'role': u'Material Manager',
'submit': 1,
'write': 1
},
@ -80,10 +118,9 @@
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 3,
'doctype': u'DocPerm',
'permlevel': 1,
'role': 'Material User',
'role': u'Material User',
'submit': 0,
'write': 0
},
@ -93,182 +130,245 @@
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 4,
'doctype': u'DocPerm',
'permlevel': 0,
'role': 'Material User',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'idx': 5,
'permlevel': 0,
'role': 'Sales User',
'submit': 0,
'write': 1
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 6,
'permlevel': 1,
'role': 'Sales User',
'role': u'Material User',
'submit': 0,
'write': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'trash_reason',
'fieldtype': 'Small Text',
'idx': 1,
'label': 'Trash Reason',
'oldfieldname': 'trash_reason',
'oldfieldtype': 'Small Text',
'permlevel': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'new_item_code',
'fieldtype': 'Data',
'idx': 2,
'label': 'New Item Code',
'allow_on_submit': 0,
'doctype': u'DocField',
'fieldname': u'new_item_code',
'fieldtype': u'Data',
'hidden': 0,
'in_filter': 0,
'label': u'New Item Code',
'no_copy': 1,
'oldfieldname': 'new_item_code',
'oldfieldtype': 'Data',
'oldfieldname': u'new_item_code',
'oldfieldtype': u'Data',
'permlevel': 1,
'reqd': 0
'print_hide': 0,
'report_hide': 0,
'reqd': 0,
'search_index': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'new_item_name',
'fieldtype': 'Data',
'idx': 3,
'label': 'New Item Name',
'oldfieldname': 'new_item_name',
'oldfieldtype': 'Data',
'allow_on_submit': 0,
'doctype': u'DocField',
'fieldname': u'new_item_name',
'fieldtype': u'Data',
'hidden': 0,
'in_filter': 0,
'label': u'New Item Name',
'no_copy': 0,
'oldfieldname': u'new_item_name',
'oldfieldtype': u'Data',
'permlevel': 1,
'print_hide': 0,
'report_hide': 0,
'reqd': 0,
'search_index': 0
},
# DocField
{
'allow_on_submit': 0,
'doctype': u'DocField',
'fieldname': u'new_item_brand',
'fieldtype': u'Data',
'hidden': 0,
'in_filter': 0,
'label': u'New Item Brand',
'no_copy': 0,
'oldfieldname': u'new_item_brand',
'oldfieldtype': u'Data',
'permlevel': 1,
'print_hide': 0,
'report_hide': 0,
'reqd': 0,
'search_index': 0
},
# DocField
{
'allow_on_submit': 0,
'doctype': u'DocField',
'fieldname': u'description',
'fieldtype': u'Text',
'hidden': 0,
'in_filter': 0,
'label': u'New Description',
'no_copy': 0,
'oldfieldname': u'description',
'oldfieldtype': u'Text',
'permlevel': 1,
'print_hide': 0,
'report_hide': 0,
'reqd': 0,
'search_index': 0,
'width': u'300px'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'amended_from',
'fieldtype': u'Data',
'label': u'Amended From',
'permlevel': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'new_item_brand',
'fieldtype': 'Data',
'idx': 4,
'label': 'New Item Brand',
'oldfieldname': 'new_item_brand',
'oldfieldtype': 'Data',
'doctype': u'DocField',
'fieldname': u'amendment_date',
'fieldtype': u'Date',
'label': u'Amendment Date',
'permlevel': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'description',
'fieldtype': 'Text',
'idx': 5,
'label': 'New Description',
'oldfieldname': 'description',
'oldfieldtype': 'Text',
'allow_on_submit': 0,
'doctype': u'DocField',
'fieldname': u'item_group',
'fieldtype': u'Link',
'hidden': 0,
'in_filter': 0,
'label': u'Item Group',
'no_copy': 0,
'oldfieldname': u'item_group',
'oldfieldtype': u'Link',
'options': u'Item Group',
'permlevel': 0,
'print_hide': 0,
'report_hide': 0,
'reqd': 0,
'search_index': 0
},
# DocField
{
'allow_on_submit': 0,
'doctype': u'DocField',
'fieldname': u'price_list',
'fieldtype': u'Select',
'hidden': 0,
'in_filter': 0,
'label': u'Price List',
'no_copy': 0,
'oldfieldname': u'price_list',
'oldfieldtype': u'Select',
'options': u'link:Price List',
'permlevel': 0,
'print_hide': 0,
'report_hide': 0,
'reqd': 0,
'search_index': 0,
'trigger': u'Client'
},
# DocField
{
'allow_on_submit': 0,
'doctype': u'DocField',
'fieldname': u'currency',
'fieldtype': u'Select',
'hidden': 0,
'in_filter': 0,
'label': u'Currency',
'no_copy': 0,
'oldfieldname': u'currency',
'oldfieldtype': u'Select',
'options': u'link:Currency',
'permlevel': 0,
'print_hide': 0,
'report_hide': 0,
'reqd': 0,
'search_index': 0,
'trigger': u'Client'
},
# DocField
{
'allow_on_submit': 0,
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldtype': u'Button',
'hidden': 0,
'in_filter': 0,
'label': u'Find Sales BOM',
'no_copy': 0,
'oldfieldtype': u'Button',
'permlevel': 0,
'print_hide': 0,
'report_hide': 0,
'reqd': 0,
'search_index': 0,
'trigger': u'Client'
},
# DocField
{
'allow_on_submit': 0,
'doctype': u'DocField',
'fieldname': u'sales_bom_items',
'fieldtype': u'Table',
'hidden': 0,
'in_filter': 0,
'label': u'Sales BOM Items',
'no_copy': 0,
'oldfieldname': u'sales_bom_items',
'oldfieldtype': u'Table',
'options': u'Sales BOM Detail',
'permlevel': 0,
'print_hide': 0,
'report_hide': 0,
'reqd': 0,
'search_index': 0
},
# DocField
{
'allow_on_submit': 0,
'doctype': u'DocField',
'fieldname': u'stock_uom',
'fieldtype': u'Link',
'hidden': 0,
'in_filter': 0,
'label': u'Stock UOM',
'no_copy': 0,
'oldfieldname': u'stock_uom',
'oldfieldtype': u'Link',
'options': u'UOM',
'permlevel': 0,
'print_hide': 0,
'report_hide': 0,
'reqd': 0,
'search_index': 0
},
# DocField
{
'allow_on_submit': 0,
'doctype': u'DocField',
'fieldname': u'trash_reason',
'fieldtype': u'Small Text',
'hidden': 0,
'in_filter': 0,
'label': u'Trash Reason',
'no_copy': 0,
'oldfieldname': u'trash_reason',
'oldfieldtype': u'Small Text',
'permlevel': 1,
'width': '300px'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'item_group',
'fieldtype': 'Link',
'idx': 7,
'label': 'Item Group',
'oldfieldname': 'item_group',
'oldfieldtype': 'Link',
'options': 'Item Group',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'price_list',
'fieldtype': 'Select',
'idx': 8,
'label': 'Price List',
'oldfieldname': 'price_list',
'oldfieldtype': 'Select',
'options': 'link:Price List',
'permlevel': 0,
'trigger': 'Client'
},
# DocField
{
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'currency',
'fieldtype': 'Select',
'idx': 9,
'label': 'Currency',
'oldfieldname': 'currency',
'oldfieldtype': 'Select',
'options': 'link:Currency',
'permlevel': 0,
'trigger': 'Client'
},
# DocField
{
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldtype': 'Button',
'idx': 10,
'label': 'Find Sales BOM',
'oldfieldtype': 'Button',
'permlevel': 0,
'trigger': 'Client'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'sales_bom_items',
'fieldtype': 'Table',
'idx': 11,
'label': 'Sales BOM Items',
'oldfieldname': 'sales_bom_items',
'oldfieldtype': 'Table',
'options': 'Sales BOM Detail',
'permlevel': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'stock_uom',
'fieldtype': 'Link',
'idx': 12,
'label': 'Stock UOM',
'oldfieldname': 'stock_uom',
'oldfieldtype': 'Link',
'options': 'UOM',
'permlevel': 0,
'print_hide': 0,
'report_hide': 0,
'reqd': 0,
'search_index': 0
}
]