fixed conflict using ours

This commit is contained in:
Nabin Hait 2012-04-27 13:59:39 +05:30
commit b931f37735
3 changed files with 17 additions and 23 deletions

View File

@ -67,7 +67,7 @@ class DocType:
msgprint("Sales Bom Item " + d.item_code +" cannot be child item.") msgprint("Sales Bom Item " + d.item_code +" cannot be child item.")
raise Exception raise Exception
# Check if is_main_item is modified once saved # 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.") msgprint("Modifying the main item is not allowed.")
raise Exception raise Exception
if len(is_main_item) > 1: if len(is_main_item) > 1:
@ -193,19 +193,17 @@ class DocType:
return return
# get all Sales BOM that have the first item # 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 # check all siblings
sub_items = [[d.item_code, flt(d.qty)] for d in il] sub_items = [[d.item_code, flt(d.qty)] for d in il]
for s in sbl: 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 and docstatus != 2", s[0])
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 = [[d[0], flt(d[1])] for d in t]
if self.has_same_items(sub_items, t): if self.has_same_items(sub_items, t):
msgprint("%s has the same Sales BOM details" % s[0]) msgprint("%s has the same Sales BOM details" % s[0])
raise Exception raise Exception
if finder: if finder:
msgprint("There is no Sales BOM present with the following Combination.") msgprint("There is no Sales BOM present with the following Combination.")
@ -218,4 +216,4 @@ class DocType:
for l in l1: for l in l1:
if l not in l2: if l not in l2:
return 0 return 0
return 1 return 1

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+"'"});
@ -87,4 +86,4 @@ report.get_query = function(){
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}); 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; return q;
} }

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)