fix: Method name in hooks, test case code clean up

This commit is contained in:
deepeshgarg007 2019-11-25 21:58:15 +05:30
parent 565d3efcdf
commit 53a66ee386
3 changed files with 9 additions and 13 deletions

View File

@ -302,7 +302,7 @@ scheduler_events = {
"erpnext.support.doctype.service_level_agreement.service_level_agreement.check_agreement_status",
"erpnext.crm.doctype.email_campaign.email_campaign.send_email_to_leads_or_contacts",
"erpnext.crm.doctype.email_campaign.email_campaign.set_email_campaign_status",
"erpnext.selling.doctype.quotation.set_expired"
"erpnext.selling.doctype.quotation.set_expired_status"
],
"daily_long": [
"erpnext.setup.doctype.email_digest.email_digest.send",

View File

@ -186,9 +186,8 @@ def _make_sales_order(source_name, target_doc=None, ignore_permissions=False):
return doclist
def set_expired_status():
frappe.db.sql("""UPDATE `tabQuotation` SET `status` = 'Expired'
frappe.db.sql("""UPDATE `tabQuotation` SET `status` = 'Expired'
WHERE `status` != "Expired" AND `valid_till` < %s""", (nowdate()))
frappe.db.commit()
@frappe.whitelist()
def make_sales_invoice(source_name, target_doc=None):

View File

@ -201,29 +201,26 @@ class TestQuotation(unittest.TestCase):
sec_qo = make_quotation(item_list=qo_item2, do_not_submit=True)
sec_qo.submit()
def test_expired_quotations(self):
import datetime
def test_quotation_expiry(self):
from erpnext.selling.doctype.quotation.quotation import set_expired_status
from erpnext.stock.doctype.item.test_item import make_item
test_item = make_item("_Test Paraglider",
{"is_stock_item":1})
quotation_item = [
{
"item_code": test_item.item_code,
"item_code": "_Test Item",
"warehouse":"",
"qty": 1,
"rate": 500
}
]
yesterday = getdate(nowdate()) - datetime.timedelta(days=1)
expired_quotation = make_quotation(item_list=quotation_item,transaction_date=yesterday,do_not_submit=True)
yesterday = add_days(nowdate(), -1)
expired_quotation = make_quotation(item_list=quotation_item, transaction_date=yesterday, do_not_submit=True)
expired_quotation.valid_till = yesterday
expired_quotation.save()
expired_quotation.submit()
set_expired_status()
expired_quotation = frappe.get_doc("Quotation",expired_quotation.name)
self.assertEqual(expired_quotation.status,"Expired")
expired_quotation.reload()
self.assertEqual(expired_quotation.status, "Expired")
test_records = frappe.get_test_records('Quotation')