fixed conflict using ours
diff --git a/erpnext/stock/doctype/sales_bom/sales_bom.py b/erpnext/stock/doctype/sales_bom/sales_bom.py
index 39fa2cd..93d7008 100644
--- a/erpnext/stock/doctype/sales_bom/sales_bom.py
+++ b/erpnext/stock/doctype/sales_bom/sales_bom.py
@@ -67,7 +67,7 @@
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 @@
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 @@
for l in l1:
if l not in l2:
return 0
- return 1
\ No newline at end of file
+ return 1
diff --git a/erpnext/stock/search_criteria/stock_report/stock_report.js b/erpnext/stock/search_criteria/stock_report/stock_report.js
index 5451eb1..d08d1e7 100644
--- a/erpnext/stock/search_criteria/stock_report/stock_report.js
+++ b/erpnext/stock/search_criteria/stock_report/stock_report.js
@@ -19,7 +19,7 @@
this.mytabs.items['Select Columns'].hide()
this.mytabs.items['More Filters'].hide()
this.hide_all_filters();
- this.add_filter({fieldname:'based_on', label:'Based On', fieldtype:'Select', options:'Warehouse'+NEWLINE+'Item Code',report_default:'Warehouse',ignore : 1,parent:'Stock Ledger Entry'});
+ this.add_filter({fieldname:'based_on', label:'Based On', fieldtype:'Select', options:'Warehouse'+NEWLINE+'Item Code',ignore : 1,parent:'Stock Ledger Entry'});
this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'To Posting Date'].df.filter_hide = 0;
this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Item Code'].df.filter_hide = 0;
this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Warehouse'].df.filter_hide = 0;
@@ -57,8 +57,8 @@
ware_type_cond = repl(' AND `tabWarehouse`.warehouse_type IN (%(war)s)', {war: war.substr(0,war.length-1)})
}
- if(based_on.length == 1){
- if(based_on == 'Item Code'){
+ if(based_on.length == 1 && based_on[0]){
+ if(based_on[0] == 'Item Code'){
cols = '`tabItem`.name AS "Item Code", `tabItem`.item_name AS "Item Name", `tabItem`.description AS "Description", `tabItem`.stock_uom AS "Stock UOM"';
cond = '(IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` = "0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND `tabItem`.is_stock_item = "Yes"';
if(item_code) cond += repl(' AND `tabItem`.name = %(item)s', {item:'"'+item_code+'"'});
@@ -66,7 +66,7 @@
tables = '`tabItem`';
group_by = '`tabStock Ledger Entry`.item_code';
}
- else if(based_on == 'Warehouse'){
+ else if(based_on[0] == 'Warehouse'){
cols = '`tabWarehouse`.name AS "Warehouse", `tabWarehouse`.warehouse_type AS "Warehouse Type"';
cond = '`tabWarehouse`.docstatus < 2'
if(warehouse) cond += repl(' AND `tabWarehouse`.name = %(warehouse)s', {warehouse:'"'+warehouse+'"'});
@@ -74,8 +74,7 @@
tables = '`tabWarehouse`';
group_by = '`tabStock Ledger Entry`.warehouse';
}
- }
- else if(based_on.length == 2){
+ } else {
cols = '`tabItem`.name AS "Item Code", `tabItem`.item_name AS "Item Name", `tabItem`.description AS "Description", `tabItem`.stock_uom AS "Stock UOM", `tabWarehouse`.name AS "Warehouse", `tabWarehouse`.warehouse_type AS "Warehouse Type"';
cond = '(IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` = "0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND `tabItem`.is_stock_item = "Yes" AND `tabWarehouse`.docstatus < 2';
if(item_code) cond += repl(" AND `tabItem`.name = %(item)s", {item:"'"+item_code+"'"});
@@ -87,4 +86,4 @@
q = repl("SELECT %(cols)s FROM %(tables)s, `tabStock Ledger Entry` WHERE %(cond)s %(date_cond)s GROUP BY %(group_by)s", {cols:cols, tables:tables, cond:cond, date_cond:date_cond, group_by:group_by});
return q;
-}
\ No newline at end of file
+}
diff --git a/erpnext/stock/search_criteria/stock_report/stock_report.py b/erpnext/stock/search_criteria/stock_report/stock_report.py
index 84866e9..b87f684 100644
--- a/erpnext/stock/search_criteria/stock_report/stock_report.py
+++ b/erpnext/stock/search_criteria/stock_report/stock_report.py
@@ -14,19 +14,16 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-if not filter_values.get('based_on'):
- msgprint("Please Select Based On")
- raise Exception
cols, columns = [], []
# Add columns
# ------------
based_on = filter_values.get('based_on').split(NEWLINE)
-if len(based_on) == 1:
+if len(based_on) == 1 and based_on[0]:
if based_on[0] == 'Item Code':
cols = ["Item Code", "Item Name", "Description", "Stock UOM"]
elif based_on[0] == 'Warehouse':
cols = ["Warehouse", "Warehouse Type"]
-elif len(based_on) == 2:
+else:
cols = ["Item Code", "Item Name", "Description", "Stock UOM", "Warehouse", "Warehouse Type"]
for d in cols:
@@ -65,7 +62,7 @@
cl_bal,tot_stock = 0,0
for r in res:
- if len(based_on) == 1:
+ if len(based_on) == 1 and based_on[0]:
if based_on[0] == 'Item Code': closing_balance, stock_value = get_values(msgprint, flt, posting_date, item_code = r[col_idx['Item Code']])
elif based_on[0] == 'Warehouse': closing_balance, stock_value = get_values(msgprint, flt, posting_date, warehouse = r[col_idx['Warehouse']])
r.append(closing_balance)