more message fixes

This commit is contained in:
Rushabh Mehta 2014-04-15 18:40:00 +05:30
parent a6e2ca9d3b
commit ff93802d58
26 changed files with 551 additions and 646 deletions

View File

@ -3,7 +3,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import frappe import frappe
from frappe.utils import flt, fmt_money, cstr, cint from frappe.utils import flt, cstr, cint
from frappe import msgprint, throw, _ from frappe import msgprint, throw, _
from frappe.model.document import Document from frappe.model.document import Document
@ -52,12 +52,7 @@ class Account(Document):
if self.get('__islocal') or not self.name: if self.get('__islocal') or not self.name:
company_abbr = frappe.db.get_value("Company", self.company, "abbr") company_abbr = frappe.db.get_value("Company", self.company, "abbr")
if frappe.db.exists("Account", (self.account_name + " - " + company_abbr)): if frappe.db.exists("Account", (self.account_name + " - " + company_abbr)):
throw("{name}: {acc_name} {exist}, {rename}".format(**{ throw(_("Account {0} already exists").format(self.account_name))
"name": _("Account Name"),
"acc_name": self.account_name,
"exist": _("already exists"),
"rename": _("please rename")
}))
def validate_root_details(self): def validate_root_details(self):
#does not exists parent #does not exists parent
@ -76,14 +71,9 @@ class Account(Document):
def convert_group_to_ledger(self): def convert_group_to_ledger(self):
if self.check_if_child_exists(): if self.check_if_child_exists():
throw("{acc}: {account_name} {child}. {msg}".format(**{ throw(_("Account with child nodes cannot be converted to ledger"))
"acc": _("Account"),
"account_name": self.name,
"child": _("has existing child"),
"msg": _("You can not convert this account to ledger")
}))
elif self.check_gle_exists(): elif self.check_gle_exists():
throw(_("Account with existing transaction can not be converted to ledger.")) throw(_("Account with existing transaction cannot be converted to ledger"))
else: else:
self.group_or_ledger = 'Ledger' self.group_or_ledger = 'Ledger'
self.save() self.save()
@ -159,10 +149,7 @@ class Account(Document):
# If outstanding greater than credit limit and not authorized person raise exception # If outstanding greater than credit limit and not authorized person raise exception
if credit_limit > 0 and flt(total_outstanding) > credit_limit \ if credit_limit > 0 and flt(total_outstanding) > credit_limit \
and not self.get_authorized_user(): and not self.get_authorized_user():
throw("""Total Outstanding amount (%s) for <b>%s</b> can not be \ throw(_("{0} Credit limit {0} crossed").format(_(credit_limit_from), credit_limit))
greater than credit limit (%s). To change your credit limit settings, \
please update in the <b>%s</b> master""" % (fmt_money(total_outstanding),
self.name, fmt_money(credit_limit), credit_limit_from))
def validate_trash(self): def validate_trash(self):
"""checks gl entries and if child exists""" """checks gl entries and if child exists"""
@ -170,8 +157,7 @@ class Account(Document):
throw(_("Root account can not be deleted")) throw(_("Root account can not be deleted"))
if self.check_gle_exists(): if self.check_gle_exists():
throw("""Account with existing transaction (Sales Invoice / Purchase Invoice / \ throw(_("Account with existing transaction can not be deleted"))
Journal Voucher) can not be deleted""")
if self.check_if_child_exists(): if self.check_if_child_exists():
throw(_("Child account exists for this account. You can not delete this account.")) throw(_("Child account exists for this account. You can not delete this account."))
@ -193,9 +179,7 @@ class Account(Document):
["group_or_ledger", "report_type", "company"])) ["group_or_ledger", "report_type", "company"]))
if val != [self.group_or_ledger, self.report_type, self.company]: if val != [self.group_or_ledger, self.report_type, self.company]:
throw(_("""Merging is only possible if following \ throw(_("""Merging is only possible if following properties are same in both records. Group or Ledger, Report Type, Company"""))
properties are same in both records.
Group or Ledger, Report Type, Company"""))
return new_account return new_account

View File

@ -17,11 +17,7 @@ class CForm(Document):
inv = frappe.db.sql("""select c_form_applicable, c_form_no from inv = frappe.db.sql("""select c_form_applicable, c_form_no from
`tabSales Invoice` where name = %s and docstatus = 1""", d.invoice_no) `tabSales Invoice` where name = %s and docstatus = 1""", d.invoice_no)
if not inv: if inv[0][0] != 'Yes':
frappe.throw("""Invoice: %s is not exists in the system or
is not submitted, please check.""" % d.invoice_no)
elif inv[0][0] != 'Yes':
frappe.throw("C-form is not applicable for Invoice: %s" % d.invoice_no) frappe.throw("C-form is not applicable for Invoice: %s" % d.invoice_no)
elif inv[0][1] and inv[0][1] != self.name: elif inv[0][1] and inv[0][1] != self.name:

View File

@ -65,8 +65,7 @@ def get_conditions(filters):
if party_accounts: if party_accounts:
conditions += " and jvd.account in (%s)" % (", ".join(['%s']*len(party_accounts))) conditions += " and jvd.account in (%s)" % (", ".join(['%s']*len(party_accounts)))
else: else:
msgprint(_("No Customer or Supplier Accounts found. Accounts are identified based on \ msgprint(_("No Customer or Supplier Accounts found"), raise_exception=1)
'Master Type' value in account record."), raise_exception=1)
if filters.get("from_date"): conditions += " and jv.posting_date >= '%s'" % filters["from_date"] if filters.get("from_date"): conditions += " and jv.posting_date >= '%s'" % filters["from_date"]
if filters.get("to_date"): conditions += " and jv.posting_date <= '%s'" % filters["to_date"] if filters.get("to_date"): conditions += " and jv.posting_date <= '%s'" % filters["to_date"]

View File

@ -147,7 +147,7 @@ class PurchaseCommon(BuyingController):
stopped = frappe.db.sql("""select name from `tab%s` where name = %s and stopped = frappe.db.sql("""select name from `tab%s` where name = %s and
status = 'Stopped'""" % (doctype, '%s'), docname) status = 'Stopped'""" % (doctype, '%s'), docname)
if stopped: if stopped:
frappe.throw("{0} {1} status is 'Stopped'".format(doctype, docname), frappe.InvalidStatusError) frappe.throw(_("{0} {1} status is 'Stopped'").format(doctype, docname), frappe.InvalidStatusError)
def check_docstatus(self, check, doctype, docname, detail_doctype = ''): def check_docstatus(self, check, doctype, docname, detail_doctype = ''):
if check == 'Next': if check == 'Next':

View File

@ -61,11 +61,7 @@ erpnext.hr.EmployeeController = frappe.ui.form.Controller.extend({
var me = this; var me = this;
this.validate_salary_structure(btn, function(r) { this.validate_salary_structure(btn, function(r) {
if(r.message) { if(r.message) {
msgprint(__("Employee {0}:\ msgprint(__("Active Salary Sructure already exists for Employee {0}", [me.frm.doc.name]));
An active Salary Structure already exists. \
If you want to create new one, please ensure that no active \
Salary Structure exists for this Employee. \
Go to the active Salary Structure and set \"Is Active\" = \"No\"", [me.frm.doc.name]));
} else if(!r.exc) { } else if(!r.exc) {
frappe.model.map({ frappe.model.map({
source: me.frm.doc, source: me.frm.doc,

View File

@ -63,7 +63,7 @@ class LeaveAllocation(Document):
cf = cf and cint(cf[0][0]) or 0 cf = cf and cint(cf[0][0]) or 0
if not cf: if not cf:
frappe.db.set(self,'carry_forward',0) frappe.db.set(self,'carry_forward',0)
frappe.throw("Cannot carry forward {0}".format(self.leave_type)) frappe.throw(_("Cannot carry forward {0}").format(self.leave_type))
def get_carry_forwarded_leaves(self): def get_carry_forwarded_leaves(self):
if self.carry_forward: if self.carry_forward:

View File

@ -144,8 +144,7 @@ class LeaveApplication(DocListController):
def validate_max_days(self): def validate_max_days(self):
max_days = frappe.db.get_value("Leave Type", self.leave_type, "max_days_allowed") max_days = frappe.db.get_value("Leave Type", self.leave_type, "max_days_allowed")
if max_days and self.total_leave_days > max_days: if max_days and self.total_leave_days > max_days:
frappe.throw("Sorry ! You cannot apply for %s for more than %s days" % frappe.throw(_("Leave of type {0} cannot be longer than {1}").format(self.leave_type, max_days))
(self.leave_type, max_days))
def validate_leave_approver(self): def validate_leave_approver(self):
employee = frappe.get_doc("Employee", self.employee) employee = frappe.get_doc("Employee", self.employee)

View File

@ -130,7 +130,7 @@ class SalarySlip(TransactionBase):
(self.month, self.fiscal_year, self.employee, self.name)) (self.month, self.fiscal_year, self.employee, self.name))
if ret_exist: if ret_exist:
self.employee = '' self.employee = ''
frappe.throw("Salary Slip of employee {0} already created for this month".format(self.employee)) frappe.throw(_("Salary Slip of employee {0} already created for this month").format(self.employee))
def validate(self): def validate(self):
from frappe.utils import money_in_words from frappe.utils import money_in_words

View File

@ -5,7 +5,7 @@ from __future__ import unicode_literals
import frappe import frappe
from frappe.utils import cstr, flt, nowdate from frappe.utils import cstr, flt, nowdate
from frappe import msgprint, _ from frappe import _
class OverProductionError(frappe.ValidationError): pass class OverProductionError(frappe.ValidationError): pass
@ -34,9 +34,7 @@ class ProductionOrder(Document):
and is_active=1 and item=%s""" and is_active=1 and item=%s"""
, (self.bom_no, self.production_item), as_dict =1) , (self.bom_no, self.production_item), as_dict =1)
if not bom: if not bom:
frappe.throw("""Incorrect BOM: %s entered. frappe.throw(_("BOM {0} is not active or not submitted").format(self.bom_no))
May be BOM not exists or inactive or not submitted
or for some other item.""" % cstr(self.bom_no))
def validate_sales_order(self): def validate_sales_order(self):
if self.sales_order: if self.sales_order:
@ -44,7 +42,7 @@ class ProductionOrder(Document):
where name=%s and docstatus = 1""", self.sales_order, as_dict=1)[0] where name=%s and docstatus = 1""", self.sales_order, as_dict=1)[0]
if not so.name: if not so.name:
frappe.throw("Sales Order: %s is not valid" % self.sales_order) frappe.throw(_("Sales Order {0} is not valid") % self.sales_order)
if not self.expected_delivery_date: if not self.expected_delivery_date:
self.expected_delivery_date = so.delivery_date self.expected_delivery_date = so.delivery_date
@ -115,8 +113,7 @@ class ProductionOrder(Document):
stock_entry = frappe.db.sql("""select name from `tabStock Entry` stock_entry = frappe.db.sql("""select name from `tabStock Entry`
where production_order = %s and docstatus = 1""", self.name) where production_order = %s and docstatus = 1""", self.name)
if stock_entry: if stock_entry:
frappe.throw("""Submitted Stock Entry %s exists against this production order. frappe.throw(_("Cannot cancel because submitted Stock Entry {0} exists").format(stock_entry[0][0]))
Hence can not be cancelled.""" % stock_entry[0][0])
frappe.db.set(self,'status', 'Cancelled') frappe.db.set(self,'status', 'Cancelled')
self.update_planned_qty(-self.qty) self.update_planned_qty(-self.qty)

View File

@ -152,21 +152,17 @@ class ProductionPlanningTool(Document):
for d in self.get('pp_details'): for d in self.get('pp_details'):
self.validate_bom_no(d) self.validate_bom_no(d)
if not flt(d.planned_qty): if not flt(d.planned_qty):
frappe.throw("Please Enter Planned Qty for item: %s at row no: %s" % frappe.throw(_("Please enter Planned Qty for Item {0} at row {1}").format(d.item_code, d.idx))
(d.item_code, d.idx))
def validate_bom_no(self, d): def validate_bom_no(self, d):
if not d.bom_no: if not d.bom_no:
frappe.throw("Please enter bom no for item: %s at row no: %s" % frappe.throw(_("Please enter BOM for Item {0} at row {1}").format(d.item_code, d.idx))
(d.item_code, d.idx))
else: else:
bom = frappe.db.sql("""select name from `tabBOM` where name = %s and item = %s bom = frappe.db.sql("""select name from `tabBOM` where name = %s and item = %s
and docstatus = 1 and is_active = 1""", and docstatus = 1 and is_active = 1""",
(d.bom_no, d.item_code), as_dict = 1) (d.bom_no, d.item_code), as_dict = 1)
if not bom: if not bom:
frappe.throw("""Incorrect BOM No: %s entered for item: %s at row no: %s frappe.throw(_("Incorrect or Inactive BOM {0} for Item {1} at row {2}").format(d.bom_no, d.item_code, d.idx))
May be BOM is inactive or for other item or does not exists in the system""" %
(d.bom_no, d.item_doce, d.idx))
def raise_production_order(self): def raise_production_order(self):
"""It will raise production order (Draft) for all distinct FG items""" """It will raise production order (Draft) for all distinct FG items"""

View File

@ -354,14 +354,9 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
validate_on_previous_row: function(tax) { validate_on_previous_row: function(tax) {
// validate if a valid row id is mentioned in case of // validate if a valid row id is mentioned in case of
// On Previous Row Amount and On Previous Row Total // On Previous Row Amount and On Previous Row Total
if(([__("On Previous Row Amount"), __("On Previous Row Total")].indexOf(tax.charge_type) != -1) && if((["On Previous Row Amount", "On Previous Row Total"].indexOf(tax.charge_type) != -1) &&
(!tax.row_id || cint(tax.row_id) >= tax.idx)) { (!tax.row_id || cint(tax.row_id) >= tax.idx)) {
var msg = repl(__("Row") + " # %(idx)s [%(doctype)s]: " + var msg = __("Please specify a valid Row ID for row {0} in table {1}", [tax.idx, __(tax.doctype)])
__("Please specify a valid") + " %(row_id_label)s", {
idx: tax.idx,
doctype: tax.doctype,
row_id_label: frappe.meta.get_label(tax.doctype, "row_id", tax.name)
});
frappe.throw(msg); frappe.throw(msg);
} }
}, },
@ -370,28 +365,13 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
if(!this.frm.tax_doclist) this.frm.tax_doclist = this.get_tax_doclist(); if(!this.frm.tax_doclist) this.frm.tax_doclist = this.get_tax_doclist();
var actual_type_error = function() { var actual_type_error = function() {
var msg = repl(__("For row") + " # %(idx)s [%(doctype)s]: " + var msg = __("Actual type tax cannot be included in Item rate in row {0}", [tax.idx])
"%(charge_type_label)s = \"%(charge_type)s\" " +
__("cannot be included in Item's rate"), {
idx: tax.idx,
doctype: tax.doctype,
charge_type_label: frappe.meta.get_label(tax.doctype, "charge_type", tax.name),
charge_type: tax.charge_type
});
frappe.throw(msg); frappe.throw(msg);
}; };
var on_previous_row_error = function(row_range) { var on_previous_row_error = function(row_range) {
var msg = repl(__("For row") + " # %(idx)s [%(doctype)s]: " + var msg = __("For row {0} in {1}. To include {2} in Item rate, rows {3} must also be included",
__("to be included in Item's rate, it is required that: ") + [tax.idx, __(tax.doctype), tax.charge_type, row_range])
" [" + __("Row") + " # %(row_range)s] " + __("also be included in Item's rate"), {
idx: tax.idx,
doctype: tax.doctype,
charge_type_label: frappe.meta.get_label(tax.doctype, "charge_type", tax.name),
charge_type: tax.charge_type,
inclusive_label: frappe.meta.get_label(tax.doctype, "included_in_print_rate", tax.name),
row_range: row_range,
});
frappe.throw(msg); frappe.throw(msg);
}; };

View File

@ -27,7 +27,7 @@ class Customer(TransactionBase):
def validate_values(self): def validate_values(self):
if frappe.defaults.get_global_default('cust_master_name') == 'Naming Series' and not self.naming_series: if frappe.defaults.get_global_default('cust_master_name') == 'Naming Series' and not self.naming_series:
frappe.throw("Series is Mandatory.", frappe.MandatoryError) frappe.throw(_("Series is mandatory"), frappe.MandatoryError)
def validate(self): def validate(self):
self.validate_values() self.validate_values()
@ -66,7 +66,7 @@ class Customer(TransactionBase):
c.is_primary_contact = 1 c.is_primary_contact = 1
try: try:
c.save() c.save()
except NameError, e: except NameError:
pass pass
def on_update(self): def on_update(self):
@ -86,7 +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.throw("A Customer Group exists with same name please change the Customer name or rename the Customer Group") frappe.throw(_("A Customer Group exists with same name please change the Customer name or rename the Customer Group"))
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`

View File

@ -27,11 +27,11 @@ class Lead(SellingController):
self.set_status() self.set_status()
if self.source == 'Campaign' and not self.campaign_name and session['user'] != 'Guest': if self.source == 'Campaign' and not self.campaign_name and session['user'] != 'Guest':
frappe.throw("Please specify campaign name") frappe.throw(_("Campaign Name is required"))
if self.email_id: if self.email_id:
if not validate_email_add(self.email_id): if not validate_email_add(self.email_id):
frappe.throw('Please enter valid email id.') frappe.throw(_('{0} is not a valid email id').format(self.email_id))
def on_update(self): def on_update(self):
self.check_email_id_is_unique() self.check_email_id_is_unique()

View File

@ -145,7 +145,7 @@ class SalesOrder(SellingController):
if quotation: if quotation:
doc = frappe.get_doc("Quotation", quotation) doc = frappe.get_doc("Quotation", quotation)
if doc.docstatus==2: if doc.docstatus==2:
frappe.throw(quotation + ": " + frappe._("Quotation is cancelled.")) frappe.throw(_("Quotation {0} is cancelled").format(quotation))
doc.set_status(update=True) doc.set_status(update=True)

View File

@ -17,6 +17,4 @@ class CustomerGroup(NestedSet):
def validate_name_with_customer(self): def validate_name_with_customer(self):
if frappe.db.exists("Customer", self.name): if frappe.db.exists("Customer", self.name):
frappe.msgprint(_("An Customer exists with same name (%s), \ frappe.msgprint(_("An Customer exists with same name"), raise_exception=1)
please change the Customer Group name or rename the Customer") %
self.name, raise_exception=1)

View File

@ -24,7 +24,7 @@
"permlevel": 0 "permlevel": 0
}, },
{ {
"description": "To track brand name in the following documents<br>\nDelivery Note, Enuiry, Material Request, Item, Purchase Order, Purchase Voucher, Purchaser Receipt, Quotation, Sales Invoice, Sales BOM, Sales Order, Serial No", "description": "To track brand name in the following documents Delivery Note, Opportunity, Material Request, Item, Purchase Order, Purchase Voucher, Purchaser Receipt, Quotation, Sales Invoice, Sales BOM, Sales Order, Serial No",
"fieldname": "fs_brands", "fieldname": "fs_brands",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Brands", "label": "Brands",
@ -50,7 +50,7 @@
"permlevel": 0 "permlevel": 0
}, },
{ {
"description": "If Sale BOM is defined, the actual BOM of the Pack is displayed as table.\nAvailable in Delivery Note and Sales Order", "description": "If Sale BOM is defined, the actual BOM of the Pack is displayed as table. Available in Delivery Note and Sales Order",
"fieldname": "fs_packing_details", "fieldname": "fs_packing_details",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Packing Details", "label": "Packing Details",
@ -70,14 +70,14 @@
"permlevel": 0 "permlevel": 0
}, },
{ {
"description": "All export related fields like currency, conversion rate, export total, export grand total etc are available in <br>\nDelivery Note, POS, Quotation, Sales Invoice, Sales Order etc.", "description": "All export related fields like currency, conversion rate, export total, export grand total etc are available in Delivery Note, POS, Quotation, Sales Invoice, Sales Order etc.",
"fieldname": "fs_exports", "fieldname": "fs_exports",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Exports", "label": "Exports",
"permlevel": 0 "permlevel": 0
}, },
{ {
"description": "All import related fields like currency, conversion rate, import total, import grand total etc are available in <br>\nPurchase Receipt, Supplier Quotation, Purchase Invoice, Purchase Order etc.", "description": "All import related fields like currency, conversion rate, import total, import grand total etc are available in Purchase Receipt, Supplier Quotation, Purchase Invoice, Purchase Order etc.",
"fieldname": "fs_imports", "fieldname": "fs_imports",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Imports", "label": "Imports",
@ -110,7 +110,7 @@
"permlevel": 0 "permlevel": 0
}, },
{ {
"description": "Available in \nBOM, Delivery Note, Purchase Invoice, Production Order, Purchase Order, Purchase Receipt, Sales Invoice, Sales Order, Stock Entry, Timesheet", "description": "Available in BOM, Delivery Note, Purchase Invoice, Production Order, Purchase Order, Purchase Receipt, Sales Invoice, Sales Order, Stock Entry, Timesheet",
"fieldname": "fs_projects", "fieldname": "fs_projects",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Projects", "label": "Projects",
@ -162,7 +162,7 @@
"permlevel": 0 "permlevel": 0
}, },
{ {
"description": "If you involve in manufacturing activity<br>\nEnables item <b>Is Manufactured</b>", "description": "If you involve in manufacturing activity. Enables Item 'Is Manufactured'",
"fieldname": "fs_manufacturing", "fieldname": "fs_manufacturing",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Manufacturing", "label": "Manufacturing",
@ -174,7 +174,7 @@
"permlevel": 0 "permlevel": 0
}, },
{ {
"description": "If you follow Quality Inspection<br>\nEnables item QA Required and QA No in Purchase Receipt", "description": "If you follow Quality Inspection. Enables Item QA Required and QA No in Purchase Receipt",
"fieldname": "fs_quality", "fieldname": "fs_quality",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Quality", "label": "Quality",

View File

@ -104,19 +104,12 @@ class NamingSeries(Document):
if i[0]: if i[0]:
existing_series = [d.split('.')[0] for d in i[0].split("\n")] existing_series = [d.split('.')[0] for d in i[0].split("\n")]
if series.split(".")[0] in existing_series: if series.split(".")[0] in existing_series:
throw("{oops}! {sr} {series} {msg} {existing_series}. {select}".format(**{ frappe.throw(_("Series {0} already used in {1}").format(series,i[1]))
"oops": _("Oops"),
"sr": _("Series Name"),
"series": series,
"msg": _("is already in use in"),
"existing_series": i[1],
"select": _("Please select a new one")
}))
def validate_series_name(self, n): def validate_series_name(self, n):
import re import re
if not re.match("^[a-zA-Z0-9-/.#]*$", n): if not re.match("^[a-zA-Z0-9-/.#]*$", n):
throw('Special Characters except "-" and "/" not allowed in naming series') throw(_('Special Characters except "-" and "/" not allowed in naming series'))
def get_options(self, arg=''): def get_options(self, arg=''):
return frappe.get_meta(self.select_doc_for_series).get_field("naming_series").options return frappe.get_meta(self.select_doc_for_series).get_field("naming_series").options

View File

@ -23,6 +23,6 @@ class SalesPerson(NestedSet):
if self.employee: if self.employee:
user = frappe.db.get_value("Employee", self.employee, "user_id") user = frappe.db.get_value("Employee", self.employee, "user_id")
if not user: if not user:
frappe.throw("User ID not set for Employee %s" % self.employee) frappe.throw(_("User ID not set for Employee {0}").format(self.employee))
else: else:
return frappe.db.get_value("User", user, "email") or user return frappe.db.get_value("User", user, "email") or user

View File

@ -11,8 +11,7 @@ def get_company_currency(company):
if not currency: if not currency:
currency = frappe.db.get_default("currency") currency = frappe.db.get_default("currency")
if not currency: if not currency:
throw(_('Please specify Default Currency in Company Master \ throw(_('Please specify Default Currency in Company Master and Global Defaults'))
and Global Defaults'))
return currency return currency

View File

@ -109,8 +109,7 @@ class Item(WebsiteGenerator):
self.is_pro_applicable = "No" self.is_pro_applicable = "No"
if self.is_pro_applicable == 'Yes' and self.is_stock_item == 'No': if self.is_pro_applicable == 'Yes' and self.is_stock_item == 'No':
frappe.throw(_("As Production Order can be made for this item, \ frappe.throw(_("As Production Order can be made for this item, it must be a stock item."))
it must be a stock item."))
if self.has_serial_no == 'Yes' and self.is_stock_item == 'No': if self.has_serial_no == 'Yes' and self.is_stock_item == 'No':
msgprint(_("'Has Serial No' can not be 'Yes' for non-stock item"), raise_exception=1) msgprint(_("'Has Serial No' can not be 'Yes' for non-stock item"), raise_exception=1)
@ -123,15 +122,13 @@ class Item(WebsiteGenerator):
and t2.docstatus = 1 and t1.docstatus =1 """, self.name) and t2.docstatus = 1 and t1.docstatus =1 """, self.name)
if bom_mat and bom_mat[0][0]: if bom_mat and bom_mat[0][0]:
frappe.throw(_("Item must be a purchase item, \ frappe.throw(_("Item must be a purchase item, as it is present in one or many Active BOMs"))
as it is present in one or many Active BOMs"))
if self.is_manufactured_item != "Yes": if self.is_manufactured_item != "Yes":
bom = frappe.db.sql("""select name from `tabBOM` where item = %s bom = frappe.db.sql("""select name from `tabBOM` where item = %s
and is_active = 1""", (self.name,)) and is_active = 1""", (self.name,))
if bom and bom[0][0]: if bom and bom[0][0]:
frappe.throw(_("""Allow Bill of Materials should be 'Yes'. Because one or many \ frappe.throw(_("""Allow Bill of Materials should be 'Yes'. Because one or many active BOMs present for this item"""))
active BOMs present for this item"""))
def fill_customer_code(self): def fill_customer_code(self):
""" Append all the customer codes and insert into "customer_code" field of item table """ """ Append all the customer codes and insert into "customer_code" field of item table """

View File

@ -20,31 +20,18 @@ class ItemPrice(Document):
def validate_item(self): def validate_item(self):
if not frappe.db.exists("Item", self.item_code): if not frappe.db.exists("Item", self.item_code):
throw("{doctype}: {item} {not_found}".format(**{ throw(_("Item {0} not found").format(self.item_code))
"doctype": _("Item"),
"item": self.item_code,
"not_found": _(" not found")
}))
def validate_price_list(self): def validate_price_list(self):
enabled = frappe.db.get_value("Price List", self.price_list, "enabled") enabled = frappe.db.get_value("Price List", self.price_list, "enabled")
if not enabled: if not enabled:
throw("{message}: {price_list} {disabled}".format(**{ throw(_("Price List {0} is disabled").format(self.price_list))
"message": _("Price List"),
"price_list": self.price_list,
"disabled": _("is disabled.")
}))
def check_duplicate_item(self): def check_duplicate_item(self):
if frappe.db.sql("""select name from `tabItem Price` if frappe.db.sql("""select name from `tabItem Price`
where item_code=%s and price_list=%s and name!=%s""", where item_code=%s and price_list=%s and name!=%s""",
(self.item_code, self.price_list, self.name)): (self.item_code, self.price_list, self.name)):
throw("{duplicate_item}: {item_code}, {already}: {price_list}".format(**{ frappe.throw(_("Item {0} appears multiple times in Price List {1}").format(self.item_code, self.price_list))
"duplicate_item": _("Duplicate Item"),
"item_code": self.item_code,
"already": _("already available in Price List"),
"price_list": self.price_list
}), ItemPriceDuplicateItem)
def update_price_list_details(self): def update_price_list_details(self):
self.buying, self.selling, self.currency = \ self.buying, self.selling, self.currency = \
@ -54,4 +41,3 @@ class ItemPrice(Document):
def update_item_details(self): def update_item_details(self):
self.item_name, self.item_description = frappe.db.get_value("Item", self.item_name, self.item_description = frappe.db.get_value("Item",
self.item_code, ["item_name", "description"]) self.item_code, ["item_name", "description"])

View File

@ -8,7 +8,7 @@ from __future__ import unicode_literals
import frappe import frappe
from frappe.utils import cstr, flt from frappe.utils import cstr, flt
from frappe import msgprint, _ from frappe import _
from erpnext.controllers.buying_controller import BuyingController from erpnext.controllers.buying_controller import BuyingController
class MaterialRequest(BuyingController): class MaterialRequest(BuyingController):
@ -43,9 +43,7 @@ class MaterialRequest(BuyingController):
actual_so_qty = actual_so_qty and flt(actual_so_qty[0][0]) or 0 actual_so_qty = actual_so_qty and flt(actual_so_qty[0][0]) or 0
if actual_so_qty and (flt(so_items[so_no][item]) + already_indented > actual_so_qty): if actual_so_qty and (flt(so_items[so_no][item]) + already_indented > actual_so_qty):
frappe.throw("You can raise indent of maximum qty: %s for item: %s against sales order: %s\ frappe.throw(_("Material Request of maximum {0} can be made for Item {1} against Sales Order {2}").format(actual_so_qty - already_indented, item, so_no))
\n Anyway, you can add more qty in new row for the same item."
% (actual_so_qty - already_indented, item, so_no))
def validate_schedule_date(self): def validate_schedule_date(self):
for d in self.get('indent_details'): for d in self.get('indent_details'):

View File

@ -27,8 +27,7 @@ class SerialNo(StockController):
def validate(self): def validate(self):
if self.get("__islocal") and self.warehouse: if self.get("__islocal") and self.warehouse:
frappe.throw(_("New Serial No cannot have Warehouse. Warehouse must be \ frappe.throw(_("New Serial No cannot have Warehouse. Warehouse must be set by Stock Entry or Purchase Receipt"), SerialNoCannotCreateDirectError)
set by Stock Entry or Purchase Receipt"), SerialNoCannotCreateDirectError)
self.set_maintenance_status() self.set_maintenance_status()
self.validate_warehouse() self.validate_warehouse()
@ -166,8 +165,7 @@ class SerialNo(StockController):
if self.status == 'Delivered': if self.status == 'Delivered':
frappe.throw(_("Delivered Serial No ") + self.name + _(" can not be deleted")) frappe.throw(_("Delivered Serial No ") + self.name + _(" can not be deleted"))
if self.warehouse: if self.warehouse:
frappe.throw(_("Cannot delete Serial No in warehouse. \ frappe.throw(_("Cannot delete Serial No in warehouse. First remove from warehouse, then delete.") + ": " + self.name)
First remove from warehouse, then delete.") + ": " + self.name)
def before_rename(self, old, new, merge=False): def before_rename(self, old, new, merge=False):
if merge: if merge:

View File

@ -105,10 +105,7 @@ class StockReconciliation(StockController):
# item should not be serialized # item should not be serialized
if item.has_serial_no == "Yes": if item.has_serial_no == "Yes":
raise frappe.ValidationError, (_("Serialized Item: '") + item_code + raise frappe.ValidationError, _("Serialized Item {0} cannot be updated using Stock Reconciliation").format(item_code)
_("""' can not be managed using Stock Reconciliation.\
You can add/delete Serial No directly, \
to modify stock of this item."""))
# docstatus should be < 2 # docstatus should be < 2
validate_cancelled_item(item_code, item.docstatus, verbose=0) validate_cancelled_item(item_code, item.docstatus, verbose=0)
@ -291,10 +288,7 @@ class StockReconciliation(StockController):
elif not frappe.db.sql("""select * from `tabStock Ledger Entry`"""): elif not frappe.db.sql("""select * from `tabStock Ledger Entry`"""):
if frappe.db.get_value("Account", self.expense_account, if frappe.db.get_value("Account", self.expense_account,
"report_type") == "Profit and Loss": "report_type") == "Profit and Loss":
msgprint(_("""Expense Account can not be a PL Account, as this stock \ frappe.throw(_("'Profit and Loss' type Account {0} used be set for Opening Entry").format(self.expense_account))
reconciliation is an opening entry. \
Please select 'Temporary Account (Liabilities)' or relevant account"""),
raise_exception=1)
@frappe.whitelist() @frappe.whitelist()
def upload(): def upload():

View File

@ -65,8 +65,7 @@ class Warehouse(Document):
if parent_account: if parent_account:
self.create_account_under = parent_account self.create_account_under = parent_account
else: else:
frappe.throw(_("Please enter account group under which account \ frappe.throw(_("Please enter parent account group for warehouse account"))
for warehouse ") + self.name +_(" will be created"))
def on_trash(self): def on_trash(self):
# delete bin # delete bin
@ -75,8 +74,7 @@ class Warehouse(Document):
for d in bins: for d in bins:
if d['actual_qty'] or d['reserved_qty'] or d['ordered_qty'] or \ if d['actual_qty'] or d['reserved_qty'] or d['ordered_qty'] or \
d['indented_qty'] or d['projected_qty'] or d['planned_qty']: d['indented_qty'] or d['projected_qty'] or d['planned_qty']:
throw("""Warehouse: %s can not be deleted as qty exists for item: %s""" throw(_("Warehouse {0} can not be deleted as quantity exists for Item {1}").format(self.name, d['item_code']))
% (self.name, d['item_code']))
else: else:
frappe.db.sql("delete from `tabBin` where name = %s", d['name']) frappe.db.sql("delete from `tabBin` where name = %s", d['name'])
@ -87,8 +85,7 @@ class Warehouse(Document):
if frappe.db.sql("""select name from `tabStock Ledger Entry` if frappe.db.sql("""select name from `tabStock Ledger Entry`
where warehouse = %s""", self.name): where warehouse = %s""", self.name):
throw(_("""Warehouse can not be deleted as stock ledger entry throw(_("Warehouse can not be deleted as stock ledger entry exists for this warehouse."))
exists for this warehouse."""))
def before_rename(self, olddn, newdn, merge=False): def before_rename(self, olddn, newdn, merge=False):
# Add company abbr if not provided # Add company abbr if not provided

View File

@ -222,8 +222,7 @@ class MaintenanceSchedule(TransactionBase):
if sr_details.status=="Delivered" and sr_details.delivery_date and \ if sr_details.status=="Delivered" and sr_details.delivery_date and \
sr_details.delivery_date >= amc_start_date: sr_details.delivery_date >= amc_start_date:
throw(_("Maintenance start date can not be before \ throw(_("Maintenance start date can not be before delivery date for Serial No {0}").format(serial_no))
delivery date for serial no: ") + serial_no)
def validate_schedule(self): def validate_schedule(self):
item_lst1 =[] item_lst1 =[]
@ -237,8 +236,7 @@ class MaintenanceSchedule(TransactionBase):
item_lst2.append(m.item_code) item_lst2.append(m.item_code)
if len(item_lst1) != len(item_lst2): if len(item_lst1) != len(item_lst2):
throw(_("Maintenance Schedule is not generated for all the items. \ throw(_("Maintenance Schedule is not generated for all the items. Please click on 'Generate Schedule'"))
Please click on 'Generate Schedule'"))
else: else:
for x in item_lst1: for x in item_lst1:
if x not in item_lst2: if x not in item_lst2: