fixed conflict in sales bom using ours

This commit is contained in:
Nabin Hait 2012-04-27 14:03:06 +05:30
commit 201f8ca821
2 changed files with 8 additions and 12 deletions

View File

@ -19,7 +19,7 @@ report.customize_filters = function() {
this.mytabs.items['Select Columns'].hide() this.mytabs.items['Select Columns'].hide()
this.mytabs.items['More Filters'].hide() this.mytabs.items['More Filters'].hide()
this.hide_all_filters(); 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 +'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 +'Item Code'].df.filter_hide = 0;
this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Warehouse'].df.filter_hide = 0; this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Warehouse'].df.filter_hide = 0;
@ -57,8 +57,8 @@ report.get_query = function(){
ware_type_cond = repl(' AND `tabWarehouse`.warehouse_type IN (%(war)s)', {war: war.substr(0,war.length-1)}) 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.length == 1 && based_on[0]){
if(based_on == 'Item Code'){ 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"'; 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"'; 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+'"'}); if(item_code) cond += repl(' AND `tabItem`.name = %(item)s', {item:'"'+item_code+'"'});
@ -66,7 +66,7 @@ report.get_query = function(){
tables = '`tabItem`'; tables = '`tabItem`';
group_by = '`tabStock Ledger Entry`.item_code'; 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"'; cols = '`tabWarehouse`.name AS "Warehouse", `tabWarehouse`.warehouse_type AS "Warehouse Type"';
cond = '`tabWarehouse`.docstatus < 2' cond = '`tabWarehouse`.docstatus < 2'
if(warehouse) cond += repl(' AND `tabWarehouse`.name = %(warehouse)s', {warehouse:'"'+warehouse+'"'}); if(warehouse) cond += repl(' AND `tabWarehouse`.name = %(warehouse)s', {warehouse:'"'+warehouse+'"'});
@ -74,8 +74,7 @@ report.get_query = function(){
tables = '`tabWarehouse`'; tables = '`tabWarehouse`';
group_by = '`tabStock Ledger Entry`.warehouse'; group_by = '`tabStock Ledger Entry`.warehouse';
} }
} } else {
else if(based_on.length == 2){
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"'; 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'; 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+"'"}); if(item_code) cond += repl(" AND `tabItem`.name = %(item)s", {item:"'"+item_code+"'"});

View File

@ -14,19 +14,16 @@
# You should have received a copy of the GNU General Public License # 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/>.
if not filter_values.get('based_on'):
msgprint("Please Select Based On")
raise Exception
cols, columns = [], [] cols, columns = [], []
# Add columns # Add columns
# ------------ # ------------
based_on = filter_values.get('based_on').split(NEWLINE) 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': if based_on[0] == 'Item Code':
cols = ["Item Code", "Item Name", "Description", "Stock UOM"] cols = ["Item Code", "Item Name", "Description", "Stock UOM"]
elif based_on[0] == 'Warehouse': elif based_on[0] == 'Warehouse':
cols = ["Warehouse", "Warehouse Type"] cols = ["Warehouse", "Warehouse Type"]
elif len(based_on) == 2: else:
cols = ["Item Code", "Item Name", "Description", "Stock UOM", "Warehouse", "Warehouse Type"] cols = ["Item Code", "Item Name", "Description", "Stock UOM", "Warehouse", "Warehouse Type"]
for d in cols: for d in cols:
@ -65,7 +62,7 @@ out=[]
cl_bal,tot_stock = 0,0 cl_bal,tot_stock = 0,0
for r in res: 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']]) 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']]) elif based_on[0] == 'Warehouse': closing_balance, stock_value = get_values(msgprint, flt, posting_date, warehouse = r[col_idx['Warehouse']])
r.append(closing_balance) r.append(closing_balance)