update translation strings #1403

This commit is contained in:
Rushabh Mehta
2014-04-14 19:20:45 +05:30
parent 7da01d6007
commit 9f0d625300
70 changed files with 1325 additions and 1639 deletions

View File

@@ -5,13 +5,13 @@ from __future__ import unicode_literals
import frappe
from frappe.utils import flt, getdate
from frappe import msgprint
from frappe import _
from erpnext.utilities.transaction_base import delete_events
from frappe.model.document import Document
class Project(Document):
def get_gross_profit(self):
pft, per_pft =0, 0
pft = flt(self.project_value) - flt(self.est_material_cost)
@@ -19,19 +19,18 @@ class Project(Document):
per_pft = (flt(pft) / flt(self.project_value)) * 100
ret = {'gross_margin_value': pft, 'per_gross_margin': per_pft}
return ret
def validate(self):
"""validate start date before end date"""
if self.project_start_date and self.completion_date:
if getdate(self.completion_date) < getdate(self.project_start_date):
msgprint("Expected Completion Date can not be less than Project Start Date")
raise Exception
frappe.throw(_("Expected Completion Date can not be less than Project Start Date"))
def on_update(self):
self.add_calendar_event()
def update_percent_complete(self):
total = frappe.db.sql("""select count(*) from tabTask where project=%s""",
total = frappe.db.sql("""select count(*) from tabTask where project=%s""",
self.name)[0][0]
if total:
completed = frappe.db.sql("""select count(*) from tabTask where
@@ -42,7 +41,7 @@ class Project(Document):
def add_calendar_event(self):
# delete any earlier event for this project
delete_events(self.doctype, self.name)
# add events
for milestone in self.get("project_milestones"):
if milestone.milestone_date:
@@ -57,6 +56,6 @@ class Project(Document):
"ref_type": self.doctype,
"ref_name": self.name
}).insert()
def on_trash(self):
delete_events(self.doctype, self.name)

View File

@@ -5,7 +5,7 @@ from __future__ import unicode_literals
import frappe, json
from frappe.utils import getdate, today
from frappe import msgprint
from frappe import _
from frappe.model.document import Document
@@ -15,32 +15,30 @@ class Task(Document):
return {
"project": self.project
}
def get_customer_details(self):
cust = frappe.db.sql("select customer_name from `tabCustomer` where name=%s", self.customer)
if cust:
ret = {'customer_name': cust and cust[0][0] or ''}
return ret
def validate(self):
if self.exp_start_date and self.exp_end_date and getdate(self.exp_start_date) > getdate(self.exp_end_date):
msgprint("'Expected Start Date' can not be greater than 'Expected End Date'")
raise Exception
frappe.throw(_("'Expected Start Date' can not be greater than 'Expected End Date'"))
if self.act_start_date and self.act_end_date and getdate(self.act_start_date) > getdate(self.act_end_date):
msgprint("'Actual Start Date' can not be greater than 'Actual End Date'")
raise Exception
frappe.throw(_("'Actual Start Date' can not be greater than 'Actual End Date'"))
self.update_status()
def update_status(self):
status = frappe.db.get_value("Task", self.name, "status")
if self.status=="Working" and status !="Working" and not self.act_start_date:
self.act_start_date = today()
if self.status=="Closed" and status != "Closed" and not self.act_end_date:
self.act_end_date = today()
def on_update(self):
"""update percent complete in project"""
if self.project:
@@ -55,14 +53,14 @@ def get_events(start, end, filters=None):
conditions = build_match_conditions("Task")
conditions and (" and " + conditions) or ""
if filters:
filters = json.loads(filters)
for key in filters:
if filters[key]:
conditions += " and " + key + ' = "' + filters[key].replace('"', '\"') + '"'
data = frappe.db.sql("""select name, exp_start_date, exp_end_date,
data = frappe.db.sql("""select name, exp_start_date, exp_end_date,
subject, status, project from `tabTask`
where ((exp_start_date between '%(start)s' and '%(end)s') \
or (exp_end_date between '%(start)s' and '%(end)s'))
@@ -79,7 +77,7 @@ def get_project(doctype, txt, searchfield, start, page_len, filters):
return frappe.db.sql(""" select name from `tabProject`
where %(key)s like "%(txt)s"
%(mcond)s
order by name
limit %(start)s, %(page_len)s """ % {'key': searchfield,
order by name
limit %(start)s, %(page_len)s """ % {'key': searchfield,
'txt': "%%%s%%" % txt, 'mcond':get_match_cond(doctype),
'start': start, 'page_len': page_len})
'start': start, 'page_len': page_len})

View File

@@ -6,7 +6,7 @@
from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.utils import cstr
from frappe.utils import cstr, comma_and
class OverlapError(frappe.ValidationError): pass
@@ -14,12 +14,12 @@ class OverlapError(frappe.ValidationError): pass
from frappe.model.document import Document
class TimeLog(Document):
def validate(self):
self.set_status()
self.validate_overlap()
self.calculate_total_hours()
def calculate_total_hours(self):
from frappe.utils import time_diff_in_hours
self.hours = time_diff_in_hours(self.to_time, self.from_time)
@@ -30,36 +30,35 @@ class TimeLog(Document):
1: "Submitted",
2: "Cancelled"
}[self.docstatus or 0]
if self.time_log_batch:
self.status="Batched for Billing"
if self.sales_invoice:
self.status="Billed"
def validate_overlap(self):
def validate_overlap(self):
existing = frappe.db.sql_list("""select name from `tabTime Log` where owner=%s and
(
(from_time between %s and %s) or
(to_time between %s and %s) or
(%s between from_time and to_time))
(from_time between %s and %s) or
(to_time between %s and %s) or
(%s between from_time and to_time))
and name!=%s
and ifnull(task, "")=%s
and docstatus < 2""",
(self.owner, self.from_time, self.to_time, self.from_time,
and docstatus < 2""",
(self.owner, self.from_time, self.to_time, self.from_time,
self.to_time, self.from_time, self.name or "No Name",
cstr(self.task)))
if existing:
frappe.msgprint(_("This Time Log conflicts with") + ":" + ', '.join(existing),
raise_exception=OverlapError)
frappe.throw(_("This Time Log conflicts with {0}").format(comma_and(existing)), OverlapError)
def before_cancel(self):
self.set_status()
def before_update_after_submit(self):
self.set_status()
@frappe.whitelist()
def get_events(start, end):
from frappe.widgets.reportview import build_match_conditions
@@ -67,7 +66,7 @@ def get_events(start, end):
frappe.msgprint(_("No Permission"), raise_exception=1)
match = build_match_conditions("Time Log")
data = frappe.db.sql("""select name, from_time, to_time,
data = frappe.db.sql("""select name, from_time, to_time,
activity_type, task, project from `tabTime Log`
where from_time between '%(start)s' and '%(end)s' or to_time between '%(start)s' and '%(end)s'
%(match)s""" % {
@@ -75,12 +74,12 @@ def get_events(start, end):
"end": end,
"match": match and (" and " + match) or ""
}, as_dict=True, update={"allDay": 0})
for d in data:
d.title = d.name + ": " + (d.activity_type or "[Activity Type not set]")
if d.task:
d.title += " for Task: " + d.task
if d.project:
d.title += " for Project: " + d.project
return data

View File

@@ -29,8 +29,7 @@ class TimeLogBatch(Document):
def validate_time_log_is_submitted(self, tl):
if tl.status != "Submitted" and self.docstatus == 0:
frappe.msgprint(_("Time Log must have status 'Submitted'") + \
" :" + tl.name + " (" + _(tl.status) + ")", raise_exception=True)
frappe.throw(_("Time Log {0} must be 'Submitted'").format(tl.name))
def set_status(self):
self.status = {