[fixes] check for close status
This commit is contained in:
parent
e930f0f74e
commit
a4efbf0db7
@ -48,7 +48,7 @@ class PurchaseInvoice(BuyingController):
|
||||
self.check_conversion_rate()
|
||||
self.validate_credit_to_acc()
|
||||
self.clear_unallocated_advances("Purchase Invoice Advance", "advances")
|
||||
self.check_for_stopped_status()
|
||||
self.check_for_stopped_or_closed_status()
|
||||
self.validate_with_previous_doc()
|
||||
self.validate_uom_is_integer("uom", "qty")
|
||||
self.set_against_expense_account()
|
||||
@ -103,14 +103,14 @@ class PurchaseInvoice(BuyingController):
|
||||
|
||||
self.party_account_currency = account.account_currency
|
||||
|
||||
def check_for_stopped_status(self):
|
||||
def check_for_stopped_or_closed_status(self):
|
||||
check_list = []
|
||||
pc_obj = frappe.get_doc('Purchase Common')
|
||||
|
||||
for d in self.get('items'):
|
||||
if d.purchase_order and not d.purchase_order in check_list and not d.purchase_receipt:
|
||||
check_list.append(d.purchase_order)
|
||||
stopped = frappe.db.sql("select name from `tabPurchase Order` where status = 'Stopped' and name = %s", d.purchase_order)
|
||||
if stopped:
|
||||
throw(_("Purchase Order {0} is 'Stopped'").format(d.purchase_order))
|
||||
pc_obj.check_for_stopped_or_closed_status('Purchase Order', d.purchase_order)
|
||||
|
||||
def validate_with_previous_doc(self):
|
||||
super(PurchaseInvoice, self).validate_with_previous_doc({
|
||||
@ -394,6 +394,8 @@ class PurchaseInvoice(BuyingController):
|
||||
make_gl_entries(gl_entries, cancel=(self.docstatus == 2))
|
||||
|
||||
def on_cancel(self):
|
||||
self.check_for_stopped_or_closed_status()
|
||||
|
||||
if not self.is_return:
|
||||
from erpnext.accounts.utils import remove_against_link_from_jv
|
||||
remove_against_link_from_jv(self.doctype, self.name)
|
||||
|
@ -80,11 +80,13 @@ class PurchaseCommon(BuyingController):
|
||||
frappe.msgprint(_("Warning: Same item has been entered multiple times."))
|
||||
|
||||
|
||||
def check_for_stopped_status(self, doctype, docname):
|
||||
stopped = frappe.db.sql("""select name from `tab%s` where name = %s and
|
||||
status = 'Stopped'""" % (doctype, '%s'), docname)
|
||||
if stopped:
|
||||
frappe.throw(_("{0} {1} status is 'Stopped'").format(doctype, docname), frappe.InvalidStatusError)
|
||||
def check_for_stopped_or_closed_status(self, doctype, docname):
|
||||
status = frappe.db.get_value(doctype, docname, "status")
|
||||
|
||||
if status == "Stopped":
|
||||
frappe.throw(_("{0} {1} status is Stopped").format(doctype, docname), frappe.InvalidStatusError)
|
||||
if status == "Closed":
|
||||
frappe.throw(_("{0} {1} status is Closed").format(doctype, docname), frappe.InvalidStatusError)
|
||||
|
||||
def check_docstatus(self, check, doctype, docname, detail_doctype = ''):
|
||||
if check == 'Next':
|
||||
|
@ -39,7 +39,7 @@ class PurchaseOrder(BuyingController):
|
||||
self.set_status()
|
||||
pc_obj = frappe.get_doc('Purchase Common')
|
||||
pc_obj.validate_for_items(self)
|
||||
self.check_for_stopped_status(pc_obj)
|
||||
self.check_for_stopped_or_closed_status(pc_obj)
|
||||
|
||||
self.validate_uom_is_integer("uom", "qty")
|
||||
self.validate_uom_is_integer("stock_uom", ["qty", "required_qty"])
|
||||
@ -108,12 +108,12 @@ class PurchaseOrder(BuyingController):
|
||||
= d.rate = item_last_purchase_rate
|
||||
|
||||
# Check for Stopped status
|
||||
def check_for_stopped_status(self, pc_obj):
|
||||
def check_for_stopped_or_closed_status(self, pc_obj):
|
||||
check_list =[]
|
||||
for d in self.get('items'):
|
||||
if d.meta.get_field('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_docname not in check_list:
|
||||
check_list.append(d.prevdoc_docname)
|
||||
pc_obj.check_for_stopped_status( d.prevdoc_doctype, d.prevdoc_docname)
|
||||
pc_obj.check_for_stopped_or_closed_status( d.prevdoc_doctype, d.prevdoc_docname)
|
||||
|
||||
def update_requested_qty(self):
|
||||
material_request_map = {}
|
||||
@ -193,7 +193,7 @@ class PurchaseOrder(BuyingController):
|
||||
})
|
||||
|
||||
pc_obj = frappe.get_doc('Purchase Common')
|
||||
self.check_for_stopped_status(pc_obj)
|
||||
self.check_for_stopped_or_closed_status(pc_obj)
|
||||
|
||||
# Check if Purchase Receipt has been submitted against current Purchase Order
|
||||
pc_obj.check_docstatus(check = 'Next', doctype = 'Purchase Receipt', docname = self.name, detail_doctype = 'Purchase Receipt Item')
|
||||
|
@ -103,7 +103,7 @@ class MaterialRequest(BuyingController):
|
||||
def on_cancel(self):
|
||||
pc_obj = frappe.get_doc('Purchase Common')
|
||||
|
||||
pc_obj.check_for_stopped_status(self.doctype, self.name)
|
||||
pc_obj.check_for_stopped_or_closed_status(self.doctype, self.name)
|
||||
pc_obj.check_docstatus(check = 'Next', doctype = 'Purchase Order', docname = self.name, detail_doctype = 'Purchase Order Item')
|
||||
|
||||
self.update_requested_qty()
|
||||
|
@ -67,7 +67,7 @@ class PurchaseReceipt(BuyingController):
|
||||
|
||||
pc_obj = frappe.get_doc('Purchase Common')
|
||||
pc_obj.validate_for_items(self)
|
||||
self.check_for_stopped_status(pc_obj)
|
||||
self.check_for_stopped_or_closed_status(pc_obj)
|
||||
|
||||
# sub-contracting
|
||||
self.validate_for_subcontracting()
|
||||
@ -219,12 +219,12 @@ class PurchaseReceipt(BuyingController):
|
||||
raise frappe.ValidationError
|
||||
|
||||
# Check for Stopped status
|
||||
def check_for_stopped_status(self, pc_obj):
|
||||
def check_for_stopped_or_closed_status(self, pc_obj):
|
||||
check_list =[]
|
||||
for d in self.get('items'):
|
||||
if d.meta.get_field('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_docname not in check_list:
|
||||
check_list.append(d.prevdoc_docname)
|
||||
pc_obj.check_for_stopped_status(d.prevdoc_doctype, d.prevdoc_docname)
|
||||
pc_obj.check_for_stopped_or_closed_status(d.prevdoc_doctype, d.prevdoc_docname)
|
||||
|
||||
# on submit
|
||||
def on_submit(self):
|
||||
@ -260,7 +260,7 @@ class PurchaseReceipt(BuyingController):
|
||||
def on_cancel(self):
|
||||
pc_obj = frappe.get_doc('Purchase Common')
|
||||
|
||||
self.check_for_stopped_status(pc_obj)
|
||||
self.check_for_stopped_or_closed_status(pc_obj)
|
||||
# Check if Purchase Invoice has been submitted against current Purchase Order
|
||||
submitted = frappe.db.sql("""select t1.name
|
||||
from `tabPurchase Invoice` t1,`tabPurchase Invoice Item` t2
|
||||
|
Loading…
x
Reference in New Issue
Block a user