fix set_expired_status method

This commit is contained in:
0Pranav 2019-11-25 14:27:43 +05:30
parent e0c9f3c282
commit 754c43f6c3
2 changed files with 3 additions and 3 deletions

View File

@ -186,8 +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'
WHERE 'valid_till' < %s""", (nowdate()))
frappe.db.sql("""UPDATE `tabQuotation` SET `status` = 'Expired'
WHERE `status` != "Expired" AND `valid_till` < %s""", (nowdate()))
frappe.db.commit()
@frappe.whitelist()

View File

@ -218,9 +218,9 @@ class TestQuotation(unittest.TestCase):
]
yesterday = getdate(nowdate()) - datetime.timedelta(days=1)
expired_quotation = make_quotation(item_list=quotation_item)
# Manually set valid till date to bypass validation
expired_quotation.valid_till = yesterday
expired_quotation.save()
# Call schedular method
set_expired_status()
self.assertEqual(expired_quotation.status,"Expired")