hooks fixes

This commit is contained in:
Rushabh Mehta 2014-02-05 17:04:49 +05:30
parent cc008cc109
commit 307fac8b78
4 changed files with 22 additions and 23 deletions

View File

@ -82,7 +82,7 @@ def make_feed(feedtype, doctype, name, owner, subject, color):
f.full_name = get_fullname(owner)
f.save()
def update_feed(controller, method=None):
def update_feed(bean, method=None):
"adds a new feed"
doc = controller.doc
if method in ['on_update', 'on_submit']:

View File

@ -22,19 +22,19 @@ mail_footer = erpnext.startup.mail_footer
on_session_creation = erpnext.startup.event_handlers.on_session_creation
# Boot Events
# Bean Events
# -------------------------
bean_event = *:on_update:erpnext.home.update_feed
bean_event = *:on_submit:erpnext.home.update_feed
bean_event = Comment:on_update:erpnext.home.make_comment_feed
bean_event:*:on_update = erpnext.home.update_feed
bean_event:*:on_submit = erpnext.home.update_feed
bean_event:Comment:on_update = erpnext.home.make_comment_feed
bean_event = *:on_update:webnotes.core.doctype.notification_count.notification_count.clear_doctype_notifications
bean_event = *:on_cancel:webnotes.core.doctype.notification_count.notification_count.clear_doctype_notifications
bean_event = *:on_trash:webnotes.core.doctype.notification_count.notification_count.clear_doctype_notifications
bean_event:*:on_update = webnotes.core.doctype.notification_count.notification_count.clear_doctype_notifications
bean_event:*:on_cancel = webnotes.core.doctype.notification_count.notification_count.clear_doctype_notifications
bean_event:*:on_trash = webnotes.core.doctype.notification_count.notification_count.clear_doctype_notifications
bean_event = Stock Entry:on_submit:erpnext.stock.doctype.material_request.material_request.update_completed_qty
bean_event = Stock Entry:on_cancel:erpnext.stock.doctype.material_request.material_request.update_completed_qty
bean_event:Stock Entry:on_submit = erpnext.stock.doctype.material_request.material_request.update_completed_qty
bean_event:Stock Entry:on_cancel = erpnext.stock.doctype.material_request.material_request.update_completed_qty
standard_queries = Customer:erpnext.selling.utils.get_customer_list

View File

@ -16,10 +16,9 @@ class DocType:
self.doclist = doclist
def get_project_details(self):
cust = webnotes.conn.sql("select customer, customer_name from `tabProject` where name = %s", self.doc.project)
if cust:
ret = {'customer': cust and cust[0][0] or '', 'customer_name': cust and cust[0][1] or ''}
return ret
return {
"project": self.doc.project
}
def get_customer_details(self):
cust = webnotes.conn.sql("select customer_name from `tabCustomer` where name=%s", self.doc.customer)

View File

@ -168,14 +168,14 @@ class DocType(BuyingController):
self.doc.per_ordered = flt((per_ordered / flt(len(item_doclist))) * 100.0, 2)
webnotes.conn.set_value(self.doc.doctype, self.doc.name, "per_ordered", self.doc.per_ordered)
def update_completed_qty(controller, caller_method):
if controller.doc.doctype == "Stock Entry":
def update_completed_qty(bean, method):
if bean.doc.doctype == "Stock Entry":
material_request_map = {}
for d in controller.doclist.get({"parentfield": "mtn_details"}):
for d in bean.doclist.get({"parentfield": "mtn_details"}):
if d.material_request:
if d.material_request not in material_request_map:
material_request_map[d.material_request] = []
material_request_map[d.material_request] = []):
material_request_map[d.material_request].append(d.material_request_item)
for mr_name, mr_items in material_request_map.items():
@ -187,17 +187,17 @@ def update_completed_qty(controller, caller_method):
+ _(mr_doctype.get_label("status")) + " = %s. " % _(mr_obj.doc.status)
+ _("Cannot continue."), exc=webnotes.InvalidStatusError)
_update_requested_qty(controller, mr_obj, mr_items)
_update_requested_qty(bean, mr_obj, mr_items)
# update ordered percentage and qty
mr_obj.update_completed_qty(mr_items)
def _update_requested_qty(controller, mr_obj, mr_items):
def _update_requested_qty(bean, mr_obj, mr_items):
"""update requested qty (before ordered_qty is updated)"""
from erpnext.stock.utils import update_bin
for mr_item_name in mr_items:
mr_item = mr_obj.doclist.getone({"parentfield": "indent_details", "name": mr_item_name})
se_detail = controller.doclist.getone({"parentfield": "mtn_details",
se_detail = bean.doclist.getone({"parentfield": "mtn_details",
"material_request": mr_obj.doc.name, "material_request_item": mr_item_name})
mr_item.ordered_qty = flt(mr_item.ordered_qty)
@ -217,7 +217,7 @@ def _update_requested_qty(controller, mr_obj, mr_items):
"item_code": se_detail.item_code,
"warehouse": se_detail.t_warehouse,
"indented_qty": (se_detail.docstatus==2 and 1 or -1) * add_indented_qty,
"posting_date": controller.doc.posting_date,
"posting_date": bean.doc.posting_date,
})
def set_missing_values(source, target_doclist):