mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 21:59:13 +00:00
Merge pull request #2451 from revant/develop
"From time" cannot be later than "To time" and hours cannot be negative
This commit is contained in:
@@ -17,5 +17,14 @@ class TestTimeLog(unittest.TestCase):
|
|||||||
|
|
||||||
frappe.db.sql("delete from `tabTime Log`")
|
frappe.db.sql("delete from `tabTime Log`")
|
||||||
|
|
||||||
|
def test_negative_hours(self):
|
||||||
|
frappe.db.sql("delete from `tabTime Log`")
|
||||||
|
test_time_log = frappe.new_doc("Time Log")
|
||||||
|
test_time_log.activity_type = "Communication"
|
||||||
|
test_time_log.from_time = "2013-01-01 11:00:00.000000"
|
||||||
|
test_time_log.to_time = "2013-01-01 10:00:00.000000"
|
||||||
|
self.assertRaises(frappe.ValidationError, test_time_log.save)
|
||||||
|
frappe.db.sql("delete from `tabTime Log`")
|
||||||
|
|
||||||
test_records = frappe.get_test_records('Time Log')
|
test_records = frappe.get_test_records('Time Log')
|
||||||
test_ignore = ["Time Log Batch", "Sales Invoice"]
|
test_ignore = ["Time Log Batch", "Sales Invoice"]
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ class TimeLog(Document):
|
|||||||
def calculate_total_hours(self):
|
def calculate_total_hours(self):
|
||||||
from frappe.utils import time_diff_in_hours
|
from frappe.utils import time_diff_in_hours
|
||||||
self.hours = time_diff_in_hours(self.to_time, self.from_time)
|
self.hours = time_diff_in_hours(self.to_time, self.from_time)
|
||||||
|
if self.hours < 0:
|
||||||
|
frappe.throw(_("'From Time' cannot be later than 'To Time'"))
|
||||||
|
|
||||||
def set_status(self):
|
def set_status(self):
|
||||||
self.status = {
|
self.status = {
|
||||||
|
|||||||
@@ -160,7 +160,7 @@
|
|||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"description": "Add to calendar on this date",
|
"description": "Add to calendar on this date",
|
||||||
"fieldname": "contact_date",
|
"fieldname": "contact_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Datetime",
|
||||||
"in_filter": 1,
|
"in_filter": 1,
|
||||||
"label": "Next Contact Date",
|
"label": "Next Contact Date",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
@@ -368,7 +368,7 @@
|
|||||||
],
|
],
|
||||||
"icon": "icon-user",
|
"icon": "icon-user",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"modified": "2014-08-12 05:22:18.801092",
|
"modified": "2014-12-01 08:22:23.286314",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Selling",
|
"module": "Selling",
|
||||||
"name": "Lead",
|
"name": "Lead",
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class Lead(SellingController):
|
|||||||
def add_calendar_event(self, opts=None, force=False):
|
def add_calendar_event(self, opts=None, force=False):
|
||||||
super(Lead, self).add_calendar_event({
|
super(Lead, self).add_calendar_event({
|
||||||
"owner": self.lead_owner,
|
"owner": self.lead_owner,
|
||||||
|
"starts_on": self.contact_date,
|
||||||
"subject": ('Contact ' + cstr(self.lead_name)),
|
"subject": ('Contact ' + cstr(self.lead_name)),
|
||||||
"description": ('Contact ' + cstr(self.lead_name)) + \
|
"description": ('Contact ' + cstr(self.lead_name)) + \
|
||||||
(self.contact_by and ('. By : ' + cstr(self.contact_by)) or '')
|
(self.contact_by and ('. By : ' + cstr(self.contact_by)) or '')
|
||||||
|
|||||||
@@ -372,7 +372,7 @@
|
|||||||
{
|
{
|
||||||
"description": "Your sales person will get a reminder on this date to contact the customer",
|
"description": "Your sales person will get a reminder on this date to contact the customer",
|
||||||
"fieldname": "contact_date",
|
"fieldname": "contact_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Datetime",
|
||||||
"label": "Next Contact Date",
|
"label": "Next Contact Date",
|
||||||
"oldfieldname": "contact_date",
|
"oldfieldname": "contact_date",
|
||||||
"oldfieldtype": "Date",
|
"oldfieldtype": "Date",
|
||||||
@@ -416,7 +416,7 @@
|
|||||||
"icon": "icon-info-sign",
|
"icon": "icon-info-sign",
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"modified": "2014-08-12 05:21:51.282397",
|
"modified": "2014-12-01 08:46:35.331148",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Selling",
|
"module": "Selling",
|
||||||
"name": "Opportunity",
|
"name": "Opportunity",
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ class Opportunity(TransactionBase):
|
|||||||
opts = frappe._dict()
|
opts = frappe._dict()
|
||||||
|
|
||||||
opts.description = ""
|
opts.description = ""
|
||||||
|
opts.contact_date = self.contact_date
|
||||||
|
|
||||||
if self.customer:
|
if self.customer:
|
||||||
if self.contact_person:
|
if self.contact_person:
|
||||||
|
|||||||
Reference in New Issue
Block a user