[minor] merge conflict fixed

This commit is contained in:
Nabin Hait
2013-11-21 12:28:50 +05:30
25 changed files with 225 additions and 226 deletions

View File

@@ -253,14 +253,44 @@ class DocType(DocListController, WebsiteGenerator):
webnotes.conn.sql("""delete from tabBin where item_code=%s""", self.doc.item_code)
WebsiteGenerator.on_trash(self)
def on_rename(self, newdn, olddn, merge=False):
webnotes.conn.sql("update tabItem set item_code = %s where name = %s", (newdn, olddn))
def before_rename(self, olddn, newdn, merge=False):
if merge:
# Validate properties before merging
field_list = ["stock_uom", "is_stock_item", "has_serial_no", "has_batch_no"]
new_properties = [cstr(d) for d in webnotes.conn.get_value("Item", newdn, field_list)]
if new_properties != [cstr(self.doc.fields[fld]) for fld in field_list]:
webnotes.throw(_("To merge, following properties must be same for both items")
+ ": \n" + ", ".join([self.meta.get_label(fld) for fld in field_list]))
webnotes.conn.sql("delete from `tabBin` where item_code=%s", olddn)
def after_rename(self, olddn, newdn, merge):
webnotes.conn.set_value("Item", newdn, "item_code", newdn)
self.update_website_page_name()
if merge:
self.set_last_purchase_rate(newdn)
self.recalculate_bin_qty(newdn)
def update_website_page_name(self):
if self.doc.page_name:
self.update_website()
from webnotes.webutils import clear_cache
clear_cache(self.doc.page_name)
if merge:
from stock.stock_ledger import update_entries_after
for wh in webnotes.conn.sql("""select warehouse from `tabBin`
where item_code=%s""", newdn):
update_entries_after({"item_code": newdn, "warehouse": wh[0]})
def set_last_purchase_rate(self, newdn):
from buying.utils import get_last_purchase_details
last_purchase_rate = get_last_purchase_details(newdn).get("purchase_rate", 0)
webnotes.conn.set_value("Item", newdn, "last_purchase_rate", last_purchase_rate)
def recalculate_bin_qty(self, newdn):
from utilities.repost_stock import repost_stock
webnotes.conn.auto_commit_on_many_writes = 1
webnotes.conn.set_default("allow_negative_stock", 1)
for warehouse in webnotes.conn.sql("select name from `tabWarehouse`"):
repost_stock(newdn, warehouse[0])
webnotes.conn.set_default("allow_negative_stock",
webnotes.conn.get_value("Stock Settings", None, "allow_negative_stock"))
webnotes.conn.auto_commit_on_many_writes = 0

View File

@@ -20,7 +20,7 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
cur_frm.add_custom_button(wn._('Make Purchase Invoice'),
this.make_purchase_invoice);
}
cur_frm.add_custom_button(wn._('Send SMS'), cur_frm.cscript['Send SMS'], "icon-mobile-phone");
cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
this.show_stock_ledger();
this.show_general_ledger();

View File

@@ -6,7 +6,7 @@ import webnotes
from webnotes.utils import cint, getdate, cstr, flt, add_days
import datetime
from webnotes import msgprint, _, ValidationError
from webnotes import _, ValidationError
from controllers.stock_controller import StockController
@@ -157,11 +157,12 @@ class DocType(StockController):
webnotes.throw(_("Cannot delete Serial No in warehouse. \
First remove from warehouse, then delete.") + ": " + self.doc.name)
def on_rename(self, new, old, merge=False):
"""rename serial_no text fields"""
def before_rename(self, old, new, merge=False):
if merge:
msgprint(_("Sorry. Serial Nos. cannot be merged"), raise_exception=True)
webnotes.throw(_("Sorry, Serial Nos cannot be merged"))
def after_rename(self, old, new, merge=False):
"""rename serial_no text fields"""
for dt in webnotes.conn.sql("""select parent from tabDocField
where fieldname='serial_no' and fieldtype='Text'"""):

View File

@@ -5,18 +5,6 @@ cur_frm.cscript.refresh = function(doc) {
cur_frm.toggle_display('warehouse_name', doc.__islocal);
}
cur_frm.cscript.merge = function(doc, cdt, cdn) {
if (!doc.merge_with) {
msgprint(wn._("Please enter the warehouse to which you want to merge?"));
return;
}
var check = confirm(wn._("Are you sure you want to merge this warehouse into "
+ doc.merge_with + "?"));
if (check) {
return $c_obj(make_doclist(cdt, cdn), 'merge_warehouses', '', '');
}
}
cur_frm.set_query("create_account_under", function() {
return {
filters: {

View File

@@ -55,47 +55,6 @@ class DocType:
else:
webnotes.throw(_("Please enter account group under which account \
for warehouse ") + self.doc.name +_(" will be created"))
def on_rename(self, new, old, merge=False):
webnotes.conn.set_value("Account", {"account_type": "Warehouse", "master_name": old},
"master_name", new)
if merge:
from stock.stock_ledger import update_entries_after
for item_code in webnotes.conn.sql("""select item_code from `tabBin`
where warehouse=%s""", new):
update_entries_after({"item_code": item_code, "warehouse": new})
def merge_warehouses(self):
webnotes.conn.auto_commit_on_many_writes = 1
# get items which dealt with current warehouse
items = webnotes.conn.sql("select item_code from tabBin where warehouse=%s" , self.doc.name)
# delete old bins
webnotes.conn.sql("delete from tabBin where warehouse=%s", self.doc.name)
# replace link fields
from webnotes.model import rename_doc
link_fields = rename_doc.get_link_fields('Warehouse')
rename_doc.update_link_field_values(link_fields, self.doc.name, self.doc.merge_with)
account_link_fields = rename_doc.get_link_fields('Account')
old_warehouse_account = webnotes.conn.get_value("Account", {"master_name": self.doc.name})
new_warehouse_account = webnotes.conn.get_value("Account",
{"master_name": self.doc.merge_with})
rename_doc.update_link_field_values(account_link_fields, old_warehouse_account,
new_warehouse_account)
webnotes.conn.delete_doc("Account", old_warehouse_account)
from utilities.repost_stock import repost
for item_code in items:
repost(item_code[0], self.doc.merge_with)
webnotes.conn.auto_commit_on_many_writes = 0
msgprint("Warehouse %s merged into %s. Now you can delete warehouse: %s"
% (self.doc.name, self.doc.merge_with, self.doc.name))
def on_trash(self):
# delete bin
@@ -110,15 +69,61 @@ class DocType:
webnotes.conn.sql("delete from `tabBin` where name = %s", d['name'])
warehouse_account = webnotes.conn.get_value("Account",
{"account_type": "Warehosue", "master_name": self.doc.name})
{"account_type": "Warehouse", "master_name": self.doc.name})
if warehouse_account:
webnotes.delete_doc("Account", warehouse_account)
# delete cancelled sle
if webnotes.conn.sql("""select name from `tabStock Ledger Entry` where warehouse = %s""",
self.doc.name):
msgprint("""Warehosue can not be deleted as stock ledger entry
if sql("""select name from `tabStock Ledger Entry` where warehouse = %s""", self.doc.name):
msgprint("""Warehouse can not be deleted as stock ledger entry
exists for this warehouse.""", raise_exception=1)
else:
webnotes.conn.sql("delete from `tabStock Ledger Entry` where warehouse = %s",
self.doc.name)
def before_rename(self, olddn, newdn, merge=False):
# Add company abbr if not provided
from setup.doctype.company.company import get_name_with_abbr
new_warehouse = get_name_with_abbr(newdn, self.doc.company)
if merge:
if self.doc.company != webnotes.conn.get_value("Warehouse", new_warehouse, "company"):
webnotes.throw(_("Both Warehouse must belong to same Company"))
webnotes.conn.sql("delete from `tabBin` where warehouse=%s", olddn)
self.rename_account(olddn, new_warehouse, merge)
return new_warehouse
def after_rename(self, olddn, newdn, merge=False):
if merge:
self.recalculate_bin_qty(newdn)
def recalculate_bin_qty(self, newdn):
from utilities.repost_stock import repost_stock
webnotes.conn.auto_commit_on_many_writes = 1
webnotes.conn.set_default("allow_negative_stock", 1)
for item in webnotes.conn.sql("""select distinct item_code from (
select name as item_code from `tabItem` where ifnull(is_stock_item, 'Yes')='Yes'
union
select distinct item_code from tabBin) a"""):
repost_stock(item[0], newdn)
webnotes.conn.set_default("allow_negative_stock",
webnotes.conn.get_value("Stock Settings", None, "allow_negative_stock"))
webnotes.conn.auto_commit_on_many_writes = 0
def rename_account(self, olddn, newdn, merge):
old_account = webnotes.conn.get_value("Account",
{"account_type": "Warehouse", "master_name": olddn})
if old_account:
new_account = None
if not merge:
if old_account == olddn:
new_account = webnotes.rename_doc("Account", olddn, newdn)
else:
existing_new_account = webnotes.conn.get_value("Account",
{"account_type": "Warehouse", "master_name": newdn})
new_account = webnotes.rename_doc("Account", old_account,
existing_new_account or newdn, merge=True if existing_new_account else False)
if new_account:
webnotes.conn.set_value("Account", new_account, "master_name", newdn)

View File

@@ -2,7 +2,7 @@
{
"creation": "2013-03-07 18:50:32",
"docstatus": 0,
"modified": "2013-10-28 16:42:07",
"modified": "2013-11-19 12:12:33",
"modified_by": "Administrator",
"owner": "Administrator"
},
@@ -20,7 +20,8 @@
"name": "__common__",
"parent": "Warehouse",
"parentfield": "fields",
"parenttype": "DocType"
"parenttype": "DocType",
"permlevel": 0
},
{
"doctype": "DocPerm",
@@ -42,7 +43,6 @@
"fieldtype": "Section Break",
"label": "Warehouse Detail",
"oldfieldtype": "Section Break",
"permlevel": 0,
"read_only": 0
},
{
@@ -52,7 +52,6 @@
"label": "Warehouse Name",
"oldfieldname": "warehouse_name",
"oldfieldtype": "Data",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
@@ -65,7 +64,6 @@
"oldfieldname": "company",
"oldfieldtype": "Link",
"options": "Company",
"permlevel": 0,
"read_only": 0,
"reqd": 1,
"search_index": 1
@@ -95,7 +93,6 @@
"fieldtype": "Table",
"label": "Warehouse Users",
"options": "Warehouse User",
"permlevel": 0,
"read_only": 0
},
{
@@ -104,7 +101,6 @@
"fieldname": "warehouse_contact_info",
"fieldtype": "Section Break",
"label": "Warehouse Contact Info",
"permlevel": 0,
"read_only": 0
},
{
@@ -115,7 +111,6 @@
"label": "Email Id",
"oldfieldname": "email_id",
"oldfieldtype": "Data",
"permlevel": 0,
"print_hide": 0,
"read_only": 0
},
@@ -127,7 +122,6 @@
"oldfieldname": "phone_no",
"oldfieldtype": "Int",
"options": "Phone",
"permlevel": 0,
"read_only": 0
},
{
@@ -138,7 +132,6 @@
"oldfieldname": "mobile_no",
"oldfieldtype": "Int",
"options": "Phone",
"permlevel": 0,
"read_only": 0
},
{
@@ -146,7 +139,6 @@
"fieldname": "column_break0",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"permlevel": 0,
"read_only": 0
},
{
@@ -156,7 +148,6 @@
"label": "Address Line 1",
"oldfieldname": "address_line_1",
"oldfieldtype": "Data",
"permlevel": 0,
"read_only": 0
},
{
@@ -166,7 +157,6 @@
"label": "Address Line 2",
"oldfieldname": "address_line_2",
"oldfieldtype": "Data",
"permlevel": 0,
"read_only": 0
},
{
@@ -177,7 +167,6 @@
"label": "City",
"oldfieldname": "city",
"oldfieldtype": "Data",
"permlevel": 0,
"read_only": 0,
"reqd": 0
},
@@ -189,7 +178,6 @@
"oldfieldname": "state",
"oldfieldtype": "Select",
"options": "Suggest",
"permlevel": 0,
"read_only": 0
},
{
@@ -199,33 +187,6 @@
"label": "PIN",
"oldfieldname": "pin",
"oldfieldtype": "Int",
"permlevel": 0,
"read_only": 0
},
{
"description": "This feature is for merging duplicate warehouses. It will replace all the links of this warehouse by \"Merge Into\" warehouse. After merging you can delete this warehouse, as stock level for this warehouse will be zero.",
"doctype": "DocField",
"fieldname": "merge_warehouses_section",
"fieldtype": "Section Break",
"label": "Merge Warehouses",
"permlevel": 2,
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "merge_with",
"fieldtype": "Link",
"label": "Merge Into",
"options": "Warehouse",
"permlevel": 2,
"read_only": 0
},
{
"doctype": "DocField",
"fieldname": "merge",
"fieldtype": "Button",
"label": "Merge",
"permlevel": 2,
"read_only": 0
},
{

View File

@@ -25,7 +25,7 @@ erpnext.StockAgeing = erpnext.StockGridReport.extend({
page: wrapper,
parent: $(wrapper).find('.layout-main'),
appframe: wrapper.appframe,
doctypes: ["Item", "Warehouse", "Stock Ledger Entry", "Item Group", "Brand"],
doctypes: ["Item", "Warehouse", "Stock Ledger Entry", "Item Group", "Brand", "Serial No"],
})
},
setup_columns: function() {
@@ -175,7 +175,7 @@ erpnext.StockAgeing = erpnext.StockGridReport.extend({
grid: { hoverable: true, clickable: true },
xaxis: {
ticks: $.map(me.data, function(item, idx) { return [[idx+1, item.name]] }),
max: 20
max: 15
},
series: { downsample: { threshold: 1000 } }
}

View File

@@ -21,7 +21,7 @@ erpnext.StockLedger = erpnext.StockGridReport.extend({
page: wrapper,
parent: $(wrapper).find('.layout-main'),
appframe: wrapper.appframe,
doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand"],
doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand", "Serial No"],
})
},

View File

@@ -27,7 +27,7 @@ erpnext.StockLevel = erpnext.StockGridReport.extend({
parent: $(wrapper).find('.layout-main'),
appframe: wrapper.appframe,
doctypes: ["Item", "Warehouse", "Stock Ledger Entry", "Production Order",
"Material Request Item", "Purchase Order Item", "Sales Order Item", "Brand"],
"Material Request Item", "Purchase Order Item", "Sales Order Item", "Brand", "Serial No"],
});
this.wrapper.bind("make", function() {