Merge branch 'master' of github.com:webnotes/erpnext

This commit is contained in:
Nabin Hait 2013-03-04 15:36:27 +05:30
commit 4c5af2f33d
5 changed files with 49 additions and 22 deletions

View File

@ -108,6 +108,8 @@ class DocType(SellingController):
self.update_time_log_batch(self.doc.name)
self.convert_to_recurring()
def before_cancel(self):
self.update_time_log_batch(None)
def on_cancel(self):
if cint(self.doc.is_pos) == 1:
@ -123,7 +125,6 @@ class DocType(SellingController):
self.check_next_docstatus()
sales_com_obj.update_prevdoc_detail(0, self)
self.update_time_log_batch(None)
self.make_gl_entries(is_cancel=1)
def on_update_after_submit(self):

View File

@ -33,10 +33,10 @@ class TestSalesInvoice(unittest.TestCase):
tlb = webnotes.bean("Time Log Batch", "_T-Time Log Batch-00001")
tlb.submit()
w = webnotes.bean(webnotes.copy_doclist(test_records[0]))
w.doclist[1].time_log_batch = "_T-Time Log Batch-00001"
w.insert()
w.submit()
si = webnotes.bean(webnotes.copy_doclist(test_records[0]))
si.doclist[1].time_log_batch = "_T-Time Log Batch-00001"
si.insert()
si.submit()
self.assertEquals(webnotes.conn.get_value("Time Log Batch", "_T-Time Log Batch-00001", "status"),
"Billed")
@ -44,7 +44,7 @@ class TestSalesInvoice(unittest.TestCase):
self.assertEquals(webnotes.conn.get_value("Time Log", "_T-Time Log-00001", "status"),
"Billed")
w.cancel()
si.cancel()
self.assertEquals(webnotes.conn.get_value("Time Log Batch", "_T-Time Log Batch-00001", "status"),
"Submitted")

View File

@ -203,4 +203,5 @@ patch_list = [
"execute:(not webnotes.conn.exists('UOM', 'Hour')) and webnotes.doc({'uom_name': 'Unit', 'doctype': 'UOM', 'name': 'Hour'}).insert()",
"patches.february_2013.p09_remove_cancelled_warehouses",
"patches.march_2013.update_po_prevdoc_doctype",
"patches.february_2013.p09_timesheets",
]

View File

@ -31,9 +31,12 @@ class DocType(DocTypeNestedSet):
self.validate_name_with_item()
from website.helpers.product import invalidate_cache_for
if self.doc.show_in_website:
# webpage updates
from website.utils import update_page_name
# webpage updates
page_name = self.doc.name
if webnotes.conn.get_value("Product Settings", None,
"default_product_category")==self.doc.name:
@ -43,9 +46,18 @@ class DocType(DocTypeNestedSet):
update_page_name(self.doc, page_name)
from website.helpers.product import invalidate_cache_for
invalidate_cache_for(self.doc.name)
elif self.doc.page_name:
# if unchecked show in website
from website.utils import delete_page_cache
delete_page_cache(self.doc.page_name)
invalidate_cache_for(self.doc.name)
webnotes.conn.set(self.doc, "page_name", None)
def validate_name_with_item(self):
if webnotes.conn.exists("Item", self.doc.name):
webnotes.msgprint("An item exists with same name (%s), please change the \

View File

@ -39,7 +39,6 @@ class DocType:
def on_update(self):
self.validate_name_with_item_group()
if self.doc.show_in_website:
# webpage updates
self.update_website()
@ -81,6 +80,15 @@ class DocType:
self.doc.name, raise_exception=1)
def update_website(self):
def _invalidate_cache():
from website.helpers.product import invalidate_cache_for
invalidate_cache_for(self.doc.item_group)
[invalidate_cache_for(d.item_group) for d in \
self.doclist.get({"doctype":"Website Item Group"})]
if self.doc.show_in_website:
from website.utils import update_page_name
if self.doc.name==self.doc.item_name:
page_name_from = self.doc.name
@ -89,11 +97,16 @@ class DocType:
update_page_name(self.doc, page_name_from)
from website.helpers.product import invalidate_cache_for
invalidate_cache_for(self.doc.item_group)
_invalidate_cache()
[invalidate_cache_for(d.item_group) for d in \
self.doclist.get({"doctype":"Website Item Group"})]
elif self.doc.page_name:
# if unchecked show in website
from website.utils import delete_page_cache
delete_page_cache(self.doc.page_name)
_invalidate_cache()
webnotes.conn.set(self.doc, "page_name", None)
# On delete 1. Delete BIN (if none of the corrosponding transactions present, it gets deleted. if present, rolled back due to exception)
def on_trash(self):