fixed strings for translation

This commit is contained in:
Rushabh Mehta
2014-04-15 14:36:12 +05:30
parent 5d4ffa6cf8
commit 2c45899a02
20 changed files with 516 additions and 562 deletions

View File

@@ -114,7 +114,7 @@ class JournalVoucher(AccountsController):
if self.cheque_no: if self.cheque_no:
if self.cheque_date: if self.cheque_date:
r.append(_('Reference #{0} dated {1}').format(self.cheque_no, formatdate(self.cheque_date))) r.append(_('Reference #{0} dated {1}').format(self.cheque_no, formatdate(self.cheque_date)))
else : else:
msgprint(_("Please enter Reference date"), raise_exception=1) msgprint(_("Please enter Reference date"), raise_exception=1)
for d in self.get('entries'): for d in self.get('entries'):

View File

@@ -86,9 +86,7 @@ class Customer(TransactionBase):
def validate_name_with_customer_group(self): def validate_name_with_customer_group(self):
if frappe.db.exists("Customer Group", self.name): if frappe.db.exists("Customer Group", self.name):
frappe.msgprint("An Customer Group exists with same name (%s), \ frappe.throw("A Customer Group exists with same name please change the Customer name or rename the Customer Group")
please change the Customer name or rename the Customer Group" %
self.name, raise_exception=1)
def delete_customer_address(self): def delete_customer_address(self):
addresses = frappe.db.sql("""select name, lead from `tabAddress` addresses = frappe.db.sql("""select name, lead from `tabAddress`
@@ -140,7 +138,7 @@ class Customer(TransactionBase):
@frappe.whitelist() @frappe.whitelist()
def get_dashboard_info(customer): def get_dashboard_info(customer):
if not frappe.has_permission("Customer", "read", customer): if not frappe.has_permission("Customer", "read", customer):
frappe.msgprint("No Permission", raise_exception=True) frappe.msgprint(_("Not permitted"), raise_exception=True)
out = {} out = {}
for doctype in ["Opportunity", "Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]: for doctype in ["Opportunity", "Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]:

View File

@@ -4,12 +4,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe.utils import add_days, cstr, flt, nowdate, cint, now from frappe.utils import flt, now
from frappe import session, msgprint
from erpnext.stock.utils import get_valid_serial_nos
from frappe.model.document import Document from frappe.model.document import Document
class StockLedger(Document): class StockLedger(Document):

View File

@@ -4,15 +4,14 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe import msgprint from frappe import _
from frappe.utils import flt, getdate, add_days from frappe.utils import flt, getdate, add_days, formatdate
from frappe.model.controller import DocListController from frappe.model.controller import DocListController
from datetime import date from datetime import date
class StockFreezeError(frappe.ValidationError): pass class StockFreezeError(frappe.ValidationError): pass
class StockLedgerEntry(DocListController): class StockLedgerEntry(DocListController):
def validate(self): def validate(self):
from erpnext.stock.utils import validate_warehouse_company from erpnext.stock.utils import validate_warehouse_company
self.validate_mandatory() self.validate_mandatory()
@@ -55,11 +54,7 @@ class StockLedgerEntry(DocListController):
mandatory = ['warehouse','posting_date','voucher_type','voucher_no','actual_qty','company'] mandatory = ['warehouse','posting_date','voucher_type','voucher_no','actual_qty','company']
for k in mandatory: for k in mandatory:
if not self.get(k): if not self.get(k):
msgprint("Stock Ledger Entry: '%s' is mandatory" % k, raise_exception = 1) frappe.throw(_("{0} is required").format(k))
elif k == 'warehouse':
if not frappe.db.exists("Warehouse", self.get(k)):
msgprint("Warehouse: '%s' does not exist in the system. Please check." %
self.get(k), raise_exception = 1)
def validate_item(self): def validate_item(self):
item_det = frappe.db.sql("""select name, has_batch_no, docstatus, item_det = frappe.db.sql("""select name, has_batch_no, docstatus,
@@ -89,15 +84,14 @@ class StockLedgerEntry(DocListController):
if stock_frozen_upto: if stock_frozen_upto:
stock_auth_role = frappe.db.get_value('Stock Settings', None,'stock_auth_role') stock_auth_role = frappe.db.get_value('Stock Settings', None,'stock_auth_role')
if getdate(self.posting_date) <= getdate(stock_frozen_upto) and not stock_auth_role in frappe.user.get_roles(): if getdate(self.posting_date) <= getdate(stock_frozen_upto) and not stock_auth_role in frappe.user.get_roles():
msgprint("You are not authorized to do / modify back dated stock entries before %s" % getdate(stock_frozen_upto).strftime('%d-%m-%Y'), raise_exception=StockFreezeError) frappe.throw(_("Entries before {0} are frozen").format(formatdate(stock_frozen_upto)), StockFreezeError)
stock_frozen_upto_days = int(frappe.db.get_value('Stock Settings', None, 'stock_frozen_upto_days') or 0) stock_frozen_upto_days = int(frappe.db.get_value('Stock Settings', None, 'stock_frozen_upto_days') or 0)
if stock_frozen_upto_days: if stock_frozen_upto_days:
stock_auth_role = frappe.db.get_value('Stock Settings', None,'stock_auth_role') stock_auth_role = frappe.db.get_value('Stock Settings', None,'stock_auth_role')
older_than_x_days_ago = (add_days(getdate(self.posting_date), stock_frozen_upto_days) <= date.today()) older_than_x_days_ago = (add_days(getdate(self.posting_date), stock_frozen_upto_days) <= date.today())
if older_than_x_days_ago and not stock_auth_role in frappe.user.get_roles(): if older_than_x_days_ago and not stock_auth_role in frappe.user.get_roles():
msgprint("You are not authorized to do / modify back dated stock entries older than %d days ago" %stock_frozen_upto_days, raise_exception=StockFreezeError) frappe.throw(_("Not allowed to update entries older than {0}").format(stock_frozen_upto_days), StockFreezeError)
def scrub_posting_time(self): def scrub_posting_time(self):
if not self.posting_time or self.posting_time == '00:0': if not self.posting_time or self.posting_time == '00:0':

View File

@@ -4,7 +4,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe.utils import cstr, flt, cint from frappe.utils import cstr, flt, cint
from frappe import msgprint, _ from frappe import _
from frappe.model.document import Document from frappe.model.document import Document
@@ -12,33 +12,28 @@ from frappe.model.document import Document
class StockUOMReplaceUtility(Document): class StockUOMReplaceUtility(Document):
def validate_mandatory(self): def validate_mandatory(self):
if not cstr(self.item_code): if not cstr(self.item_code):
msgprint("Please Enter an Item.") frappe.throw(_("Item is required"))
raise Exception
if not cstr(self.new_stock_uom): if not cstr(self.new_stock_uom):
msgprint("Please Enter New Stock UOM.") frappe.throw(_("New Stock UOM is required"))
raise Exception
if cstr(self.current_stock_uom) == cstr(self.new_stock_uom): if cstr(self.current_stock_uom) == cstr(self.new_stock_uom):
msgprint("Current Stock UOM and Stock UOM are same.") frappe.throw(_("New Stock UOM must be different from current stock UOM"))
raise Exception
# check conversion factor # check conversion factor
if not flt(self.conversion_factor): if not flt(self.conversion_factor):
msgprint("Please Enter Conversion Factor.") frappe.throw(_("Conversion Factor is required"))
raise Exception
stock_uom = frappe.db.get_value("Item", self.item_code, "stock_uom") stock_uom = frappe.db.get_value("Item", self.item_code, "stock_uom")
if cstr(self.new_stock_uom) == cstr(stock_uom): if cstr(self.new_stock_uom) == cstr(stock_uom):
msgprint("Item Master is already updated with New Stock UOM " + cstr(self.new_stock_uom)) frappe.throw(_("Item is updated"))
raise Exception
def update_item_master(self): def update_item_master(self):
item_doc = frappe.get_doc("Item", self.item_code) item_doc = frappe.get_doc("Item", self.item_code)
item_doc.stock_uom = self.new_stock_uom item_doc.stock_uom = self.new_stock_uom
item_doc.save() item_doc.save()
msgprint(_("Default UOM updated in item ") + self.item_code) frappe.msgprint(_("Stock UOM updatd for Item {0}").format(self.item_code))
def update_bin(self): def update_bin(self):
# update bin # update bin
@@ -59,7 +54,7 @@ class StockUOMReplaceUtility(Document):
(self.new_stock_uom, self.item_code) ) (self.new_stock_uom, self.item_code) )
# acknowledge user # acknowledge user
msgprint(" All Bins Updated Successfully.") frappe.msgprint(_("Stock balances updated"))
def update_stock_ledger_entry(self): def update_stock_ledger_entry(self):
# update stock ledger entry # update stock ledger entry
@@ -75,7 +70,7 @@ class StockUOMReplaceUtility(Document):
where item_code=%s""", (self.new_stock_uom, self.item_code)) where item_code=%s""", (self.new_stock_uom, self.item_code))
# acknowledge user # acknowledge user
msgprint("Stock Ledger Entries Updated Successfully.") frappe.msgprint(_("Stock Ledger entries balances updated"))
# update item valuation # update item valuation
if flt(self.conversion_factor) != flt(1): if flt(self.conversion_factor) != flt(1):
@@ -84,7 +79,7 @@ class StockUOMReplaceUtility(Document):
update_entries_after({"item_code": self.item_code, "warehouse": w[0]}) update_entries_after({"item_code": self.item_code, "warehouse": w[0]})
# acknowledge user # acknowledge user
msgprint("Item Valuation Updated Successfully.") frappe.msgprint(_("Item valuation updated"))
# Update Stock UOM # Update Stock UOM
def update_stock_uom(self): def update_stock_uom(self):
@@ -102,14 +97,11 @@ class StockUOMReplaceUtility(Document):
current_is_integer = frappe.db.get_value("UOM", self.current_stock_uom, "must_be_whole_number") current_is_integer = frappe.db.get_value("UOM", self.current_stock_uom, "must_be_whole_number")
new_is_integer = frappe.db.get_value("UOM", self.new_stock_uom, "must_be_whole_number") new_is_integer = frappe.db.get_value("UOM", self.new_stock_uom, "must_be_whole_number")
if current_is_integer and not new_is_integer:
frappe.msgprint("New UOM must be of type Whole Number", raise_exception=True)
if not current_is_integer and new_is_integer: if not current_is_integer and new_is_integer:
frappe.msgprint("New UOM must NOT be of type Whole Number", raise_exception=True) frappe.throw(_("New UOM must NOT be of type Whole Number"))
if current_is_integer and new_is_integer and cint(self.conversion_factor)!=self.conversion_factor: if current_is_integer and new_is_integer and cint(self.conversion_factor)!=self.conversion_factor:
frappe.msgprint("Conversion Factor cannot be fraction", raise_exception=True) frappe.throw(_("Conversion factor cannot be in fractions"))
@frappe.whitelist() @frappe.whitelist()
def get_stock_uom(item_code): def get_stock_uom(item_code):

View File

@@ -56,7 +56,7 @@ class Warehouse(Document):
ac_doc.ignore_permissions = True ac_doc.ignore_permissions = True
ac_doc.insert() ac_doc.insert()
msgprint(_("Account Head") + ": " + ac_doc.name + _(" created")) msgprint(_("Account head {0} created"))
def validate_parent_account(self): def validate_parent_account(self):
if not self.create_account_under: if not self.create_account_under:

View File

@@ -3,6 +3,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe import _
from frappe.utils import flt from frappe.utils import flt
def execute(filters=None): def execute(filters=None):
@@ -37,12 +38,12 @@ def get_columns(filters):
def get_conditions(filters): def get_conditions(filters):
conditions = "" conditions = ""
if not filters.get("from_date"): if not filters.get("from_date"):
frappe.msgprint("Please enter From Date", raise_exception=1) frappe.throw(_("'From Date' is required"))
if filters.get("to_date"): if filters.get("to_date"):
conditions += " and posting_date <= '%s'" % filters["to_date"] conditions += " and posting_date <= '%s'" % filters["to_date"]
else: else:
frappe.msgprint("Please enter To Date", raise_exception=1) frappe.throw(_("'To Date' is required"))
return conditions return conditions

View File

@@ -2,6 +2,7 @@
# License: GNU General Public License v3. See license.txt # License: GNU General Public License v3. See license.txt
import frappe import frappe
from frappe import _
from frappe.utils import getdate, flt from frappe.utils import getdate, flt
def execute(filters=None): def execute(filters=None):
@@ -13,7 +14,7 @@ def execute(filters=None):
avg_daily_outgoing = 0 avg_daily_outgoing = 0
diff = ((getdate(filters.get("to_date")) - getdate(filters.get("from_date"))).days)+1 diff = ((getdate(filters.get("to_date")) - getdate(filters.get("from_date"))).days)+1
if diff <= 0: if diff <= 0:
frappe.msgprint("To Date should not be less than eual to From Date",raise_exception=1) frappe.throw(_("'From Date' must be after 'To Date'"))
columns = get_columns() columns = get_columns()
items = get_item_info() items = get_item_info()
@@ -87,5 +88,5 @@ def get_condition(filters):
if filters.get("from_date") and filters.get("to_date"): if filters.get("from_date") and filters.get("to_date"):
conditions += " and posting_date between '%s' and '%s'" % (filters["from_date"],filters["to_date"]) conditions += " and posting_date between '%s' and '%s'" % (filters["from_date"],filters["to_date"])
else: else:
frappe.msgprint("Please set date in from date field",raise_exception=1) frappe.throw(_("From and To dates required"))
return conditions return conditions

View File

@@ -3,6 +3,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe import _
from frappe.utils import flt from frappe.utils import flt
def execute(filters=None): def execute(filters=None):
@@ -37,12 +38,12 @@ def get_columns(filters):
def get_conditions(filters): def get_conditions(filters):
conditions = "" conditions = ""
if not filters.get("from_date"): if not filters.get("from_date"):
frappe.msgprint("Please enter From Date", raise_exception=1) frappe.throw(_("'From Date' is required"))
if filters.get("to_date"): if filters.get("to_date"):
conditions += " and posting_date <= '%s'" % filters["to_date"] conditions += " and posting_date <= '%s'" % filters["to_date"]
else: else:
frappe.msgprint("Please enter To Date", raise_exception=1) frappe.throw(_("'To Date' is required"))
return conditions return conditions

View File

@@ -4,7 +4,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe import session, msgprint from frappe import session, _
from frappe.utils import today from frappe.utils import today
@@ -15,8 +15,7 @@ class CustomerIssue(TransactionBase):
def validate(self): def validate(self):
if session['user'] != 'Guest' and not self.customer: if session['user'] != 'Guest' and not self.customer:
msgprint("Please select Customer from whom issue is raised", frappe.throw(_("Customer is required"))
raise_exception=True)
if self.status=="Closed" and \ if self.status=="Closed" and \
frappe.db.get_value("Customer Issue", self.name, "status")!="Closed": frappe.db.get_value("Customer Issue", self.name, "status")!="Closed":
@@ -30,8 +29,7 @@ class CustomerIssue(TransactionBase):
(self.name)) (self.name))
if lst: if lst:
lst1 = ','.join([x[0] for x in lst]) lst1 = ','.join([x[0] for x in lst])
msgprint("Maintenance Visit No. "+lst1+" already created against this customer issue. So can not be Cancelled") frappe.throw(_("Cancel Material Visit {0} before cancelling this Customer Issue").format(lst1))
raise Exception
else: else:
frappe.db.set(self, 'status', 'Cancelled') frappe.db.set(self, 'status', 'Cancelled')

View File

@@ -151,7 +151,8 @@
"oldfieldname": "maintenance_visit_details", "oldfieldname": "maintenance_visit_details",
"oldfieldtype": "Table", "oldfieldtype": "Table",
"options": "Maintenance Visit Purpose", "options": "Maintenance Visit Purpose",
"permlevel": 0 "permlevel": 0,
"reqd": 1
}, },
{ {
"fieldname": "more_info", "fieldname": "more_info",
@@ -277,7 +278,7 @@
"icon": "icon-file-text", "icon": "icon-file-text",
"idx": 1, "idx": 1,
"is_submittable": 1, "is_submittable": 1,
"modified": "2014-01-20 17:48:57.000000", "modified": "2014-01-20 17:48:57.000001",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Support", "module": "Support",
"name": "Maintenance Visit", "name": "Maintenance Visit",

View File

@@ -3,12 +3,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe import _
from frappe.utils import cstr
from frappe import msgprint
from erpnext.utilities.transaction_base import TransactionBase from erpnext.utilities.transaction_base import TransactionBase
@@ -24,10 +19,6 @@ class MaintenanceVisit(TransactionBase):
def validate(self): def validate(self):
if not self.get('maintenance_visit_details'):
msgprint("Please enter maintenance details")
raise Exception
self.validate_serial_no() self.validate_serial_no()
def update_customer_issue(self, flag): def update_customer_issue(self, flag):
@@ -72,7 +63,7 @@ class MaintenanceVisit(TransactionBase):
if check: if check:
check_lst = [x[0] for x in check] check_lst = [x[0] for x in check]
check_lst =','.join(check_lst) check_lst =','.join(check_lst)
msgprint("To cancel this, you need to cancel Maintenance Visit(s) "+cstr(check_lst)+" created after this maintenance visit against same "+check_for_doctype) frappe.throw(_("Cancel Material Visits {0} before cancelling this Maintenance Visit").format(check_lst))
raise Exception raise Exception
else: else:
self.update_customer_issue(0) self.update_customer_issue(0)

View File

@@ -6,7 +6,7 @@ from __future__ import unicode_literals
import frappe import frappe
import frappe.utils import frappe.utils
from frappe.utils import cstr from frappe.utils import cstr
from frappe import msgprint, throw, _ from frappe import throw, _
from frappe.model.document import Document from frappe.model.document import Document
class Newsletter(Document): class Newsletter(Document):
@@ -20,10 +20,7 @@ class Newsletter(Document):
self.recipients = self.test_email_id.split(",") self.recipients = self.test_email_id.split(",")
self.send_to_doctype = "Lead" self.send_to_doctype = "Lead"
self.send_bulk() self.send_bulk()
msgprint("{send} {email}".format**{ frappe.msgprint(_("Scheduled to send to {0}").format(self.test_email_id))
"send": _("Scheduled to send to"),
"email": self.test_email_id
})
def send_emails(self): def send_emails(self):
"""send emails to leads and customers""" """send emails to leads and customers"""
@@ -33,11 +30,7 @@ class Newsletter(Document):
self.recipients = self.get_recipients() self.recipients = self.get_recipients()
self.send_bulk() self.send_bulk()
msgprint("{send} {recipients} {doctype}(s)".format(**{ frappe.msgprint(_("Scheduled to send to {0} recipients").format(len(self.recipients)))
"send": _("Scheduled to send to"),
"recipients": len(self.recipients),
"doctype": self.send_to_doctype
}))
frappe.db.set(self, "email_sent", 1) frappe.db.set(self, "email_sent", 1)
@@ -103,12 +96,11 @@ class Newsletter(Document):
def validate_send(self): def validate_send(self):
if self.get("__islocal"): if self.get("__islocal"):
throw(_("Please save the Newsletter before sending.")) throw(_("Please save the Newsletter before sending"))
from frappe import conf from frappe import conf
if (conf.get("status") or None) == "Trial": if (conf.get("status") or None) == "Trial":
throw(_("Sending newsletters is not allowed for Trial users, \ throw(_("Newsletters is not allowed for Trial users"))
to prevent abuse of this feature."))
@frappe.whitelist() @frappe.whitelist()
def get_lead_options(): def get_lead_options():

View File

@@ -5,7 +5,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe import _
from frappe.model.document import Document from frappe.model.document import Document
from frappe.utils.email_lib.receive import POP3Mailbox from frappe.utils.email_lib.receive import POP3Mailbox
import _socket, poplib import _socket, poplib
@@ -22,7 +22,7 @@ class SupportEmailSettings(Document):
inc_email.host = self.mail_server inc_email.host = self.mail_server
inc_email.use_ssl = self.use_ssl inc_email.use_ssl = self.use_ssl
try: try:
err_msg = 'User Name or Support Password missing. Please enter and try again.' err_msg = _('User Name or Support Password missing. Please enter and try again.')
if not (self.mail_login and self.mail_password): if not (self.mail_login and self.mail_password):
raise AttributeError, err_msg raise AttributeError, err_msg
inc_email.username = self.mail_login inc_email.username = self.mail_login
@@ -37,9 +37,8 @@ class SupportEmailSettings(Document):
pop_mb.connect() pop_mb.connect()
except _socket.error, e: except _socket.error, e:
# Invalid mail server -- due to refusing connection # Invalid mail server -- due to refusing connection
frappe.msgprint('Invalid POP3 Mail Server. Please rectify and try again.') frappe.msgprint(_('Invalid Mail Server. Please rectify and try again.'))
raise raise
except poplib.error_proto, e: except poplib.error_proto, e:
frappe.msgprint('Invalid User Name or Support Password. Please rectify and try again.') frappe.msgprint(_('Invalid User Name or Support Password. Please rectify and try again.'))
raise raise

View File

@@ -16,12 +16,12 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe import _, msgprint from frappe import _
from frappe.utils import cint, comma_or from frappe.utils import cint, comma_or
def validate_status(status, options): def validate_status(status, options):
if status not in options: if status not in options:
msgprint(_("Status must be one of ") + comma_or(options), raise_exception=True) frappe.throw(_("Status must be one of {0}").format(comma_or(options)))
def build_filter_conditions(filters): def build_filter_conditions(filters):
conditions, filter_values = [], [] conditions, filter_values = [], []

View File

@@ -4,8 +4,8 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe import msgprint, throw, _ from frappe import throw, _
from frappe.utils import cstr, cint from frappe.utils import cstr
from frappe.model.document import Document from frappe.model.document import Document

View File

@@ -5,7 +5,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe import _
from frappe.model.document import Document from frappe.model.document import Document
class Note(Document): class Note(Document):
@@ -18,11 +18,11 @@ class Note(Document):
def onload(self): def onload(self):
if not self.public and frappe.session.user != self.owner: if not self.public and frappe.session.user != self.owner:
if frappe.session.user not in [d.user for d in self.get("share_with")]: if frappe.session.user not in [d.user for d in self.get("share_with")]:
frappe.msgprint("You are not authorized to read this record.", raise_exception=True) frappe.throw(_("Not permitted"), frappe.PermissionError)
def validate(self): def validate(self):
if not self.get("__islocal"): if not self.get("__islocal"):
if frappe.session.user != self.owner: if frappe.session.user != self.owner:
if frappe.session.user not in frappe.db.sql_list("""select user from `tabNote User` if frappe.session.user not in frappe.db.sql_list("""select user from `tabNote User`
where parent=%s and permission='Edit'""", self.name): where parent=%s and permission='Edit'""", self.name):
frappe.msgprint("You are not authorized to edit this record.", raise_exception=True) frappe.throw(_("Not permitted"), frappe.PermissionError)

View File

@@ -20,7 +20,6 @@ def get_doctypes():
@frappe.whitelist() @frappe.whitelist()
def upload(select_doctype=None, rows=None): def upload(select_doctype=None, rows=None):
from frappe.utils.datautils import read_csv_content_from_uploaded_file from frappe.utils.datautils import read_csv_content_from_uploaded_file
from frappe.modules import scrub
from frappe.model.rename_doc import rename_doc from frappe.model.rename_doc import rename_doc
if not select_doctype: if not select_doctype:
@@ -32,12 +31,11 @@ def upload(select_doctype=None, rows=None):
if not rows: if not rows:
rows = read_csv_content_from_uploaded_file() rows = read_csv_content_from_uploaded_file()
if not rows: if not rows:
frappe.msgprint(_("Please select a valid csv file with data.")) frappe.throw(_("Please select a valid csv file with data"))
raise Exception
if len(rows) > 500: max_rows = 500
frappe.msgprint(_("Max 500 rows only.")) if len(rows) > max_rows:
raise Exception frappe.throw(_("Maximum {0} rows allowed").format(max_rows))
rename_log = [] rename_log = []
for row in rows: for row in rows:

View File

@@ -34,12 +34,9 @@ class SMSControl(Document):
'ERPNXT' 'ERPNXT'
if len(sender_name) > 6 and \ if len(sender_name) > 6 and \
frappe.db.get_default("country") == "India": frappe.db.get_default("country") == "India":
throw(_(""" throw("""As per TRAI rule, sender name must be exactly 6 characters.
As per TRAI rule, sender name must be exactly 6 characters.
Kindly change sender name in Setup --> Global Defaults. Kindly change sender name in Setup --> Global Defaults.
Note: Hyphen, space, numeric digit, special characters are not allowed.""")
Note: Hyphen, space, numeric digit, special characters are not allowed.
"""))
return sender_name return sender_name
def get_contact_number(self, arg): def get_contact_number(self, arg):

View File

@@ -71,8 +71,7 @@ class TransactionBase(StatusUpdater):
if ref_dn not in item_ref_dn: if ref_dn not in item_ref_dn:
item_ref_dn.append(ref_dn) item_ref_dn.append(ref_dn)
elif not val.get("allow_duplicate_prev_row_id"): elif not val.get("allow_duplicate_prev_row_id"):
frappe.msgprint(_("Row ") + cstr(d.idx + 1) + frappe.throw(_("Duplicate row {0} with same {1}").format(d.idx, key))
_(": Duplicate row from same ") + key, raise_exception=1)
elif ref_dn: elif ref_dn:
ref_doc.setdefault(key, []) ref_doc.setdefault(key, [])
if ref_dn not in ref_doc[key]: if ref_dn not in ref_doc[key]:
@@ -112,7 +111,4 @@ def validate_uom_is_integer(doc, uom_field, qty_fields):
for f in qty_fields: for f in qty_fields:
if d.get(f): if d.get(f):
if cint(d.get(f))!=d.get(f): if cint(d.get(f))!=d.get(f):
frappe.msgprint(_("For UOM") + " '" + d.get(uom_field) \ frappe.throw(_("Quantity cannot be a fraction in row {0}").format(d.idx), UOMMustBeIntegerError)
+ "': " + _("Quantity cannot be a fraction.") \
+ " " + _("In Row") + ": " + str(d.idx),
raise_exception=UOMMustBeIntegerError)