[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