update translation strings #1403
This commit is contained in:
@@ -50,6 +50,6 @@ class BankReconciliation(Document):
|
||||
vouchers.append(d.voucher_id)
|
||||
|
||||
if vouchers:
|
||||
msgprint("Clearance Date updated in %s" % ", ".join(vouchers))
|
||||
msgprint("Clearance Date updated in: {0}".format(", ".join(vouchers)))
|
||||
else:
|
||||
msgprint(_("Clearance Date not mentioned"))
|
||||
@@ -17,18 +17,18 @@ class CostCenter(NestedSet):
|
||||
|
||||
def validate_mandatory(self):
|
||||
if not self.group_or_ledger:
|
||||
msgprint("Please select Group or Ledger value", raise_exception=1)
|
||||
msgprint(_("Please select Group or Ledger value"), raise_exception=1)
|
||||
|
||||
if self.cost_center_name != self.company and not self.parent_cost_center:
|
||||
msgprint("Please enter parent cost center", raise_exception=1)
|
||||
msgprint(_("Please enter parent cost center"), raise_exception=1)
|
||||
elif self.cost_center_name == self.company and self.parent_cost_center:
|
||||
msgprint(_("Root cannot have a parent cost center"), raise_exception=1)
|
||||
|
||||
def convert_group_to_ledger(self):
|
||||
if self.check_if_child_exists():
|
||||
msgprint("Cost Center: %s has existing child. You can not convert this cost center to ledger" % (self.name), raise_exception=1)
|
||||
msgprint(_("Cannot convert Cost Center to ledger as it has child nodes"), raise_exception=1)
|
||||
elif self.check_gle_exists():
|
||||
msgprint("Cost Center with existing transaction can not be converted to ledger.", raise_exception=1)
|
||||
msgprint(_("Cost Center with existing transactions can not be converted to ledger"), raise_exception=1)
|
||||
else:
|
||||
self.group_or_ledger = 'Ledger'
|
||||
self.save()
|
||||
@@ -36,7 +36,7 @@ class CostCenter(NestedSet):
|
||||
|
||||
def convert_ledger_to_group(self):
|
||||
if self.check_gle_exists():
|
||||
msgprint("Cost Center with existing transaction can not be converted to group.", raise_exception=1)
|
||||
msgprint(_("Cost Center with existing transactions can not be converted to group"), raise_exception=1)
|
||||
else:
|
||||
self.group_or_ledger = 'Group'
|
||||
self.save()
|
||||
@@ -53,10 +53,10 @@ class CostCenter(NestedSet):
|
||||
check_acc_list = []
|
||||
for d in self.get('budget_details'):
|
||||
if self.group_or_ledger=="Group":
|
||||
msgprint("Budget cannot be set for Group Cost Centers", raise_exception=1)
|
||||
msgprint(_("Budget cannot be set for Group Cost Centers"), raise_exception=1)
|
||||
|
||||
if [d.account, d.fiscal_year] in check_acc_list:
|
||||
msgprint("Account " + d.account + "has been entered more than once for fiscal year " + d.fiscal_year, raise_exception=1)
|
||||
msgprint(_("Account {0} has been entered more than once for fiscal year {1}").format(d.account, d.fiscal_year), raise_exception=1)
|
||||
else:
|
||||
check_acc_list.append([d.account, d.fiscal_year])
|
||||
|
||||
@@ -65,7 +65,7 @@ class CostCenter(NestedSet):
|
||||
Cost Center name must be unique
|
||||
"""
|
||||
if (self.get("__islocal") or not self.name) and frappe.db.sql("select name from `tabCost Center` where cost_center_name = %s and company=%s", (self.cost_center_name, self.company)):
|
||||
msgprint("Cost Center Name already exists, please rename", raise_exception=1)
|
||||
msgprint(_("Cost Center Name already exists"), raise_exception=1)
|
||||
|
||||
self.validate_mandatory()
|
||||
self.validate_budget_details()
|
||||
|
||||
@@ -17,8 +17,7 @@ class FiscalYear(Document):
|
||||
# clear cache
|
||||
frappe.clear_cache()
|
||||
|
||||
msgprint(self.name + _(""" is now the default Fiscal Year. \
|
||||
Please refresh your browser for the change to take effect."""))
|
||||
msgprint(_("{0} is now the default Fiscal Year. Please refresh your browser for the change to take effect.").format(self.name))
|
||||
|
||||
def validate(self):
|
||||
year_start_end_dates = frappe.db.sql("""select year_start_date, year_end_date
|
||||
|
||||
@@ -57,17 +57,16 @@ class JournalVoucher(AccountsController):
|
||||
def validate_debit_credit(self):
|
||||
for d in self.get('entries'):
|
||||
if d.debit and d.credit:
|
||||
msgprint("You cannot credit and debit same account at the same time.",
|
||||
raise_exception=1)
|
||||
msgprint(_("You cannot credit and debit same account at the same time."), raise_exception=1)
|
||||
|
||||
def validate_cheque_info(self):
|
||||
if self.voucher_type in ['Bank Voucher']:
|
||||
if not self.cheque_no or not self.cheque_date:
|
||||
msgprint("Reference No & Reference Date is required for %s" %
|
||||
self.voucher_type, raise_exception=1)
|
||||
msgprint(_("Reference No & Reference Date is required for {0}").format(self.voucher_type),
|
||||
raise_exception=1)
|
||||
|
||||
if self.cheque_date and not self.cheque_no:
|
||||
msgprint("Reference No is mandatory if you entered Reference Date", raise_exception=1)
|
||||
msgprint(_("Reference No is mandatory if you entered Reference Date"), raise_exception=1)
|
||||
|
||||
def validate_entries_for_advance(self):
|
||||
for d in self.get('entries'):
|
||||
@@ -76,19 +75,17 @@ class JournalVoucher(AccountsController):
|
||||
master_type = frappe.db.get_value("Account", d.account, "master_type")
|
||||
if (master_type == 'Customer' and flt(d.credit) > 0) or \
|
||||
(master_type == 'Supplier' and flt(d.debit) > 0):
|
||||
msgprint("Message: Please check Is Advance as 'Yes' against \
|
||||
Account %s if this is an advance entry." % d.account)
|
||||
msgprint(_("Please check 'Is Advance' against Account {0} if this is an advance entry.").format(d.account))
|
||||
|
||||
def validate_against_jv(self):
|
||||
for d in self.get('entries'):
|
||||
if d.against_jv:
|
||||
if d.against_jv == self.name:
|
||||
msgprint("You can not enter current voucher in 'Against JV' column",
|
||||
raise_exception=1)
|
||||
msgprint(_("You can not enter current voucher in 'Against Journal Voucher' column"), raise_exception=1)
|
||||
elif not frappe.db.sql("""select name from `tabJournal Voucher Detail`
|
||||
where account = %s and docstatus = 1 and parent = %s""",
|
||||
(d.account, d.against_jv)):
|
||||
msgprint("Against JV: %s is not valid." % d.against_jv, raise_exception=1)
|
||||
msgprint(_("Journal Voucher {0} does not have account {1}.").format(d.against_jv, d.account), raise_exception=1)
|
||||
|
||||
def set_against_account(self):
|
||||
# Debit = Credit
|
||||
@@ -104,8 +101,8 @@ class JournalVoucher(AccountsController):
|
||||
self.total_credit = credit
|
||||
|
||||
if abs(self.total_debit-self.total_credit) > 0.001:
|
||||
msgprint("Debit must be equal to Credit. The difference is %s" %
|
||||
(self.total_debit-self.total_credit), raise_exception=1)
|
||||
msgprint(_("Debit must equal Credit. The difference is {0}").format(self.total_debit-self.total_credit),
|
||||
raise_exception=1)
|
||||
|
||||
# update against account
|
||||
for d in self.get('entries'):
|
||||
@@ -116,10 +113,9 @@ class JournalVoucher(AccountsController):
|
||||
r = []
|
||||
if self.cheque_no:
|
||||
if self.cheque_date:
|
||||
r.append('Via Reference #%s dated %s' %
|
||||
(self.cheque_no, formatdate(self.cheque_date)))
|
||||
r.append(_('Reference #{0} dated {1}').fomrat(self.cheque_no, formatdate(self.cheque_date)))
|
||||
else :
|
||||
msgprint("Please enter Reference date", raise_exception=1)
|
||||
msgprint(_("Please enter Reference date"), raise_exception=1)
|
||||
|
||||
for d in self.get('entries'):
|
||||
if d.against_invoice and d.credit:
|
||||
@@ -137,12 +133,12 @@ class JournalVoucher(AccountsController):
|
||||
bill_no[0][1] and formatdate(bill_no[0][1].strftime('%Y-%m-%d')) or ''))
|
||||
|
||||
if self.user_remark:
|
||||
r.append("User Remark : %s"%self.user_remark)
|
||||
r.append(_("Note: {0}").format(self.user_remark))
|
||||
|
||||
if r:
|
||||
self.remark = ("\n").join(r)
|
||||
else:
|
||||
frappe.msgprint("User Remarks is mandatory", raise_exception=1)
|
||||
frappe.msgprint(_("User Remarks is mandatory"), raise_exception=1)
|
||||
|
||||
def set_aging_date(self):
|
||||
if self.is_opening != 'Yes':
|
||||
@@ -158,7 +154,7 @@ class JournalVoucher(AccountsController):
|
||||
|
||||
# If customer/supplier account, aging date is mandatory
|
||||
if exists and not self.aging_date:
|
||||
msgprint("Aging Date is mandatory for opening entry", raise_exception=1)
|
||||
msgprint(_("Aging Date is mandatory for opening entry"), raise_exception=1)
|
||||
else:
|
||||
self.aging_date = self.posting_date
|
||||
|
||||
@@ -195,8 +191,8 @@ class JournalVoucher(AccountsController):
|
||||
credit_days = self.get_credit_days_for(d.account)
|
||||
# Check credit days
|
||||
if credit_days > 0 and not self.get_authorized_user() and cint(date_diff) > credit_days:
|
||||
msgprint("Credit Not Allowed: Cannot allow a check that is dated \
|
||||
more than %s days after the posting date" % credit_days, raise_exception=1)
|
||||
msgprint(_("Maximum allowed credit is {0} days after posting date").format(credit_days),
|
||||
raise_exception=1)
|
||||
|
||||
def get_credit_days_for(self, ac):
|
||||
if not self.credit_days_for.has_key(ac):
|
||||
@@ -272,7 +268,7 @@ class JournalVoucher(AccountsController):
|
||||
|
||||
def get_balance(self):
|
||||
if not self.get('entries'):
|
||||
msgprint("Please enter atleast 1 entry in 'GL Entries' table")
|
||||
msgprint(_("'Entries' cannot be empty"), raise_exception=True)
|
||||
else:
|
||||
flag, self.total_debit, self.total_credit = 0, 0, 0
|
||||
diff = flt(self.difference, 2)
|
||||
@@ -390,7 +386,7 @@ def get_payment_entry(doc):
|
||||
jv.company = doc.company
|
||||
jv.fiscal_year = doc.fiscal_year
|
||||
|
||||
d1 = jv.append("entries")
|
||||
jv.append("entries")
|
||||
d2 = jv.append("entries")
|
||||
|
||||
if bank_account:
|
||||
|
||||
@@ -79,7 +79,7 @@ class PaymenttoInvoiceMatchingTool(Document):
|
||||
|
||||
def validate_mandatory(self):
|
||||
if not self.account:
|
||||
msgprint("Please select Account first", raise_exception=1)
|
||||
msgprint(_("Please select Account first"), raise_exception=1)
|
||||
|
||||
def reconcile(self):
|
||||
"""
|
||||
@@ -112,9 +112,9 @@ class PaymenttoInvoiceMatchingTool(Document):
|
||||
if lst:
|
||||
from erpnext.accounts.utils import reconcile_against_document
|
||||
reconcile_against_document(lst)
|
||||
msgprint("Successfully allocated.")
|
||||
msgprint(_("Successfully allocated"))
|
||||
else:
|
||||
msgprint("No amount allocated.", raise_exception=1)
|
||||
msgprint(_("No amount allocated"), raise_exception=1)
|
||||
|
||||
def gl_entry_details(doctype, txt, searchfield, start, page_len, filters):
|
||||
from erpnext.controllers.queries import get_match_cond
|
||||
|
||||
@@ -23,11 +23,11 @@ class POSSetting(Document):
|
||||
(self.user, self.name, self.company))
|
||||
if res:
|
||||
if res[0][1]:
|
||||
msgprint("POS Setting '%s' already created for user: '%s' and company: '%s'" %
|
||||
(res[0][0], res[0][1], self.company), raise_exception=1)
|
||||
msgprint(_("POS Setting {0} already created for user: {1} and company {2}").format(res[0][0],
|
||||
res[0][1], self.company), raise_exception=1)
|
||||
else:
|
||||
msgprint("Global POS Setting already created - %s for this company: '%s'" %
|
||||
(res[0][0], self.company), raise_exception=1)
|
||||
msgprint(_("Global POS Setting {0} already created for company {1}").format(res[0][0],
|
||||
self.company), raise_exception=1)
|
||||
|
||||
def validate_expense_account(self):
|
||||
if cint(frappe.defaults.get_global_default("auto_accounting_for_stock")) \
|
||||
|
||||
@@ -6,7 +6,7 @@ import frappe
|
||||
|
||||
from frappe.utils import cint, cstr, flt, formatdate
|
||||
|
||||
from frappe import msgprint, _
|
||||
from frappe import msgprint, _, throw
|
||||
from erpnext.setup.utils import get_company_currency
|
||||
|
||||
import frappe.defaults
|
||||
@@ -73,22 +73,15 @@ class PurchaseInvoice(BuyingController):
|
||||
def check_active_purchase_items(self):
|
||||
for d in self.get('entries'):
|
||||
if d.item_code: # extra condn coz item_code is not mandatory in PV
|
||||
valid_item = frappe.db.sql("select docstatus,is_purchase_item from tabItem where name = %s",d.item_code)
|
||||
if valid_item[0][0] == 2:
|
||||
msgprint("Item : '%s' is Inactive, you can restore it from Trash" %(d.item_code))
|
||||
raise Exception
|
||||
if not valid_item[0][1] == 'Yes':
|
||||
msgprint("Item : '%s' is not Purchase Item"%(d.item_code))
|
||||
raise Exception
|
||||
if frappe.db.get_value("Item", d.item_code, "is_purchase_item") != 'Yes':
|
||||
msgprint(_("Item {0} is not Purchase Item").format(d.item_code), raise_exception=True)
|
||||
|
||||
def check_conversion_rate(self):
|
||||
default_currency = get_company_currency(self.company)
|
||||
if not default_currency:
|
||||
msgprint('Message: Please enter default currency in Company Master')
|
||||
raise Exception
|
||||
throw(_('Please enter default currency in Company Master'))
|
||||
if (self.currency == default_currency and flt(self.conversion_rate) != 1.00) or not self.conversion_rate or (self.currency != default_currency and flt(self.conversion_rate) == 1.00):
|
||||
msgprint("Message: Please Enter Appropriate Conversion Rate.")
|
||||
raise Exception
|
||||
throw(_("Conversion rate cannot be 0 or 1"))
|
||||
|
||||
def validate_bill_no(self):
|
||||
if self.bill_no and self.bill_no.lower().strip() \
|
||||
@@ -97,13 +90,12 @@ class PurchaseInvoice(BuyingController):
|
||||
where bill_no = %s and credit_to = %s and docstatus = 1 and name != %s""",
|
||||
(self.bill_no, self.credit_to, self.name))
|
||||
if b_no and cstr(b_no[0][2]) == cstr(self.is_opening):
|
||||
msgprint("Please check you have already booked expense against Bill No. %s \
|
||||
in Purchase Invoice %s" % (cstr(b_no[0][0]), cstr(b_no[0][1])),
|
||||
raise_exception=1)
|
||||
throw(_("Bill No {0} already booked in Purchase Invoice {1}").format(cstr(b_no[0][0]),
|
||||
cstr(b_no[0][1])))
|
||||
|
||||
if not self.remarks and self.bill_date:
|
||||
self.remarks = (self.remarks or '') + "\n" + ("Against Bill %s dated %s"
|
||||
% (self.bill_no, formatdate(self.bill_date)))
|
||||
self.remarks = (self.remarks or '') + "\n" \
|
||||
+ _("Against Bill %s dated %s").format(self.bill_no, formatdate(self.bill_date))
|
||||
|
||||
if not self.remarks:
|
||||
self.remarks = "No Remarks"
|
||||
@@ -130,7 +122,7 @@ class PurchaseInvoice(BuyingController):
|
||||
check_list.append(d.purchase_order)
|
||||
stopped = frappe.db.sql("select name from `tabPurchase Order` where status = 'Stopped' and name = %s", d.purchase_order)
|
||||
if stopped:
|
||||
msgprint("One cannot do any transaction against 'Purchase Order' : %s, it's status is 'Stopped'" % (d.purhcase_order))
|
||||
throw(_("Purchase Order {0} is 'Stopped'").format(d.purchase_order))
|
||||
raise Exception
|
||||
|
||||
def validate_with_previous_doc(self):
|
||||
@@ -176,7 +168,7 @@ class PurchaseInvoice(BuyingController):
|
||||
if self.is_opening != 'Yes':
|
||||
self.aging_date = self.posting_date
|
||||
elif not self.aging_date:
|
||||
msgprint("Aging Date is mandatory for opening entry")
|
||||
msgprint(_("Ageing date is mandatory for opening entry"))
|
||||
raise Exception
|
||||
|
||||
def set_against_expense_account(self):
|
||||
@@ -199,8 +191,7 @@ class PurchaseInvoice(BuyingController):
|
||||
against_accounts.append(stock_not_billed_account)
|
||||
|
||||
elif not item.expense_account:
|
||||
msgprint(_("Expense account is mandatory for item") + ": " +
|
||||
(item.item_code or item.item_name), raise_exception=1)
|
||||
throw(_("Expense account is mandatory for item {0}").format(item.item_code or item.item_name))
|
||||
|
||||
elif item.expense_account not in against_accounts:
|
||||
# if no auto_accounting_for_stock or not a stock item
|
||||
@@ -212,19 +203,18 @@ class PurchaseInvoice(BuyingController):
|
||||
if frappe.db.get_value("Buying Settings", None, "po_required") == 'Yes':
|
||||
for d in self.get('entries'):
|
||||
if not d.purchase_order:
|
||||
msgprint("Purchse Order No. required against item %s"%d.item_code)
|
||||
raise Exception
|
||||
throw(_("Purchse Order number required for Item {0}").format(d.item_code))
|
||||
|
||||
def pr_required(self):
|
||||
if frappe.db.get_value("Buying Settings", None, "pr_required") == 'Yes':
|
||||
for d in self.get('entries'):
|
||||
if not d.purchase_receipt:
|
||||
msgprint("Purchase Receipt No. required against item %s"%d.item_code)
|
||||
throw(_("Purchase Receipt number required for Item {0}").format(d.item_code))
|
||||
raise Exception
|
||||
|
||||
def validate_write_off_account(self):
|
||||
if self.write_off_amount and not self.write_off_account:
|
||||
msgprint("Please enter Write Off Account", raise_exception=1)
|
||||
throw(_("Please enter Write Off Account"))
|
||||
|
||||
def check_prev_docstatus(self):
|
||||
for d in self.get('entries'):
|
||||
|
||||
@@ -6,9 +6,9 @@ import frappe
|
||||
import frappe.defaults
|
||||
|
||||
from frappe.utils import add_days, cint, cstr, date_diff, flt, getdate, nowdate, \
|
||||
get_first_day, get_last_day, comma_and
|
||||
get_first_day, get_last_day
|
||||
from frappe.model.naming import make_autoname
|
||||
from frappe import _, msgprint
|
||||
from frappe import _, msgprint, throw
|
||||
|
||||
from erpnext.accounts.party import get_party_account, get_due_date
|
||||
from erpnext.controllers.stock_controller import update_gl_entries_after
|
||||
@@ -165,8 +165,7 @@ class SalesInvoice(SellingController):
|
||||
if d.time_log_batch:
|
||||
status = frappe.db.get_value("Time Log Batch", d.time_log_batch, "status")
|
||||
if status!="Submitted":
|
||||
frappe.msgprint(_("Time Log Batch status must be 'Submitted'") + ":" + d.time_log_batch,
|
||||
raise_exception=True)
|
||||
frappe.throw(_("Time Log Batch {0} must be 'Submitted'").format(d.time_log_batch))
|
||||
|
||||
def set_pos_fields(self, for_validate=False):
|
||||
"""Set retail related fields from pos settings"""
|
||||
@@ -263,10 +262,8 @@ class SalesInvoice(SellingController):
|
||||
where name = %s and (ifnull(end_of_life,'')='' or end_of_life > now())""", d.item_code)
|
||||
acc = frappe.db.sql("""select account_type from `tabAccount`
|
||||
where name = %s and docstatus != 2""", d.income_account)
|
||||
if not acc:
|
||||
msgprint("Account: "+d.income_account+" does not exist in the system", raise_exception=True)
|
||||
elif item and item[0][1] == 'Yes' and not acc[0][0] == 'Fixed Asset':
|
||||
msgprint("Please select income head with account type 'Fixed Asset' as Item %s is an asset item" % d.item_code, raise_exception=True)
|
||||
if item and item[0][1] == 'Yes' and not acc[0][0] == 'Fixed Asset':
|
||||
msgprint(_("Account {0} must be of type 'Fixed Asset' as Item {1} is an Asset Item").format(d.item_code), raise_exception=True)
|
||||
|
||||
def validate_with_previous_doc(self):
|
||||
super(SalesInvoice, self).validate_with_previous_doc(self.tname, {
|
||||
@@ -302,7 +299,7 @@ class SalesInvoice(SellingController):
|
||||
if self.is_opening != 'Yes':
|
||||
self.aging_date = self.posting_date
|
||||
elif not self.aging_date:
|
||||
msgprint("Aging Date is mandatory for opening entry")
|
||||
msgprint(_("Ageing Date is mandatory for opening entry"))
|
||||
raise Exception
|
||||
|
||||
|
||||
@@ -327,7 +324,7 @@ class SalesInvoice(SellingController):
|
||||
for d in self.get('entries'):
|
||||
if frappe.db.get_value('Item', d.item_code, 'is_stock_item') == 'Yes' \
|
||||
and not d.get(i.lower().replace(' ','_')):
|
||||
msgprint("%s is mandatory for stock item which is not mentioed against item: %s"%(i,d.item_code), raise_exception=1)
|
||||
msgprint(_("{0} is mandatory for Item {1}").format(i,d.item_code), raise_exception=1)
|
||||
|
||||
|
||||
def validate_proj_cust(self):
|
||||
@@ -337,34 +334,32 @@ class SalesInvoice(SellingController):
|
||||
where name = %s and (customer = %s or
|
||||
ifnull(customer,'')='')""", (self.project_name, self.customer))
|
||||
if not res:
|
||||
msgprint("Customer - %s does not belong to project - %s. \n\nIf you want to use project for multiple customers then please make customer details blank in that project."%(self.customer,self.project_name))
|
||||
msgprint(_("Customer {0} does not belong to project {1}").format(self.customer,self.project_name))
|
||||
raise Exception
|
||||
|
||||
def validate_pos(self):
|
||||
if not self.cash_bank_account and flt(self.paid_amount):
|
||||
msgprint("Cash/Bank Account is mandatory for POS, for making payment entry")
|
||||
msgprint(_("Cash or Bank Account is mandatory for making payment entry"))
|
||||
raise Exception
|
||||
if flt(self.paid_amount) + flt(self.write_off_amount) \
|
||||
- flt(self.grand_total) > 1/(10**(self.precision("grand_total") + 1)):
|
||||
frappe.throw(_("""(Paid amount + Write Off Amount) can not be \
|
||||
greater than Grand Total"""))
|
||||
frappe.throw(_("""Paid amount + Write Off Amount can not be greater than Grand Total"""))
|
||||
|
||||
|
||||
def validate_item_code(self):
|
||||
for d in self.get('entries'):
|
||||
if not d.item_code:
|
||||
msgprint("Please enter Item Code at line no : %s to update stock or remove check from Update Stock in Basic Info Tab." % (d.idx),
|
||||
raise_exception=True)
|
||||
msgprint(_("Item Code required at Row No {0}").format(d.idx), raise_exception=True)
|
||||
|
||||
def validate_delivery_note(self):
|
||||
for d in self.get("entries"):
|
||||
if d.delivery_note:
|
||||
msgprint("""Stock update can not be made against Delivery Note""", raise_exception=1)
|
||||
msgprint(_("Stock cannot be updated against Delivery Note {0}").format(d.delivery_note), raise_exception=1)
|
||||
|
||||
|
||||
def validate_write_off_account(self):
|
||||
if flt(self.write_off_amount) and not self.write_off_account:
|
||||
msgprint("Please enter Write Off Account", raise_exception=1)
|
||||
msgprint(_("Please enter Write Off Account"), raise_exception=1)
|
||||
|
||||
|
||||
def validate_c_form(self):
|
||||
@@ -396,9 +391,9 @@ class SalesInvoice(SellingController):
|
||||
ps = frappe.db.sql("""select name, warehouse from `tabPOS Setting`
|
||||
where ifnull(user,'') = '' and company = %s""", self.company)
|
||||
if not ps:
|
||||
msgprint("To make POS entry, please create POS Setting from Accounts --> POS Setting page and refresh the system.", raise_exception=True)
|
||||
msgprint(_("POS Setting required to make POS Entry"), raise_exception=True)
|
||||
elif not ps[0][1]:
|
||||
msgprint("Please enter warehouse in POS Setting")
|
||||
msgprint(_("Warehouse required in POS Setting"))
|
||||
else:
|
||||
w = ps[0][1]
|
||||
return w
|
||||
@@ -426,7 +421,7 @@ class SalesInvoice(SellingController):
|
||||
else:
|
||||
# show message that the amount is not paid
|
||||
frappe.db.set(self,'paid_amount',0)
|
||||
frappe.msgprint("Note: Payment Entry will not be created since 'Cash/Bank Account' was not specified.")
|
||||
frappe.msgprint(_("Note: Payment Entry will not be created since 'Cash or Bank Account' was not specified"))
|
||||
else:
|
||||
frappe.db.set(self,'paid_amount',0)
|
||||
|
||||
@@ -436,15 +431,15 @@ class SalesInvoice(SellingController):
|
||||
submitted = frappe.db.sql("""select name from `tabSales Order`
|
||||
where docstatus = 1 and name = %s""", d.sales_order)
|
||||
if not submitted:
|
||||
msgprint("Sales Order : "+ cstr(d.sales_order) +" is not submitted")
|
||||
raise Exception , "Validation Error."
|
||||
msgprint(_("Sales Order {0} is not submitted").format(d.sales_order))
|
||||
raise Exception
|
||||
|
||||
if d.delivery_note:
|
||||
submitted = frappe.db.sql("""select name from `tabDelivery Note`
|
||||
where docstatus = 1 and name = %s""", d.delivery_note)
|
||||
if not submitted:
|
||||
msgprint("Delivery Note : "+ cstr(d.delivery_note) +" is not submitted")
|
||||
raise Exception , "Validation Error."
|
||||
msgprint(_("Delivery Note {0} is not submitted").format(d.delivery_note))
|
||||
raise Exception
|
||||
|
||||
def update_stock_ledger(self):
|
||||
sl_entries = []
|
||||
@@ -594,15 +589,12 @@ class SalesInvoice(SellingController):
|
||||
self.validate_notification_email_id()
|
||||
|
||||
if not self.recurring_type:
|
||||
msgprint(_("Please select: ") + self.meta.get_label("recurring_type"),
|
||||
msgprint(_("Please select {0}").format(self.meta.get_label("recurring_type")),
|
||||
raise_exception=1)
|
||||
|
||||
elif not (self.invoice_period_from_date and \
|
||||
self.invoice_period_to_date):
|
||||
msgprint(comma_and([self.meta.get_label("invoice_period_from_date"),
|
||||
self.meta.get_label("invoice_period_to_date")])
|
||||
+ _(": Mandatory for a Recurring Invoice."),
|
||||
raise_exception=True)
|
||||
throw(_("Invoice Period From and Invoice Period To dates mandatory for recurring invoice"))
|
||||
|
||||
def convert_to_recurring(self):
|
||||
if self.convert_into_recurring_invoice:
|
||||
@@ -625,20 +617,15 @@ class SalesInvoice(SellingController):
|
||||
from frappe.utils import validate_email_add
|
||||
for email in email_list:
|
||||
if not validate_email_add(email):
|
||||
msgprint(self.meta.get_label("notification_email_address") \
|
||||
+ " - " + _("Invalid Email Address") + ": \"%s\"" % email,
|
||||
raise_exception=1)
|
||||
throw(_("{0} is an invalid email address in 'Notification Email Address'").format(email))
|
||||
|
||||
else:
|
||||
msgprint("Notification Email Addresses not specified for recurring invoice",
|
||||
raise_exception=1)
|
||||
throw(_("'Notification Email Addresses' not specified for recurring invoice"))
|
||||
|
||||
def set_next_date(self):
|
||||
""" Set next date on which auto invoice will be created"""
|
||||
if not self.repeat_on_day_of_month:
|
||||
msgprint("""Please enter 'Repeat on Day of Month' field value.
|
||||
The day of the month on which auto invoice
|
||||
will be generated e.g. 05, 28 etc.""", raise_exception=1)
|
||||
msgprint(_("Please enter 'Repeat on Day of Month' field value"), raise_exception=1)
|
||||
|
||||
next_date = get_next_date(self.posting_date,
|
||||
month_map[self.recurring_type], cint(self.repeat_on_day_of_month))
|
||||
@@ -765,7 +752,7 @@ def assign_task_to_owner(inv, msg, users):
|
||||
def get_bank_cash_account(mode_of_payment):
|
||||
val = frappe.db.get_value("Mode of Payment", mode_of_payment, "default_account")
|
||||
if not val:
|
||||
frappe.msgprint("Default Bank / Cash Account not set in Mode of Payment: %s. Please add a Default Account in Mode of Payment master." % mode_of_payment)
|
||||
frappe.msgprint(_("Please set default Cash or Bank account in Mode of Payment {0}").format(mode_of_payment))
|
||||
return {
|
||||
"cash_bank_account": val
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _, msgprint
|
||||
from frappe import _, msgprint, throw
|
||||
from frappe.utils import flt, fmt_money
|
||||
from frappe.model.controller import DocListController
|
||||
from erpnext.setup.utils import get_company_currency
|
||||
@@ -36,14 +36,12 @@ class ShippingRule(DocListController):
|
||||
if not d.to_value:
|
||||
zero_to_values.append(d)
|
||||
elif d.from_value >= d.to_value:
|
||||
msgprint(_("Error") + ": " + _("Row") + " # %d: " % d.idx +
|
||||
_("From Value should be less than To Value"),
|
||||
raise_exception=FromGreaterThanToError)
|
||||
throw(_("From value must be less than to value in row {0}").format(d.idx), FromGreaterThanToError)
|
||||
|
||||
# check if more than two or more rows has To Value = 0
|
||||
if len(zero_to_values) >= 2:
|
||||
msgprint(_('''There can only be one Shipping Rule Condition with 0 or blank value for "To Value"'''),
|
||||
raise_exception=ManyBlankToValuesError)
|
||||
throw(_('There can only be one Shipping Rule Condition with 0 or blank value for "To Value"'),
|
||||
ManyBlankToValuesError)
|
||||
|
||||
def sort_shipping_rule_conditions(self):
|
||||
"""Sort Shipping Rule Conditions based on increasing From Value"""
|
||||
@@ -75,7 +73,7 @@ class ShippingRule(DocListController):
|
||||
|
||||
if overlaps:
|
||||
company_currency = get_company_currency(self.company)
|
||||
msgprint(_("Error") + ": " + _("Overlapping Conditions found between") + ":")
|
||||
msgprint(_("Overlapping conditions found between:"))
|
||||
messages = []
|
||||
for d1, d2 in overlaps:
|
||||
messages.append("%s-%s = %s " % (d1.from_value, d1.to_value, fmt_money(d1.shipping_amount, currency=company_currency)) +
|
||||
|
||||
@@ -180,4 +180,4 @@ def create_party_account(party, party_type, company):
|
||||
"report_type": "Balance Sheet"
|
||||
}).insert(ignore_permissions=True)
|
||||
|
||||
frappe.msgprint(_("Account Created") + ": " + account.name)
|
||||
frappe.msgprint(_("Account Created: {0}").format(account.name))
|
||||
|
||||
@@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
from frappe.utils import nowdate, cstr, flt, now, getdate, add_months
|
||||
from frappe import msgprint, throw, _
|
||||
from frappe import throw, _
|
||||
from frappe.utils import formatdate
|
||||
from erpnext.utilities import build_filter_conditions
|
||||
|
||||
@@ -29,9 +29,7 @@ def get_fiscal_years(date=None, fiscal_year=None, label="Date", verbose=1):
|
||||
from `tabFiscal Year` where %s order by year_start_date desc""" % cond)
|
||||
|
||||
if not fy:
|
||||
error_msg = """%s %s not in any Fiscal Year""" % (label, formatdate(date))
|
||||
error_msg = """{msg}: {date}""".format(msg=_("Fiscal Year does not exist for date"),
|
||||
date=formatdate(date))
|
||||
error_msg = _("""{0} {1} not in any Fiscal Year""").format(label, formatdate(date))
|
||||
if verbose: frappe.msgprint(error_msg)
|
||||
raise FiscalYearError, error_msg
|
||||
|
||||
@@ -40,12 +38,7 @@ def get_fiscal_years(date=None, fiscal_year=None, label="Date", verbose=1):
|
||||
def validate_fiscal_year(date, fiscal_year, label="Date"):
|
||||
years = [f[0] for f in get_fiscal_years(date, label=label)]
|
||||
if fiscal_year not in years:
|
||||
throw(("%(label)s '%(posting_date)s': " + _("not within Fiscal Year") + \
|
||||
": '%(fiscal_year)s'") % {
|
||||
"label": label,
|
||||
"posting_date": formatdate(date),
|
||||
"fiscal_year": fiscal_year
|
||||
})
|
||||
throw(_("{0} '{1}' not in Fiscal Year {2}").format(label, formatdate(date), fiscal_year))
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_balance_on(account=None, date=None):
|
||||
@@ -62,7 +55,7 @@ def get_balance_on(account=None, date=None):
|
||||
|
||||
try:
|
||||
year_start_date = get_fiscal_year(date, verbose=0)[1]
|
||||
except FiscalYearError, e:
|
||||
except FiscalYearError:
|
||||
if getdate(date) > getdate(nowdate()):
|
||||
# if fiscal year not found and the date is greater than today
|
||||
# get fiscal year for today's date and its corresponding year start date
|
||||
@@ -232,9 +225,7 @@ def remove_against_link_from_jv(ref_type, ref_no, against_field):
|
||||
and voucher_no != ifnull(against_voucher, '')""",
|
||||
(now(), frappe.session.user, ref_type, ref_no))
|
||||
|
||||
frappe.msgprint("{msg} {linked_jv}".format(msg = _("""Following linked Journal Vouchers \
|
||||
made against this transaction has been unlinked. You can link them again with other \
|
||||
transactions via Payment Reconciliation Tool."""), linked_jv="\n".join(linked_jv)))
|
||||
frappe.msgprint(_("Following Journal Vouchers Unlinked: {0}".format("\n".join(linked_jv))))
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import cstr, flt
|
||||
from frappe import msgprint
|
||||
from frappe import msgprint, _
|
||||
from erpnext.controllers.buying_controller import BuyingController
|
||||
|
||||
class PurchaseOrder(BuyingController):
|
||||
@@ -128,8 +128,8 @@ class PurchaseOrder(BuyingController):
|
||||
date_diff = frappe.db.sql("select TIMEDIFF('%s', '%s')" % ( mod_db[0][0],cstr(self.modified)))
|
||||
|
||||
if date_diff and date_diff[0][0]:
|
||||
msgprint(cstr(self.doctype) +" => "+ cstr(self.name) +" has been modified. Please Refresh. ")
|
||||
raise Exception
|
||||
msgprint(_("{0} {1} has been modified. Please refresh").format(self.doctype, self.name),
|
||||
raise_exception=True)
|
||||
|
||||
def update_status(self, status):
|
||||
self.check_modified_date()
|
||||
@@ -140,7 +140,7 @@ class PurchaseOrder(BuyingController):
|
||||
self.update_bin(is_submit = (status == 'Submitted') and 1 or 0, is_stopped = 1)
|
||||
|
||||
# step 3:=> Acknowledge user
|
||||
msgprint(self.doctype + ": " + self.name + " has been %s." % ((status == 'Submitted') and 'Unstopped' or cstr(status)))
|
||||
msgprint(_("Status of {0} {1} is now {2}").format(self.doctype, self.name, status))
|
||||
|
||||
def on_submit(self):
|
||||
purchase_controller = frappe.get_doc("Purchase Common")
|
||||
@@ -163,12 +163,12 @@ class PurchaseOrder(BuyingController):
|
||||
pc_obj.check_docstatus(check = 'Next', doctype = 'Purchase Receipt', docname = self.name, detail_doctype = 'Purchase Receipt Item')
|
||||
|
||||
# Check if Purchase Invoice has been submitted against current Purchase Order
|
||||
submitted = frappe.db.sql("""select t1.name
|
||||
submitted = frappe.db.sql_list("""select t1.name
|
||||
from `tabPurchase Invoice` t1,`tabPurchase Invoice Item` t2
|
||||
where t1.name = t2.parent and t2.purchase_order = %s and t1.docstatus = 1""",
|
||||
self.name)
|
||||
if submitted:
|
||||
msgprint("Purchase Invoice : " + cstr(submitted[0][0]) + " has already been submitted !")
|
||||
msgprint(_("Purchase Invoice {0} is already submitted").format(", ".join(submitted)))
|
||||
raise Exception
|
||||
|
||||
frappe.db.set(self,'status','Cancelled')
|
||||
|
||||
@@ -55,7 +55,7 @@ class Supplier(TransactionBase):
|
||||
#validation for Naming Series mandatory field...
|
||||
if frappe.defaults.get_global_default('supp_master_name') == 'Naming Series':
|
||||
if not self.naming_series:
|
||||
msgprint("Series is Mandatory.", raise_exception=1)
|
||||
msgprint(_("Series is mandatory"), raise_exception=1)
|
||||
|
||||
def get_contacts(self,nm):
|
||||
if nm:
|
||||
@@ -106,7 +106,7 @@ class Supplier(TransactionBase):
|
||||
@frappe.whitelist()
|
||||
def get_dashboard_info(supplier):
|
||||
if not frappe.has_permission("Supplier", "read", supplier):
|
||||
frappe.msgprint("No Permission", raise_exception=True)
|
||||
frappe.throw(_("No permission"))
|
||||
|
||||
out = {}
|
||||
for doctype in ["Supplier Quotation", "Purchase Order", "Purchase Receipt", "Purchase Invoice"]:
|
||||
|
||||
@@ -417,8 +417,7 @@ class AccountsController(TransactionBase):
|
||||
ref_amt = flt(frappe.db.get_value(ref_dt + " Item",
|
||||
item.get(item_ref_dn), based_on), self.precision(based_on, item))
|
||||
if not ref_amt:
|
||||
frappe.msgprint(_("As amount for item") + ": " + item.item_code + _(" in ") +
|
||||
ref_dt + _(" is zero, system will not check for over-billed"))
|
||||
frappe.msgprint(_("Warning: System will not check overbilling since amount for Item {0} in {1} is zero").format(item.item_code, ref_dt))
|
||||
else:
|
||||
already_billed = frappe.db.sql("""select sum(%s) from `tab%s`
|
||||
where %s=%s and docstatus=1 and parent != %s""" %
|
||||
|
||||
@@ -61,7 +61,7 @@ class BuyingController(StockController):
|
||||
self.get("other_charges")
|
||||
if d.category in ["Valuation", "Valuation and Total"]]
|
||||
if tax_for_valuation:
|
||||
frappe.msgprint(_("""Tax Category can not be 'Valuation' or 'Valuation and Total' as all items are non-stock items"""), raise_exception=1)
|
||||
frappe.throw(_("Tax Category can not be 'Valuation' or 'Valuation and Total' as all items are non-stock items"))
|
||||
|
||||
def set_total_in_words(self):
|
||||
from frappe.utils import money_in_words
|
||||
@@ -197,13 +197,11 @@ class BuyingController(StockController):
|
||||
|
||||
def validate_for_subcontracting(self):
|
||||
if not self.is_subcontracted and self.sub_contracted_items:
|
||||
frappe.msgprint(_("""Please enter whether %s is made for subcontracting or purchasing,
|
||||
in 'Is Subcontracted' field""" % self.doctype), raise_exception=1)
|
||||
frappe.throw(_("Please enter 'Is Subcontracted' as Yes or No"))
|
||||
|
||||
if self.doctype == "Purchase Receipt" and self.is_subcontracted=="Yes" \
|
||||
and not self.supplier_warehouse:
|
||||
frappe.msgprint(_("Supplier Warehouse mandatory subcontracted purchase receipt"),
|
||||
raise_exception=1)
|
||||
frappe.throw(_("Supplier Warehouse mandatory for sub-contracted Purchase Receipt"))
|
||||
|
||||
def update_raw_materials_supplied(self, raw_material_table):
|
||||
self.set(raw_material_table, [])
|
||||
@@ -249,7 +247,7 @@ class BuyingController(StockController):
|
||||
where t2.parent = t1.name and t1.item = %s and t1.is_default = 1
|
||||
and t1.docstatus = 1 and t1.is_active = 1""", item_code, as_dict=1)
|
||||
if not bom_items:
|
||||
msgprint(_("No default BOM exists for item: ") + item_code, raise_exception=1)
|
||||
msgprint(_("No default BOM exists for Item {0}").format(item_code), raise_exception=1)
|
||||
|
||||
return bom_items
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import cint, flt, comma_or, _round, cstr
|
||||
from frappe.utils import cint, flt, _round, cstr
|
||||
from erpnext.setup.utils import get_company_currency
|
||||
from frappe import msgprint, _
|
||||
from frappe import _, throw
|
||||
|
||||
from erpnext.controllers.stock_controller import StockController
|
||||
|
||||
@@ -233,8 +233,7 @@ class SellingController(StockController):
|
||||
if self.meta.get_field("commission_rate"):
|
||||
self.round_floats_in(self, ["net_total", "commission_rate"])
|
||||
if self.commission_rate > 100.0:
|
||||
msgprint(_(self.meta.get_label("commission_rate")) + " " +
|
||||
_("cannot be greater than 100"), raise_exception=True)
|
||||
throw(_("Commission rate cannot be greater than 100"))
|
||||
|
||||
self.total_commission = flt(self.net_total * self.commission_rate / 100.0,
|
||||
self.precision("total_commission"))
|
||||
@@ -252,17 +251,14 @@ class SellingController(StockController):
|
||||
total += sales_person.allocated_percentage
|
||||
|
||||
if sales_team and total != 100.0:
|
||||
msgprint(_("Total") + " " +
|
||||
_(self.meta.get_label("allocated_percentage", parentfield="sales_team")) +
|
||||
" " + _("should be 100%"), raise_exception=True)
|
||||
throw(_("Total allocated percentage for sales team should be 100"))
|
||||
|
||||
def validate_order_type(self):
|
||||
valid_types = ["Sales", "Maintenance", "Shopping Cart"]
|
||||
if not self.order_type:
|
||||
self.order_type = "Sales"
|
||||
elif self.order_type not in valid_types:
|
||||
msgprint(_(self.meta.get_label("order_type")) + " " +
|
||||
_("must be one of") + ": " + comma_or(valid_types), raise_exception=True)
|
||||
throw(_("Order Type must be one of {1}").comma_or(valid_types))
|
||||
|
||||
def check_credit(self, grand_total):
|
||||
customer_account = frappe.db.get_value("Account", {"company": self.company,
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import flt, cstr
|
||||
from frappe import msgprint
|
||||
from frappe.utils import flt
|
||||
from frappe import msgprint, _, throw
|
||||
|
||||
from frappe.model.controller import DocListController
|
||||
|
||||
@@ -129,19 +129,13 @@ class StatusUpdater(DocListController):
|
||||
item['target_ref_field'] = args['target_ref_field'].replace('_', ' ')
|
||||
|
||||
if not item[args['target_ref_field']]:
|
||||
msgprint("""As %(target_ref_field)s for item: %(item_code)s in \
|
||||
%(parenttype)s: %(parent)s is zero, system will not check \
|
||||
over-delivery or over-billed""" % item)
|
||||
msgprint(_("Note: System will not check over-delivery and over-booking for Item {0} as quantity or amount is 0").format(item.item_code))
|
||||
elif args.get('no_tolerance'):
|
||||
item['reduce_by'] = item[args['target_field']] - \
|
||||
item[args['target_ref_field']]
|
||||
if item['reduce_by'] > .01:
|
||||
msgprint("""
|
||||
Row #%(idx)s: Max %(target_ref_field)s allowed for <b>Item \
|
||||
%(item_code)s</b> against <b>%(parenttype)s %(parent)s</b> \
|
||||
is <b>""" % item + cstr(item[args['target_ref_field']]) +
|
||||
"""</b>.<br>You must reduce the %(target_ref_field)s by \
|
||||
%(reduce_by)s""" % item, raise_exception=1)
|
||||
msgprint(_("Allowance for over-delivery / over-billing crossed for Item {0}").format(item.item_code))
|
||||
throw(_("{0} must be less than or equal to {1}").format(_(item.target_ref_field), item[args["target_ref_field"]]))
|
||||
|
||||
else:
|
||||
self.check_overflow_with_tolerance(item, args)
|
||||
@@ -161,18 +155,8 @@ class StatusUpdater(DocListController):
|
||||
item['max_allowed'] = flt(item[args['target_ref_field']] * (100+tolerance)/100)
|
||||
item['reduce_by'] = item[args['target_field']] - item['max_allowed']
|
||||
|
||||
msgprint("""
|
||||
Row #%(idx)s: Max %(target_ref_field)s allowed for <b>Item %(item_code)s</b> \
|
||||
against <b>%(parenttype)s %(parent)s</b> is <b>%(max_allowed)s</b>.
|
||||
|
||||
If you want to increase your overflow tolerance, please increase tolerance %% in \
|
||||
Global Defaults or Item master.
|
||||
|
||||
Or, you must reduce the %(target_ref_field)s by %(reduce_by)s
|
||||
|
||||
Also, please check if the order item has already been billed in the Sales Order""" %
|
||||
item, raise_exception=1)
|
||||
|
||||
msgprint(_("Allowance for over-delivery / over-billing crossed for Item {0}").format(item["item_code"]))
|
||||
throw(_("{0} must be less than or equal to {1}").format(_(item["target_ref_field"]), item[args["max_allowed"]]))
|
||||
|
||||
def update_qty(self, change_modified=True):
|
||||
"""
|
||||
|
||||
@@ -65,7 +65,7 @@ class StockController(AccountsController):
|
||||
warehouse_with_no_account.append(sle.warehouse)
|
||||
|
||||
if warehouse_with_no_account:
|
||||
msgprint(_("No accounting entries for following warehouses") + ": \n" +
|
||||
msgprint(_("No accounting entries for the following warehouses") + ": \n" +
|
||||
"\n".join(warehouse_with_no_account))
|
||||
|
||||
return process_gl_map(gl_list)
|
||||
@@ -231,12 +231,10 @@ class StockController(AccountsController):
|
||||
|
||||
def check_expense_account(self, item):
|
||||
if item.meta.get_field("expense_account") and not item.expense_account:
|
||||
msgprint(_("""Expense/Difference account is mandatory for item: """) + item.item_code,
|
||||
raise_exception=1)
|
||||
frappe.throw(_("Expense or Difference account is mandatory for Item {0}").format(item.item_code))
|
||||
|
||||
if item.meta.get_field("expense_account") and not item.cost_center:
|
||||
msgprint(_("""Cost Center is mandatory for item: """) + item.item_code,
|
||||
raise_exception=1)
|
||||
frappe.throw(_("""Cost Center is mandatory for item {0}""").format(item.item_code))
|
||||
|
||||
def get_sl_entries(self, d, args):
|
||||
sl_dict = {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import add_days, add_months, cstr, getdate
|
||||
from frappe.utils import getdate
|
||||
from frappe import _
|
||||
|
||||
def get_columns(filters, trans):
|
||||
@@ -30,10 +30,10 @@ def get_columns(filters, trans):
|
||||
def validate_filters(filters):
|
||||
for f in ["Fiscal Year", "Based On", "Period", "Company"]:
|
||||
if not filters.get(f.lower().replace(" ", "_")):
|
||||
frappe.msgprint(f + _(" is mandatory"), raise_exception=1)
|
||||
frappe.throw(_("{0} is mandatory").format(f))
|
||||
|
||||
if filters.get("based_on") == filters.get("group_by"):
|
||||
frappe.msgprint("'Based On' and 'Group By' can not be same", raise_exception=1)
|
||||
frappe.throw(_("'Based On' and 'Group By' can not be same"))
|
||||
|
||||
def get_data(filters, conditions):
|
||||
data = []
|
||||
@@ -249,7 +249,7 @@ def based_wise_colums_query(based_on, trans):
|
||||
based_on_details["based_on_group_by"] = 't2.project_name'
|
||||
based_on_details["addl_tables"] = ''
|
||||
else:
|
||||
frappe.msgprint("Project-wise data is not available for Quotation", raise_exception=1)
|
||||
frappe.throw(_("Project-wise data is not available for Quotation"))
|
||||
|
||||
return based_on_details
|
||||
|
||||
|
||||
@@ -47,12 +47,11 @@ class Appraisal(Document):
|
||||
total_w += flt(d.per_weightage)
|
||||
|
||||
if int(total_w) != 100:
|
||||
msgprint("Total weightage assigned should be 100%. It is :" + str(total_w) + "%",
|
||||
raise_exception=1)
|
||||
frappe.throw(_("Total weightage assigned should be 100%. It is {0}").format(str(total_w) + "%"))
|
||||
|
||||
if frappe.db.get_value("Employee", self.employee, "user_id") != \
|
||||
frappe.session.user and total == 0:
|
||||
msgprint("Total can't be zero. You must atleast give some points!", raise_exception=1)
|
||||
frappe.throw(_("Total cannot be zero"))
|
||||
|
||||
self.total_score = total
|
||||
|
||||
|
||||
@@ -14,6 +14,4 @@ class AppraisalTemplate(Document):
|
||||
self.total_points += int(d.per_weightage or 0)
|
||||
|
||||
if int(self.total_points) != 100:
|
||||
frappe.msgprint(_("Total (sum of) points distribution for all goals should be 100.") \
|
||||
+ " " + _("Not") + " " + str(self.total_points),
|
||||
raise_exception=True)
|
||||
frappe.throw(_("Total points for all goals should be 100. It is {0}").format(self.total_points))
|
||||
|
||||
@@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe.utils import getdate, nowdate
|
||||
from frappe import msgprint, _
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
|
||||
class Attendance(Document):
|
||||
@@ -14,8 +14,7 @@ class Attendance(Document):
|
||||
and name != %s and docstatus = 1""",
|
||||
(self.employee, self.att_date, self.name))
|
||||
if res:
|
||||
msgprint(_("Attendance for the employee: ") + self.employee +
|
||||
_(" already marked"), raise_exception=1)
|
||||
frappe.throw(_("Attendance for employee {0} is already marked").format(self.employee))
|
||||
|
||||
def check_leave_record(self):
|
||||
if self.status == 'Present':
|
||||
@@ -24,9 +23,8 @@ class Attendance(Document):
|
||||
and docstatus = 1""", (self.employee, self.att_date))
|
||||
|
||||
if leave:
|
||||
frappe.msgprint(_("Employee: ") + self.employee + _(" was on leave on ")
|
||||
+ self.att_date + _(". You can not mark his attendance as 'Present'"),
|
||||
raise_exception=1)
|
||||
frappe.throw(_("Employee {0} was on leave on {1}. Cannot mark attendance.").format(self.employee,
|
||||
self.att_date))
|
||||
|
||||
def validate_fiscal_year(self):
|
||||
from erpnext.accounts.utils import validate_fiscal_year
|
||||
@@ -34,14 +32,13 @@ class Attendance(Document):
|
||||
|
||||
def validate_att_date(self):
|
||||
if getdate(self.att_date) > getdate(nowdate()):
|
||||
msgprint(_("Attendance can not be marked for future dates"), raise_exception=1)
|
||||
frappe.throw(_("Attendance can not be marked for future dates"))
|
||||
|
||||
def validate_employee(self):
|
||||
emp = frappe.db.sql("select name from `tabEmployee` where name = %s and status = 'Active'",
|
||||
self.employee)
|
||||
if not emp:
|
||||
msgprint(_("Employee: ") + self.employee +
|
||||
_(" not active or does not exists in the system"), raise_exception=1)
|
||||
frappe.throw(_("Employee {0} is not active or does not exist").format(self.employee))
|
||||
|
||||
def validate(self):
|
||||
from erpnext.utilities import validate_status
|
||||
|
||||
@@ -3,19 +3,17 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import msgprint
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
|
||||
class ExpenseClaim(Document):
|
||||
|
||||
def validate(self):
|
||||
self.validate_fiscal_year()
|
||||
self.validate_exp_details()
|
||||
|
||||
def on_submit(self):
|
||||
if self.approval_status=="Draft":
|
||||
frappe.msgprint("""Please set Approval Status to 'Approved' or \
|
||||
'Rejected' before submitting""", raise_exception=1)
|
||||
frappe.throw(_("""Approval Status must be 'Approved' or 'Rejected'"""))
|
||||
|
||||
def validate_fiscal_year(self):
|
||||
from erpnext.accounts.utils import validate_fiscal_year
|
||||
@@ -23,5 +21,4 @@ class ExpenseClaim(Document):
|
||||
|
||||
def validate_exp_details(self):
|
||||
if not self.get('expense_voucher_details'):
|
||||
msgprint("Please add expense voucher details")
|
||||
raise Exception
|
||||
frappe.throw(_("Please add expense voucher details"))
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe.utils import add_days, add_years, cint, getdate
|
||||
from frappe.utils import cint
|
||||
from frappe.model.naming import make_autoname
|
||||
from frappe import msgprint, throw, _
|
||||
import datetime
|
||||
from frappe import throw, _
|
||||
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import cint, flt
|
||||
from frappe import msgprint
|
||||
from frappe import _
|
||||
|
||||
from frappe.model.document import Document
|
||||
|
||||
@@ -12,11 +12,9 @@ class LeaveAllocation(Document):
|
||||
def validate(self):
|
||||
self.validate_new_leaves_allocated_value()
|
||||
self.check_existing_leave_allocation()
|
||||
self.validate_new_leaves_allocated()
|
||||
|
||||
def on_update_after_submit(self):
|
||||
self.validate_new_leaves_allocated_value()
|
||||
self.validate_new_leaves_allocated()
|
||||
|
||||
def on_update(self):
|
||||
self.get_total_allocated_leaves()
|
||||
@@ -27,11 +25,7 @@ class LeaveAllocation(Document):
|
||||
def validate_new_leaves_allocated_value(self):
|
||||
"""validate that leave allocation is in multiples of 0.5"""
|
||||
if flt(self.new_leaves_allocated) % 0.5:
|
||||
guess = round(flt(self.new_leaves_allocated) * 2.0) / 2.0
|
||||
|
||||
msgprint("""New Leaves Allocated should be a multiple of 0.5.
|
||||
Perhaps you should enter %s or %s""" % (guess, guess + 0.5),
|
||||
raise_exception=1)
|
||||
frappe.throw(_("Leaves must be allocated in multiples of 0.5"))
|
||||
|
||||
def check_existing_leave_allocation(self):
|
||||
"""check whether leave for same type is already allocated or not"""
|
||||
@@ -39,24 +33,9 @@ class LeaveAllocation(Document):
|
||||
where employee=%s and leave_type=%s and fiscal_year=%s and docstatus=1""",
|
||||
(self.employee, self.leave_type, self.fiscal_year))
|
||||
if leave_allocation:
|
||||
msgprint("""%s is already allocated to Employee: %s for Fiscal Year: %s.
|
||||
Please refere Leave Allocation: \
|
||||
<a href="#Form/Leave Allocation/%s">%s</a>""" % \
|
||||
(self.leave_type, self.employee, self.fiscal_year,
|
||||
leave_allocation[0][0], leave_allocation[0][0]), raise_exception=1)
|
||||
|
||||
def validate_new_leaves_allocated(self):
|
||||
"""check if Total Leaves Allocated >= Leave Applications"""
|
||||
self.total_leaves_allocated = flt(self.carry_forwarded_leaves) + \
|
||||
flt(self.new_leaves_allocated)
|
||||
leaves_applied = self.get_leaves_applied(self.fiscal_year)
|
||||
if leaves_applied > self.total_leaves_allocated:
|
||||
expected_new_leaves = flt(self.new_leaves_allocated) + \
|
||||
(leaves_applied - self.total_leaves_allocated)
|
||||
msgprint("""Employee: %s has already applied for %s leaves.
|
||||
Hence, New Leaves Allocated should be atleast %s""" % \
|
||||
(self.employee, leaves_applied, expected_new_leaves),
|
||||
raise_exception=1)
|
||||
frappe.msgprint(_("Leaves for type {0} already allocated for Employee {1} for Fiscal Year {0}").format(self.leave_type,
|
||||
self.employee, self.fiscal_year))
|
||||
frappe.throw('<a href="#Form/Leave Allocation/{0}">{0}</a>'.format(leave_allocation[0][0]))
|
||||
|
||||
def get_leave_bal(self, prev_fyear):
|
||||
return self.get_leaves_allocated(prev_fyear) - self.get_leaves_applied(prev_fyear)
|
||||
@@ -82,8 +61,7 @@ class LeaveAllocation(Document):
|
||||
cf = cf and cint(cf[0][0]) or 0
|
||||
if not cf:
|
||||
frappe.db.set(self,'carry_forward',0)
|
||||
msgprint("Sorry! You cannot carry forward %s" % (self.leave_type),
|
||||
raise_exception=1)
|
||||
frappe.throw("Cannot carry forward {0}".format(self.leave_type))
|
||||
|
||||
def get_carry_forwarded_leaves(self):
|
||||
if self.carry_forward:
|
||||
@@ -112,10 +90,7 @@ class LeaveAllocation(Document):
|
||||
where employee=%s and leave_type=%s and fiscal_year=%s and docstatus=1""",
|
||||
(self.employee, self.leave_type, self.fiscal_year))
|
||||
if exists:
|
||||
msgprint("""Cannot cancel this Leave Allocation as \
|
||||
Employee : %s has already applied for %s.
|
||||
Please check Leave Application: \
|
||||
<a href="#Form/Leave Application/%s">%s</a>""" % \
|
||||
(self.employee, self.leave_type, exists[0][0], exists[0][0]))
|
||||
raise Exception
|
||||
frappe.msgprint(_("Cannot cancel because Employee {0} is already approved for {1}").format(self.employee,
|
||||
self.leave_type))
|
||||
frappe.throw('<a href="#Form/Leave Application/{0}">{0}</a>'.format(exists[0][0]))
|
||||
|
||||
|
||||
@@ -43,8 +43,7 @@ class LeaveApplication(DocListController):
|
||||
|
||||
def on_submit(self):
|
||||
if self.status != "Approved":
|
||||
frappe.msgprint("""Only Leave Applications with status 'Approved' can be Submitted.""",
|
||||
raise_exception=True)
|
||||
frappe.throw(_("Only Leave Applications with status 'Approved' can be submitted"))
|
||||
|
||||
# notify leave applier about approval
|
||||
self.notify_employee(self.status)
|
||||
@@ -72,7 +71,7 @@ class LeaveApplication(DocListController):
|
||||
|
||||
if block_dates:
|
||||
if self.status == "Approved":
|
||||
frappe.msgprint(_("Cannot approve leave as you are not authorized to approve leaves on Block Dates."))
|
||||
frappe.msgprint(_("Cannot approve leave as you are not authorized to approve leaves on Block Dates"))
|
||||
raise LeaveDayBlockedError
|
||||
|
||||
def get_holidays(self):
|
||||
@@ -100,16 +99,14 @@ class LeaveApplication(DocListController):
|
||||
def validate_to_date(self):
|
||||
if self.from_date and self.to_date and \
|
||||
(getdate(self.to_date) < getdate(self.from_date)):
|
||||
msgprint("To date cannot be before from date")
|
||||
raise Exception
|
||||
frappe.throw(_("To date cannot be before from date"))
|
||||
|
||||
def validate_balance_leaves(self):
|
||||
if self.from_date and self.to_date:
|
||||
self.total_leave_days = self.get_total_leave_days()["total_leave_days"]
|
||||
|
||||
if self.total_leave_days == 0:
|
||||
msgprint(_("The day(s) on which you are applying for leave coincide with holiday(s). You need not apply for leave."),
|
||||
raise_exception=1)
|
||||
frappe.throw(_("The day(s) on which you are applying for leave are holiday. You need not apply for leave."))
|
||||
|
||||
if not is_lwp(self.leave_type):
|
||||
self.leave_balance = get_leave_balance(self.employee,
|
||||
@@ -118,9 +115,11 @@ class LeaveApplication(DocListController):
|
||||
if self.status != "Rejected" \
|
||||
and self.leave_balance - self.total_leave_days < 0:
|
||||
#check if this leave type allow the remaining balance to be in negative. If yes then warn the user and continue to save else warn the user and don't save.
|
||||
msgprint("There is not enough leave balance for Leave Type: %s" % \
|
||||
(self.leave_type,),
|
||||
raise_exception=not(frappe.db.get_value("Leave Type", self.leave_type,"allow_negative") or None))
|
||||
if frappe.db.get_value("Leave Type", self.leave_type, "allow_negative"):
|
||||
frappe.msgprint(_("Note: There is not enough leave balance for Leave Type {0}").format(self.leave_type))
|
||||
else:
|
||||
frappe.throw(_("There is not enough leave balance for Leave Type {0}").format(self.leave_type))
|
||||
|
||||
|
||||
def validate_leave_overlap(self):
|
||||
if not self.name:
|
||||
@@ -138,7 +137,9 @@ class LeaveApplication(DocListController):
|
||||
or %(from_date)s between from_date and to_date)
|
||||
and name != %(name)s""", self.as_dict(), as_dict = 1):
|
||||
|
||||
msgprint("Employee : %s has already applied for %s between %s and %s on %s. Please refer Leave Application : <a href=\"#Form/Leave Application/%s\">%s</a>" % (self.employee, cstr(d['leave_type']), formatdate(d['from_date']), formatdate(d['to_date']), formatdate(d['posting_date']), d['name'], d['name']), raise_exception = OverlapError)
|
||||
frappe.msgprint(_("Employee {0} has already applied for {1} between {2} and {3}").format(self.employee,
|
||||
cstr(d['leave_type']), formatdate(d['from_date']), formatdate(d['to_date'])))
|
||||
frappe.throw('<a href="#Form/Leave Application/{0}">{0}</a>'.format(d["name"]), OverlapError)
|
||||
|
||||
def validate_max_days(self):
|
||||
max_days = frappe.db.get_value("Leave Type", self.leave_type, "max_days_allowed")
|
||||
@@ -152,14 +153,12 @@ class LeaveApplication(DocListController):
|
||||
employee.get("employee_leave_approvers")]
|
||||
|
||||
if len(leave_approvers) and self.leave_approver not in leave_approvers:
|
||||
msgprint(("[" + _("For Employee") + ' "' + self.employee + '"] '
|
||||
+ _("Leave Approver can be one of") + ": "
|
||||
+ comma_or(leave_approvers)), raise_exception=InvalidLeaveApproverError)
|
||||
frappe.throw(_("Leave approver must be one of {0}").format(comma_or(leave_approvers)), InvalidLeaveApproverError)
|
||||
|
||||
elif self.leave_approver and not frappe.db.sql("""select name from `tabUserRole`
|
||||
where parent=%s and role='Leave Approver'""", self.leave_approver):
|
||||
msgprint(get_fullname(self.leave_approver) + ": " \
|
||||
+ _("does not have role 'Leave Approver'"), raise_exception=InvalidLeaveApproverError)
|
||||
frappe.throw(_("{0} must have role 'Leave Approver'").format(get_fullname(self.leave_approver)),
|
||||
InvalidLeaveApproverError)
|
||||
|
||||
elif self.docstatus==1 and len(leave_approvers) and self.leave_approver != frappe.session.user:
|
||||
msgprint(_("Only the selected Leave Approver can submit this Leave Application"),
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe.utils import cint, cstr, flt, nowdate
|
||||
from frappe.utils import cint, cstr, flt, nowdate, comma_and
|
||||
from frappe import msgprint, _
|
||||
|
||||
|
||||
@@ -59,4 +59,4 @@ class LeaveControlPanel(Document):
|
||||
except:
|
||||
pass
|
||||
if leave_allocated_for:
|
||||
msgprint("Leaves Allocated Successfully for " + ", ".join(leave_allocated_for))
|
||||
msgprint(_("Leaves Allocated Successfully for {0}").format(comma_and(leave_allocated_for)))
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import cint, flt
|
||||
from frappe import msgprint
|
||||
from frappe import _
|
||||
|
||||
from frappe.model.document import Document
|
||||
|
||||
@@ -52,8 +52,7 @@ class SalaryManager(Document):
|
||||
def check_mandatory(self):
|
||||
for f in ['company', 'month', 'fiscal_year']:
|
||||
if not self.get(f):
|
||||
msgprint("Please select %s to proceed" % f, raise_exception=1)
|
||||
|
||||
frappe.throw(_("Please set {0}").format(f))
|
||||
|
||||
def get_month_details(self, year, month):
|
||||
ysd = frappe.db.get_value("Fiscal Year", year, "year_start_date")
|
||||
@@ -136,7 +135,7 @@ class SalaryManager(Document):
|
||||
frappe.db.set(ss_obj, 'docstatus', 1)
|
||||
except Exception,e:
|
||||
not_submitted_ss.append(ss[0])
|
||||
msgprint(e)
|
||||
frappe.msgprint(e)
|
||||
continue
|
||||
|
||||
return self.create_submit_log(ss_list, not_submitted_ss)
|
||||
@@ -191,7 +190,7 @@ class SalaryManager(Document):
|
||||
default_bank_account = frappe.db.get_value("Company", self.company,
|
||||
"default_bank_account")
|
||||
if not default_bank_account:
|
||||
msgprint("You can set Default Bank Account in Company master.")
|
||||
frappe.msgprint(_("You can set Default Bank Account in Company master"))
|
||||
|
||||
return {
|
||||
'default_bank_account' : default_bank_account,
|
||||
|
||||
@@ -28,7 +28,7 @@ class SalarySlip(TransactionBase):
|
||||
struct = frappe.db.sql("""select name from `tabSalary Structure`
|
||||
where employee=%s and is_active = 'Yes'""", self.employee)
|
||||
if not struct:
|
||||
msgprint("Please create Salary Structure for employee '%s'" % self.employee)
|
||||
msgprint(_("Please create Salary Structure for employee {0}").format(self.employee))
|
||||
self.employee = None
|
||||
return struct and struct[0][0] or ''
|
||||
|
||||
@@ -58,8 +58,7 @@ class SalarySlip(TransactionBase):
|
||||
"include_holidays_in_total_working_days")):
|
||||
m["month_days"] -= len(holidays)
|
||||
if m["month_days"] < 0:
|
||||
msgprint(_("Bummer! There are more holidays than working days this month."),
|
||||
raise_exception=True)
|
||||
frappe.throw(_("There are more holidays than working days this month."))
|
||||
|
||||
if not lwp:
|
||||
lwp = self.calculate_lwp(holidays, m)
|
||||
@@ -79,9 +78,7 @@ class SalarySlip(TransactionBase):
|
||||
getdate(emp['relieving_date']) < m['month_end_date']:
|
||||
payment_days = getdate(emp['relieving_date']).day
|
||||
elif getdate(emp['relieving_date']) < m['month_start_date']:
|
||||
frappe.msgprint(_("Relieving Date of employee is ") + cstr(emp['relieving_date']
|
||||
+ _(". Please set status of the employee as 'Left'")), raise_exception=1)
|
||||
|
||||
frappe.throw(_("Employee relieved on {0} must be set as 'Left'").format(emp["relieving_date"]))
|
||||
|
||||
if emp['date_of_joining']:
|
||||
if getdate(emp['date_of_joining']) > m['month_start_date'] and \
|
||||
@@ -133,9 +130,7 @@ class SalarySlip(TransactionBase):
|
||||
(self.month, self.fiscal_year, self.employee, self.name))
|
||||
if ret_exist:
|
||||
self.employee = ''
|
||||
msgprint("Salary Slip of employee '%s' already created for this month"
|
||||
% self.employee, raise_exception=1)
|
||||
|
||||
frappe.throw("Salary Slip of employee {0} already created for this month".format(self.employee))
|
||||
|
||||
def validate(self):
|
||||
from frappe.utils import money_in_words
|
||||
@@ -297,4 +292,4 @@ class SalarySlip(TransactionBase):
|
||||
|
||||
sendmail([receiver], subject=subj, msg = msg)
|
||||
else:
|
||||
msgprint("Company Email ID not found, hence mail not sent")
|
||||
msgprint(_("Company Email ID not found, hence mail not sent"))
|
||||
|
||||
@@ -6,7 +6,7 @@ import frappe
|
||||
|
||||
from frappe.utils import cstr, flt
|
||||
from frappe.model.naming import make_autoname
|
||||
from frappe import msgprint, _
|
||||
from frappe import _
|
||||
|
||||
|
||||
from frappe.model.document import Document
|
||||
@@ -58,12 +58,11 @@ class SalaryStructure(Document):
|
||||
ret = frappe.db.sql("""select name from `tabSalary Structure` where is_active = 'Yes'
|
||||
and employee = %s and name!=%s""", (self.employee,self.name))
|
||||
if ret and self.is_active=='Yes':
|
||||
msgprint(_("""Another Salary Structure '%s' is active for employee '%s'. Please make its status 'Inactive' to proceed.""") %
|
||||
(cstr(ret), self.employee), raise_exception=1)
|
||||
frappe.throw(_("Another Salary Structure {0} is active for employee {0}. Please make its status 'Inactive' to proceed.").format(cstr(ret), self.employee))
|
||||
|
||||
def validate_amount(self):
|
||||
if flt(self.net_pay) < 0:
|
||||
msgprint(_("Net pay can not be negative"), raise_exception=1)
|
||||
frappe.throw(_("Net pay cannot be negative"))
|
||||
|
||||
def validate(self):
|
||||
self.check_existing()
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import cstr, add_days, date_diff
|
||||
from frappe import msgprint, _
|
||||
from frappe import _
|
||||
from frappe.utils.datautils import UnicodeWriter
|
||||
from frappe.model.document import Document
|
||||
|
||||
@@ -87,8 +87,7 @@ def get_existing_attendance_records(args):
|
||||
def get_naming_series():
|
||||
series = frappe.get_meta("Attendance").get_field("naming_series").options.strip().split("\n")
|
||||
if not series:
|
||||
msgprint("""Please create naming series for Attendance \
|
||||
through Setup -> Numbering Series.""", raise_exception=1)
|
||||
frappe.throw(_("Please setup numbering series for Attendance via Setup > Numbering Series"))
|
||||
return series[0]
|
||||
|
||||
|
||||
@@ -111,7 +110,6 @@ def upload():
|
||||
error = False
|
||||
|
||||
from frappe.utils.datautils import check_record, import_doc
|
||||
doctype_dl = frappe.get_meta("Attendance")
|
||||
|
||||
for i, row in enumerate(rows[5:]):
|
||||
if not row: continue
|
||||
|
||||
@@ -10,7 +10,7 @@ def get_leave_approver_list():
|
||||
roles = [r[0] for r in frappe.db.sql("""select distinct parent from `tabUserRole`
|
||||
where role='Leave Approver'""")]
|
||||
if not roles:
|
||||
frappe.msgprint(_("No Leave Approvers. Please assign 'Leave Approver' Role to atleast one user."))
|
||||
frappe.msgprint(_("No Leave Approvers. Please assign 'Leave Approver' Role to atleast one user"))
|
||||
|
||||
return roles
|
||||
|
||||
@@ -20,6 +20,5 @@ def get_expense_approver_list():
|
||||
roles = [r[0] for r in frappe.db.sql("""select distinct parent from `tabUserRole`
|
||||
where role='Expense Approver'""")]
|
||||
if not roles:
|
||||
frappe.msgprint("No Expense Approvers. Please assign 'Expense Approver' \
|
||||
Role to atleast one user.")
|
||||
frappe.msgprint(_("No Expense Approvers. Please assign 'Expense Approver' Role to atleast one user"))
|
||||
return roles
|
||||
|
||||
@@ -5,10 +5,7 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import cint, cstr, flt, now, nowdate
|
||||
|
||||
from frappe import msgprint, _
|
||||
|
||||
|
||||
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
|
||||
class BOM(Document):
|
||||
@@ -64,11 +61,7 @@ class BOM(Document):
|
||||
|
||||
def validate_rm_item(self, item):
|
||||
if item[0]['name'] == self.item:
|
||||
msgprint("Item_code: %s in materials tab cannot be same as FG Item",
|
||||
item[0]['name'], raise_exception=1)
|
||||
|
||||
if not item or item[0]['docstatus'] == 2:
|
||||
msgprint("Item %s does not exist in system" % item[0]['item_code'], raise_exception = 1)
|
||||
frappe.throw(_("Raw material cannot be same as main Item"))
|
||||
|
||||
def set_bom_material_details(self):
|
||||
for item in self.get("bom_materials"):
|
||||
@@ -188,12 +181,10 @@ class BOM(Document):
|
||||
""" Validate main FG item"""
|
||||
item = self.get_item_det(self.item)
|
||||
if not item:
|
||||
msgprint("Item %s does not exists in the system or expired." %
|
||||
self.item, raise_exception = 1)
|
||||
frappe.throw(_("Item {0} does not exists in the system or has expired").format(self.item))
|
||||
elif item[0]['is_manufactured_item'] != 'Yes' \
|
||||
and item[0]['is_sub_contracted_item'] != 'Yes':
|
||||
msgprint("""As Item: %s is not a manufactured / sub-contracted item, \
|
||||
you can not make BOM for it""" % self.item, raise_exception = 1)
|
||||
frappe.throw(_("Item {0} must be manufactured or sub-contracted").format(self.item))
|
||||
else:
|
||||
ret = frappe.db.get_value("Item", self.item, ["description", "stock_uom"])
|
||||
self.description = ret[0]
|
||||
@@ -204,8 +195,7 @@ class BOM(Document):
|
||||
self.op = []
|
||||
for d in self.get('bom_operations'):
|
||||
if cstr(d.operation_no) in self.op:
|
||||
msgprint("Operation no: %s is repeated in Operations Table" %
|
||||
d.operation_no, raise_exception=1)
|
||||
frappe.throw(_("Operation {0} is repeated in Operations Table").format(d.operation_no))
|
||||
else:
|
||||
# add operation in op list
|
||||
self.op.append(cstr(d.operation_no))
|
||||
@@ -216,26 +206,20 @@ class BOM(Document):
|
||||
for m in self.get('bom_materials'):
|
||||
# check if operation no not in op table
|
||||
if self.with_operations and cstr(m.operation_no) not in self.op:
|
||||
msgprint("""Operation no: %s against item: %s at row no: %s \
|
||||
is not present at Operations table""" %
|
||||
(m.operation_no, m.item_code, m.idx), raise_exception = 1)
|
||||
frappe.throw(_("Operation {0} not present in Operations Table").format(m.operation_no))
|
||||
|
||||
item = self.get_item_det(m.item_code)
|
||||
if item[0]['is_manufactured_item'] == 'Yes':
|
||||
if not m.bom_no:
|
||||
msgprint("Please enter BOM No aginst item: %s at row no: %s" %
|
||||
(m.item_code, m.idx), raise_exception=1)
|
||||
frappe.throw(_("BOM number is required for manufactured Item {0} in row {1}").format(m.item, m.idx))
|
||||
else:
|
||||
self.validate_bom_no(m.item_code, m.bom_no, m.idx)
|
||||
|
||||
elif m.bom_no:
|
||||
msgprint("""As Item %s is not a manufactured / sub-contracted item, \
|
||||
you can not enter BOM against it (Row No: %s).""" %
|
||||
(m.item_code, m.idx), raise_exception = 1)
|
||||
frappe.throw(_("BOM number not allowed for non-manufactured Item {0} in row {1}").format(m.item_code, m.idx))
|
||||
|
||||
if flt(m.qty) <= 0:
|
||||
msgprint("Please enter qty against raw material: %s at row no: %s" %
|
||||
(m.item_code, m.idx), raise_exception = 1)
|
||||
frappe.throw(_("Quantity required for Item {0} in row {1}").format(m.item_code, m.idx))
|
||||
|
||||
self.check_if_item_repeated(m.item_code, m.operation_no, check_list)
|
||||
|
||||
@@ -245,14 +229,11 @@ class BOM(Document):
|
||||
and is_active=1 and docstatus=1""",
|
||||
(bom_no, item), as_dict =1)
|
||||
if not bom:
|
||||
msgprint("""Incorrect BOM No: %s against item: %s at row no: %s.
|
||||
It may be inactive or not submitted or does not belong to this item.""" %
|
||||
(bom_no, item, idx), raise_exception = 1)
|
||||
frappe.throw(_("BOM {0} for Item {1} in row {2} is inactive or not submitted").format(bom_no, item, idx))
|
||||
|
||||
def check_if_item_repeated(self, item, op, check_list):
|
||||
if [cstr(item), cstr(op)] in check_list:
|
||||
msgprint(_("Item") + " %s " % (item,) + _("has been entered atleast twice")
|
||||
+ (cstr(op) and _(" against same operation") or ""), raise_exception=1)
|
||||
frappe.throw(_("Item {0} has been entered multiple times against same operation").format(item))
|
||||
else:
|
||||
check_list.append([cstr(item), cstr(op)])
|
||||
|
||||
@@ -268,8 +249,7 @@ class BOM(Document):
|
||||
count = count + 1
|
||||
for b in boms:
|
||||
if b[0] == self.name:
|
||||
msgprint("""Recursion Occured => '%s' cannot be '%s' of '%s'.
|
||||
""" % (cstr(b[0]), cstr(d[2]), self.name), raise_exception = 1)
|
||||
frappe.throw(_("BOM recursion: {0} cannot be parent or child of {2}").format(b[0], self.name))
|
||||
if b[0]:
|
||||
bom_list.append(b[0])
|
||||
|
||||
@@ -389,12 +369,9 @@ class BOM(Document):
|
||||
and docstatus = 1 and is_active = 1)""", self.name)
|
||||
|
||||
if act_pbom and act_pbom[0][0]:
|
||||
action = self.docstatus < 2 and _("deactivate") or _("cancel")
|
||||
msgprint(_("Cannot ") + action + _(": It is linked to other active BOM(s)"),
|
||||
raise_exception=1)
|
||||
frappe.throw(_("Cannot deactive or cancle BOM as it is linked with other BOMs"))
|
||||
|
||||
def get_bom_items_as_dict(bom, qty=1, fetch_exploded=1):
|
||||
import json
|
||||
item_dict = {}
|
||||
|
||||
query = """select
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import cstr, flt
|
||||
from frappe import msgprint, _
|
||||
from frappe import _
|
||||
|
||||
from frappe.model.document import Document
|
||||
|
||||
@@ -22,7 +22,7 @@ class BOMReplaceTool(Document):
|
||||
|
||||
def validate_bom(self):
|
||||
if cstr(self.current_bom) == cstr(self.new_bom):
|
||||
msgprint("Current BOM and New BOM can not be same", raise_exception=1)
|
||||
frappe.throw(_("Current BOM and New BOM can not be same"))
|
||||
|
||||
def update_new_bom(self):
|
||||
current_bom_unitcost = frappe.db.sql("""select total_cost/quantity
|
||||
|
||||
@@ -88,7 +88,7 @@ class ProductionOrder(Document):
|
||||
self.update_status(status)
|
||||
qty = (flt(self.qty)-flt(self.produced_qty)) * ((status == 'Stopped') and -1 or 1)
|
||||
self.update_planned_qty(qty)
|
||||
msgprint("Production Order has been %s" % status)
|
||||
frappe.msgprint(_("Production Order status is {0}").format(status))
|
||||
|
||||
|
||||
def update_status(self, status):
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import cstr, flt, cint, nowdate, add_days
|
||||
from frappe.utils import cstr, flt, cint, nowdate, add_days, comma_and
|
||||
|
||||
from frappe import msgprint, _
|
||||
|
||||
@@ -180,9 +180,9 @@ class ProductionPlanningTool(Document):
|
||||
if pro:
|
||||
pro = ["""<a href="#Form/Production Order/%s" target="_blank">%s</a>""" % \
|
||||
(p, p) for p in pro]
|
||||
msgprint(_("Production Order(s) created:\n\n") + '\n'.join(pro))
|
||||
msgprint(_("{0} created").format(comma_and(pro)))
|
||||
else :
|
||||
msgprint(_("No Production Order created."))
|
||||
msgprint(_("No Production Orders created"))
|
||||
|
||||
def get_distinct_items_and_boms(self):
|
||||
""" Club similar BOM and item for processing
|
||||
@@ -221,7 +221,7 @@ class ProductionPlanningTool(Document):
|
||||
try:
|
||||
pro.insert()
|
||||
pro_list.append(pro.name)
|
||||
except OverProductionError, e:
|
||||
except OverProductionError:
|
||||
pass
|
||||
|
||||
frappe.flags.mute_messages = False
|
||||
@@ -401,7 +401,6 @@ class ProductionPlanningTool(Document):
|
||||
if purchase_request_list:
|
||||
pur_req = ["""<a href="#Form/Material Request/%s" target="_blank">%s</a>""" % \
|
||||
(p, p) for p in purchase_request_list]
|
||||
msgprint("Material Request(s) created: \n%s" %
|
||||
"\n".join(pur_req))
|
||||
msgprint(_("Material Requests {0} created").format(comma_and(pur_req)))
|
||||
else:
|
||||
msgprint(_("Nothing to request"))
|
||||
|
||||
@@ -5,7 +5,7 @@ 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
|
||||
@@ -24,8 +24,7 @@ class Project(Document):
|
||||
"""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()
|
||||
|
||||
@@ -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
|
||||
@@ -24,12 +24,10 @@ class Task(Document):
|
||||
|
||||
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()
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -51,8 +51,7 @@ class TimeLog(Document):
|
||||
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()
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -6,7 +6,7 @@ import frappe
|
||||
|
||||
from frappe.utils import cstr, getdate
|
||||
|
||||
from frappe import msgprint
|
||||
from frappe import _
|
||||
from erpnext.stock.utils import get_valid_serial_nos
|
||||
|
||||
from erpnext.utilities.transaction_base import TransactionBase
|
||||
@@ -46,15 +46,14 @@ class InstallationNote(TransactionBase):
|
||||
def is_serial_no_added(self, item_code, serial_no):
|
||||
ar_required = frappe.db.get_value("Item", item_code, "has_serial_no")
|
||||
if ar_required == 'Yes' and not serial_no:
|
||||
msgprint("Serial No is mandatory for item: " + item_code, raise_exception=1)
|
||||
frappe.throw(_("Serial No is mandatory for Item {0}").format(item_code))
|
||||
elif ar_required != 'Yes' and cstr(serial_no).strip():
|
||||
msgprint("If serial no required, please select 'Yes' in 'Has Serial No' in Item :" +
|
||||
item_code, raise_exception=1)
|
||||
frappe.throw(_("Item {0} is not a serialized Item").format(item_code))
|
||||
|
||||
def is_serial_no_exist(self, item_code, serial_no):
|
||||
for x in serial_no:
|
||||
if not frappe.db.exists("Serial No", x):
|
||||
msgprint("Serial No " + x + " does not exist in the system", raise_exception=1)
|
||||
frappe.throw(_("Serial No {0} does not exist").format(x))
|
||||
|
||||
def is_serial_no_installed(self,cur_s_no,item_code):
|
||||
for x in cur_s_no:
|
||||
@@ -62,8 +61,7 @@ class InstallationNote(TransactionBase):
|
||||
status = status and status[0][0] or ''
|
||||
|
||||
if status == 'Installed':
|
||||
msgprint("Item "+item_code+" with serial no. " + x + " already installed",
|
||||
raise_exception=1)
|
||||
frappe.throw(_("Item {0} with Serial No {1} is already installed").format(item_code, x))
|
||||
|
||||
def get_prevdoc_serial_no(self, prevdoc_detail_docname):
|
||||
serial_nos = frappe.db.get_value("Delivery Note Item",
|
||||
@@ -73,8 +71,7 @@ class InstallationNote(TransactionBase):
|
||||
def is_serial_no_match(self, cur_s_no, prevdoc_s_no, prevdoc_docname):
|
||||
for sr in cur_s_no:
|
||||
if sr not in prevdoc_s_no:
|
||||
msgprint("Serial No. " + sr + " is not matching with the Delivery Note " +
|
||||
prevdoc_docname, raise_exception = 1)
|
||||
frappe.throw(_("Serial No {0} does not belong to Delivery Note {1}").format(sr, prevdoc_docname))
|
||||
|
||||
def validate_serial_no(self):
|
||||
cur_s_no, prevdoc_s_no, sr_list = [], [], []
|
||||
@@ -95,12 +92,11 @@ class InstallationNote(TransactionBase):
|
||||
if d.prevdoc_docname:
|
||||
d_date = frappe.db.get_value("Delivery Note", d.prevdoc_docname, "posting_date")
|
||||
if d_date > getdate(self.inst_date):
|
||||
msgprint("Installation Date can not be before Delivery Date " + cstr(d_date) +
|
||||
" for item "+d.item_code, raise_exception=1)
|
||||
frappe.throw(_("Installation date cannot be before delivery date for Item {0}").format(d.item_code))
|
||||
|
||||
def check_item_table(self):
|
||||
if not(self.get('installed_item_details')):
|
||||
msgprint("Please fetch items from Delivery Note selected", raise_exception=1)
|
||||
frappe.throw(_("Please pull items from Delivery Note"))
|
||||
|
||||
def on_update(self):
|
||||
frappe.db.set(self, 'status', 'Draft')
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.utils import cstr, validate_email_add, cint
|
||||
from frappe.utils import cstr, validate_email_add, cint, comma_and
|
||||
from frappe import session
|
||||
|
||||
|
||||
@@ -52,8 +52,7 @@ class Lead(SellingController):
|
||||
self.email_id)
|
||||
if len(email_list) > 1:
|
||||
items = [e[0] for e in email_list if e[0]!=self.name]
|
||||
frappe.msgprint(_("""Email Id must be unique, already exists for: """) + \
|
||||
", ".join(items), raise_exception=True)
|
||||
frappe.throw(_("Email id must be unique, already exists for {0}").format(comma_and(items)))
|
||||
|
||||
def on_trash(self):
|
||||
frappe.db.sql("""update `tabSupport Ticket` set lead='' where lead=%s""",
|
||||
|
||||
@@ -82,12 +82,11 @@ class Opportunity(TransactionBase):
|
||||
|
||||
def validate_item_details(self):
|
||||
if not self.get('enquiry_details'):
|
||||
msgprint("Please select items for which enquiry needs to be made")
|
||||
raise Exception
|
||||
frappe.throw(_("Items required"))
|
||||
|
||||
def validate_lead_cust(self):
|
||||
if self.enquiry_from == 'Lead' and not self.lead:
|
||||
msgprint("Lead Id is mandatory if 'Opportunity From' is selected as Lead", raise_exception=1)
|
||||
frappe.throw(_("Lead must be set if Opportunity is made from Lead"))
|
||||
elif self.enquiry_from == 'Customer' and not self.customer:
|
||||
msgprint("Customer is mandatory if 'Opportunity From' is selected as Customer", raise_exception=1)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import cstr
|
||||
|
||||
from frappe import _, msgprint
|
||||
from frappe import _
|
||||
|
||||
from erpnext.controllers.selling_controller import SellingController
|
||||
|
||||
@@ -20,8 +20,7 @@ class Quotation(SellingController):
|
||||
chk_dupl_itm = []
|
||||
for d in self.get('quotation_details'):
|
||||
if [cstr(d.item_code),cstr(d.description)] in chk_dupl_itm:
|
||||
msgprint("Item %s has been entered twice. Please change description atleast to continue" % d.item_code)
|
||||
raise Exception
|
||||
frappe.throw(_("Item {0} with same description entered twice").format(d.item_code))
|
||||
else:
|
||||
chk_dupl_itm.append([cstr(d.item_code),cstr(d.description)])
|
||||
|
||||
@@ -34,16 +33,14 @@ class Quotation(SellingController):
|
||||
is_service_item = is_service_item and is_service_item[0][0] or 'No'
|
||||
|
||||
if is_service_item == 'No':
|
||||
msgprint("You can not select non service item "+d.item_code+" in Maintenance Quotation")
|
||||
raise Exception
|
||||
frappe.throw(_("Item {0} must be Service Item").format(d.item_code))
|
||||
else:
|
||||
for d in self.get('quotation_details'):
|
||||
is_sales_item = frappe.db.sql("select is_sales_item from `tabItem` where name=%s", d.item_code)
|
||||
is_sales_item = is_sales_item and is_sales_item[0][0] or 'No'
|
||||
|
||||
if is_sales_item == 'No':
|
||||
msgprint("You can not select non sales item "+d.item_code+" in Sales Quotation")
|
||||
raise Exception
|
||||
frappe.throw(_("Item {0} must be Sales Item").format(d.item_code))
|
||||
|
||||
def validate(self):
|
||||
super(Quotation, self).validate()
|
||||
@@ -67,8 +64,7 @@ class Quotation(SellingController):
|
||||
|
||||
def check_item_table(self):
|
||||
if not self.get('quotation_details'):
|
||||
msgprint("Please enter item details")
|
||||
raise Exception
|
||||
frappe.throw(_("Please enter item details"))
|
||||
|
||||
def on_submit(self):
|
||||
self.check_item_table()
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe import _
|
||||
|
||||
from frappe.model.document import Document
|
||||
|
||||
class SalesBOM(Document):
|
||||
@@ -22,8 +24,7 @@ class SalesBOM(Document):
|
||||
"""main item must have Is Stock Item as No and Is Sales Item as Yes"""
|
||||
if not frappe.db.sql("""select name from tabItem where name=%s and
|
||||
ifnull(is_stock_item,'')='No' and ifnull(is_sales_item,'')='Yes'""", self.new_item_code):
|
||||
frappe.msgprint("""Parent Item %s is either a Stock Item or a not a Sales Item""",
|
||||
raise_exception=1)
|
||||
frappe.throw(_("Parent Item {0} must be not Stock Item and must be a Sales Item").format(self.new_item_code))
|
||||
|
||||
def get_item_details(self, name):
|
||||
det = frappe.db.sql("""select description, stock_uom from `tabItem`
|
||||
|
||||
@@ -5,9 +5,9 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
import frappe.utils
|
||||
|
||||
from frappe.utils import cstr, flt, getdate
|
||||
from frappe.utils import cstr, flt, getdate, comma_and
|
||||
|
||||
from frappe import msgprint
|
||||
from frappe import _
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
|
||||
from erpnext.controllers.selling_controller import SellingController
|
||||
@@ -23,22 +23,19 @@ class SalesOrder(SellingController):
|
||||
# validate transaction date v/s delivery date
|
||||
if self.delivery_date:
|
||||
if getdate(self.transaction_date) > getdate(self.delivery_date):
|
||||
msgprint("Expected Delivery Date cannot be before Sales Order Date")
|
||||
raise Exception
|
||||
frappe.throw(_("Expected Delivery Date cannot be before Sales Order Date"))
|
||||
|
||||
def validate_po(self):
|
||||
# validate p.o date v/s delivery date
|
||||
if self.po_date and self.delivery_date and getdate(self.po_date) > getdate(self.delivery_date):
|
||||
msgprint("Expected Delivery Date cannot be before Purchase Order Date")
|
||||
raise Exception
|
||||
frappe.throw(_("Expected Delivery Date cannot be before Purchase Order Date"))
|
||||
|
||||
if self.po_no and self.customer:
|
||||
so = frappe.db.sql("select name from `tabSales Order` \
|
||||
where ifnull(po_no, '') = %s and name != %s and docstatus < 2\
|
||||
and customer = %s", (self.po_no, self.name, self.customer))
|
||||
if so and so[0][0]:
|
||||
msgprint("""Another Sales Order (%s) exists against same PO No and Customer.
|
||||
Please be sure, you are not making duplicate entry.""" % so[0][0])
|
||||
frappe.msgprint(_("Warning: Sales Order {0} already exists against same Purchase Order number").format(so[0][0]))
|
||||
|
||||
def validate_for_items(self):
|
||||
check_list, flag = [], 0
|
||||
@@ -49,16 +46,15 @@ class SalesOrder(SellingController):
|
||||
|
||||
if frappe.db.get_value("Item", d.item_code, "is_stock_item") == 'Yes':
|
||||
if not d.warehouse:
|
||||
msgprint("""Please enter Reserved Warehouse for item %s
|
||||
as it is stock Item""" % d.item_code, raise_exception=1)
|
||||
frappe.throw(_("Reserved warehouse required for stock item {0}").format(d.item_code))
|
||||
|
||||
if e in check_list:
|
||||
msgprint("Item %s has been entered twice." % d.item_code)
|
||||
frappe.throw(_("Item {0} has been entered twice").format(d.item_code))
|
||||
else:
|
||||
check_list.append(e)
|
||||
else:
|
||||
if f in chk_dupl_itm:
|
||||
msgprint("Item %s has been entered twice." % d.item_code)
|
||||
frappe.throw(_("Item {0} has been entered twice").format(d.item_code))
|
||||
else:
|
||||
chk_dupl_itm.append(f)
|
||||
|
||||
@@ -74,16 +70,14 @@ class SalesOrder(SellingController):
|
||||
if d.prevdoc_docname:
|
||||
res = frappe.db.sql("select name from `tabQuotation` where name=%s and order_type = %s", (d.prevdoc_docname, self.order_type))
|
||||
if not res:
|
||||
msgprint("""Order Type (%s) should be same in Quotation: %s \
|
||||
and current Sales Order""" % (self.order_type, d.prevdoc_docname))
|
||||
frappe.msgprint(_("Quotation {0} not of type {1}").format(d.prevdoc_docname, self.order_type))
|
||||
|
||||
def validate_order_type(self):
|
||||
super(SalesOrder, self).validate_order_type()
|
||||
|
||||
def validate_delivery_date(self):
|
||||
if self.order_type == 'Sales' and not self.delivery_date:
|
||||
msgprint("Please enter 'Expected Delivery Date'")
|
||||
raise Exception
|
||||
frappe.throw(_("Please enter 'Expected Delivery Date'"))
|
||||
|
||||
self.validate_sales_mntc_quotation()
|
||||
|
||||
@@ -93,8 +87,7 @@ class SalesOrder(SellingController):
|
||||
and (customer = %s or ifnull(customer,'')='')""",
|
||||
(self.project_name, self.customer))
|
||||
if not res:
|
||||
msgprint("Customer - %s does not belong to project - %s. \n\nIf you want to use project for multiple customers then please make customer details blank in project - %s."%(self.customer,self.project_name,self.project_name))
|
||||
raise Exception
|
||||
frappe.throw(_("Customer {0} does not belong to project {1}").format(self.customer, self.project_name))
|
||||
|
||||
def validate(self):
|
||||
super(SalesOrder, self).validate()
|
||||
@@ -169,8 +162,8 @@ class SalesOrder(SellingController):
|
||||
def on_cancel(self):
|
||||
# Cannot cancel stopped SO
|
||||
if self.status == 'Stopped':
|
||||
msgprint("Sales Order : '%s' cannot be cancelled as it is Stopped. Unstop it for any further transactions" %(self.name))
|
||||
raise Exception
|
||||
frappe.throw(_("Stopped order cannot be cancelled. Unstop to cancel."))
|
||||
|
||||
self.check_nextdoc_docstatus()
|
||||
self.update_stock_ledger(update_stock = -1)
|
||||
|
||||
@@ -180,55 +173,56 @@ class SalesOrder(SellingController):
|
||||
|
||||
def check_nextdoc_docstatus(self):
|
||||
# Checks Delivery Note
|
||||
submit_dn = frappe.db.sql("select t1.name from `tabDelivery Note` t1,`tabDelivery Note Item` t2 where t1.name = t2.parent and t2.against_sales_order = %s and t1.docstatus = 1", self.name)
|
||||
submit_dn = frappe.db.sql_list("""select t1.name from `tabDelivery Note` t1,`tabDelivery Note Item` t2
|
||||
where t1.name = t2.parent and t2.against_sales_order = %s and t1.docstatus = 1""", self.name)
|
||||
if submit_dn:
|
||||
msgprint("Delivery Note : " + cstr(submit_dn[0][0]) + " has been submitted against " + cstr(self.doctype) + ". Please cancel Delivery Note : " + cstr(submit_dn[0][0]) + " first and then cancel "+ cstr(self.doctype), raise_exception = 1)
|
||||
frappe.throw(_("Delivery Notes {0} must be cancelled before cancelling this Sales Order").format(comma_and(submit_dn)))
|
||||
|
||||
# Checks Sales Invoice
|
||||
submit_rv = frappe.db.sql("""select t1.name
|
||||
submit_rv = frappe.db.sql_list("""select t1.name
|
||||
from `tabSales Invoice` t1,`tabSales Invoice Item` t2
|
||||
where t1.name = t2.parent and t2.sales_order = %s and t1.docstatus = 1""",
|
||||
self.name)
|
||||
if submit_rv:
|
||||
msgprint("Sales Invoice : " + cstr(submit_rv[0][0]) + " has already been submitted against " +cstr(self.doctype)+ ". Please cancel Sales Invoice : "+ cstr(submit_rv[0][0]) + " first and then cancel "+ cstr(self.doctype), raise_exception = 1)
|
||||
frappe.throw(_("Sales Invoice {0} must be cancelled before cancelling this Sales Order").format(comma_and(submit_rv)))
|
||||
|
||||
#check maintenance schedule
|
||||
submit_ms = frappe.db.sql("select t1.name from `tabMaintenance Schedule` t1, `tabMaintenance Schedule Item` t2 where t2.parent=t1.name and t2.prevdoc_docname = %s and t1.docstatus = 1",self.name)
|
||||
submit_ms = frappe.db.sql_list("""select t1.name from `tabMaintenance Schedule` t1,
|
||||
`tabMaintenance Schedule Item` t2
|
||||
where t2.parent=t1.name and t2.prevdoc_docname = %s and t1.docstatus = 1""", self.name)
|
||||
if submit_ms:
|
||||
msgprint("Maintenance Schedule : " + cstr(submit_ms[0][0]) + " has already been submitted against " +cstr(self.doctype)+ ". Please cancel Maintenance Schedule : "+ cstr(submit_ms[0][0]) + " first and then cancel "+ cstr(self.doctype), raise_exception = 1)
|
||||
frappe.throw(_("Maintenance Schedule {0} must be cancelled before cancelling this Sales Order").format(comma_and(submit_ms)))
|
||||
|
||||
# check maintenance visit
|
||||
submit_mv = frappe.db.sql("select t1.name from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2 where t2.parent=t1.name and t2.prevdoc_docname = %s and t1.docstatus = 1",self.name)
|
||||
submit_mv = frappe.db.sql_list("""select t1.name from `tabMaintenance Visit` t1, `tabMaintenance Visit Purpose` t2
|
||||
where t2.parent=t1.name and t2.prevdoc_docname = %s and t1.docstatus = 1""",self.name)
|
||||
if submit_mv:
|
||||
msgprint("Maintenance Visit : " + cstr(submit_mv[0][0]) + " has already been submitted against " +cstr(self.doctype)+ ". Please cancel Maintenance Visit : " + cstr(submit_mv[0][0]) + " first and then cancel "+ cstr(self.doctype), raise_exception = 1)
|
||||
frappe.throw(_("Maintenance Visit {0} must be cancelled before cancelling this Sales Order").format(comma_and(submit_mv)))
|
||||
|
||||
# check production order
|
||||
pro_order = frappe.db.sql("""select name from `tabProduction Order` where sales_order = %s and docstatus = 1""", self.name)
|
||||
pro_order = frappe.db.sql_list("""select name from `tabProduction Order`
|
||||
where sales_order = %s and docstatus = 1""", self.name)
|
||||
if pro_order:
|
||||
msgprint("""Production Order: %s exists against this sales order.
|
||||
Please cancel production order first and then cancel this sales order""" %
|
||||
pro_order[0][0], raise_exception=1)
|
||||
frappe.throw(_("Production Order {0} must be cancelled before cancelling this Sales Order").format(comma_and(pro_order)))
|
||||
|
||||
def check_modified_date(self):
|
||||
mod_db = frappe.db.get_value("Sales Order", self.name, "modified")
|
||||
date_diff = frappe.db.sql("select TIMEDIFF('%s', '%s')" %
|
||||
( mod_db, cstr(self.modified)))
|
||||
if date_diff and date_diff[0][0]:
|
||||
msgprint("%s: %s has been modified after you have opened. Please Refresh"
|
||||
% (self.doctype, self.name), raise_exception=1)
|
||||
frappe.throw(_("{0} {1} has been modified. Please Refresh").format(self.doctype, self.name))
|
||||
|
||||
def stop_sales_order(self):
|
||||
self.check_modified_date()
|
||||
self.update_stock_ledger(-1)
|
||||
frappe.db.set(self, 'status', 'Stopped')
|
||||
msgprint("""%s: %s has been Stopped. To make transactions against this Sales Order
|
||||
you need to Unstop it.""" % (self.doctype, self.name))
|
||||
frappe.msgprint(_("{0} {1} status is Stopped").format(self.doctype, self.name))
|
||||
|
||||
def unstop_sales_order(self):
|
||||
self.check_modified_date()
|
||||
self.update_stock_ledger(1)
|
||||
frappe.db.set(self, 'status', 'Submitted')
|
||||
msgprint("%s: %s has been Unstopped" % (self.doctype, self.name))
|
||||
frappe.msgprint(_("{0} {1} status is Unstopped").format(self.doctype, self.name))
|
||||
|
||||
|
||||
def update_stock_ledger(self, update_stock):
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import cint
|
||||
from frappe import _
|
||||
|
||||
def execute(filters=None):
|
||||
if not filters: filters ={}
|
||||
|
||||
days_since_last_order = filters.get("days_since_last_order")
|
||||
if cint(days_since_last_order) <= 0:
|
||||
frappe.msgprint("Please mention positive value in 'Days Since Last Order' field",raise_exception=1)
|
||||
frappe.throw(_("'Days Since Last Order' must be greater than or equal to zero"))
|
||||
|
||||
columns = get_columns()
|
||||
customers = get_so_details()
|
||||
|
||||
@@ -5,10 +5,8 @@ from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _, msgprint
|
||||
from frappe.utils import flt
|
||||
import time
|
||||
from erpnext.accounts.utils import get_fiscal_year
|
||||
from erpnext.controllers.trends import get_period_date_ranges, get_period_month_ranges
|
||||
from frappe.model.meta import get_field_precision
|
||||
|
||||
def execute(filters=None):
|
||||
if not filters: filters = {}
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe.utils import cstr, flt, has_common, make_esc
|
||||
from frappe.utils import cstr, flt, has_common, make_esc, comma_or
|
||||
|
||||
from frappe import session, msgprint
|
||||
from erpnext.setup.utils import get_company_currency
|
||||
from frappe import session, _
|
||||
|
||||
|
||||
from erpnext.utilities.transaction_base import TransactionBase
|
||||
@@ -34,17 +33,8 @@ class AuthorizationControl(TransactionBase):
|
||||
if(d[1]): appr_roles.append(d[1])
|
||||
|
||||
if not has_common(appr_roles, frappe.user.get_roles()) and not has_common(appr_users, [session['user']]):
|
||||
msg, add_msg = '',''
|
||||
if max_amount:
|
||||
dcc = get_company_currency(self.company)
|
||||
if based_on == 'Grand Total': msg = "since Grand Total exceeds %s. %s" % (dcc, flt(max_amount))
|
||||
elif based_on == 'Itemwise Discount': msg = "since Discount exceeds %s for Item Code : %s" % (cstr(max_amount)+'%', item)
|
||||
elif based_on == 'Average Discount' or based_on == 'Customerwise Discount': msg = "since Discount exceeds %s" % (cstr(max_amount)+'%')
|
||||
|
||||
if appr_users: add_msg = "Users : "+cstr(appr_users)
|
||||
if appr_roles: add_msg = "Roles : "+cstr(appr_roles)
|
||||
if appr_users and appr_roles: add_msg = "Users : "+cstr(appr_users)+" or "+"Roles : "+cstr(appr_roles)
|
||||
msgprint("You are not authorize to submit this %s %s. Please send for approval to %s" % (doctype_name, msg, add_msg))
|
||||
frappe.msgprint(_("Not authroized since {0} exceeds limits").format(_(based_on)))
|
||||
frappe.throw(_("Can be approved by {0}").format(comma_or(appr_roles + appr_users)))
|
||||
raise Exception
|
||||
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe.utils import cint, cstr, flt, has_common
|
||||
from frappe import msgprint
|
||||
from frappe.utils import cstr, flt
|
||||
from frappe import _, msgprint
|
||||
|
||||
from frappe.model.document import Document
|
||||
|
||||
@@ -23,62 +23,28 @@ class AuthorizationRule(Document):
|
||||
cstr(self.to_designation), self.name))
|
||||
auth_exists = exists and exists[0][0] or ''
|
||||
if auth_exists:
|
||||
if cint(exists[0][1]) == 2:
|
||||
msgprint("""Duplicate Entry. Please untrash Authorization Rule : %s \
|
||||
from Recycle Bin""" % (auth_exists), raise_exception=1)
|
||||
else:
|
||||
msgprint("Duplicate Entry. Please check Authorization Rule : %s" %
|
||||
(auth_exists), raise_exception=1)
|
||||
|
||||
|
||||
def validate_master_name(self):
|
||||
if self.based_on == 'Customerwise Discount' and \
|
||||
not frappe.db.sql("""select name from tabCustomer
|
||||
where name = %s and docstatus != 2""", (self.master_name)):
|
||||
msgprint("Please select valid Customer Name for Customerwise Discount",
|
||||
raise_exception=1)
|
||||
elif self.based_on == 'Itemwise Discount' and \
|
||||
not frappe.db.sql("select name from tabItem where name = %s and docstatus != 2",
|
||||
(self.master_name)):
|
||||
msgprint("Please select valid Item Name for Itemwise Discount", raise_exception=1)
|
||||
elif (self.based_on == 'Grand Total' or \
|
||||
self.based_on == 'Average Discount') and self.master_name:
|
||||
msgprint("Please remove Customer/Item Name for %s." %
|
||||
self.based_on, raise_exception=1)
|
||||
frappe.throw(_("Duplicate Entry. Please check Authorization Rule {0}").format(auth_exists))
|
||||
|
||||
|
||||
def validate_rule(self):
|
||||
if self.transaction != 'Appraisal':
|
||||
if not self.approving_role and not self.approving_user:
|
||||
msgprint("Please enter Approving Role or Approving User", raise_exception=1)
|
||||
frappe.throw(_("Please enter Approving Role or Approving User"))
|
||||
elif self.system_user and self.system_user == self.approving_user:
|
||||
msgprint("Approving User cannot be same as user the rule is Applicable To (User)",
|
||||
raise_exception=1)
|
||||
frappe.throw(_("Approving User cannot be same as user the rule is Applicable To"))
|
||||
elif self.system_role and self.system_role == self.approving_role:
|
||||
msgprint("Approving Role cannot be same as user the rule is \
|
||||
Applicable To (Role).", raise_exception=1)
|
||||
elif self.system_user and self.approving_role and \
|
||||
has_common([self.approving_role], [x[0] for x in \
|
||||
frappe.db.sql("select role from `tabUserRole` where parent = %s", \
|
||||
(self.system_user))]):
|
||||
msgprint("System User : %s is assigned role : %s. So rule does not make sense" %
|
||||
(self.system_user,self.approving_role), raise_exception=1)
|
||||
frappe.throw(_("Approving Role cannot be same as role the rule is Applicable To"))
|
||||
elif self.transaction in ['Purchase Order', 'Purchase Receipt', \
|
||||
'Purchase Invoice', 'Stock Entry'] and self.based_on \
|
||||
in ['Average Discount', 'Customerwise Discount', 'Itemwise Discount']:
|
||||
msgprint("You cannot set authorization on basis of Discount for %s" %
|
||||
self.transaction, raise_exception=1)
|
||||
frappe.throw(_("Cannot set authorization on basis of Discount for {0}").format(self.transaction))
|
||||
elif self.based_on == 'Average Discount' and flt(self.value) > 100.00:
|
||||
msgprint("Discount cannot given for more than 100%", raise_exception=1)
|
||||
frappe.throw(_("Discount must be less than 100"))
|
||||
elif self.based_on == 'Customerwise Discount' and not self.master_name:
|
||||
msgprint("Please enter Customer Name for 'Customerwise Discount'",
|
||||
raise_exception=1)
|
||||
frappe.throw(_("Customer required for 'Customerwise Discount'"))
|
||||
else:
|
||||
if self.transaction == 'Appraisal' and self.based_on != 'Not Applicable':
|
||||
msgprint("Based on should be 'Not Applicable' while setting authorization rule\
|
||||
for 'Appraisal'", raise_exception=1)
|
||||
|
||||
|
||||
if self.transaction == 'Appraisal':
|
||||
self.based_on = "Not Applicable"
|
||||
|
||||
def validate(self):
|
||||
self.check_duplicate_entry()
|
||||
|
||||
@@ -20,7 +20,7 @@ import mimetypes
|
||||
import frappe
|
||||
import oauth2client.client
|
||||
from frappe.utils import cstr
|
||||
from frappe import _, msgprint
|
||||
from frappe import _
|
||||
from apiclient.discovery import build
|
||||
from apiclient.http import MediaFileUpload
|
||||
|
||||
@@ -117,8 +117,7 @@ def get_gdrive_flow():
|
||||
from frappe import conf
|
||||
|
||||
if not "gdrive_client_id" in conf:
|
||||
frappe.msgprint(_("Please set Google Drive access keys in") + " conf.py",
|
||||
raise_exception=True)
|
||||
frappe.throw(_("Please set Google Drive access keys in {0}"),format("site_config.json"))
|
||||
|
||||
flow = OAuth2WebServerFlow(conf.gdrive_client_id, conf.gdrive_client_secret,
|
||||
"https://www.googleapis.com/auth/drive", 'urn:ietf:wg:oauth:2.0:oob')
|
||||
@@ -145,7 +144,7 @@ def gdrive_callback(verification_code = None):
|
||||
final_credentials = credentials.to_json()
|
||||
frappe.db.set_value("Backup Manager", "Backup Manager", "gdrive_credentials", final_credentials)
|
||||
|
||||
frappe.msgprint("Updated")
|
||||
frappe.msgprint(_("Updated"))
|
||||
|
||||
def create_erpnext_folder(service):
|
||||
if not frappe.db:
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _, msgprint
|
||||
from frappe import _
|
||||
|
||||
from frappe.utils import cstr, cint
|
||||
from frappe.utils import cint
|
||||
import frappe.defaults
|
||||
|
||||
|
||||
@@ -30,14 +30,13 @@ class Company(Document):
|
||||
|
||||
def validate(self):
|
||||
if self.get('__islocal') and len(self.abbr) > 5:
|
||||
frappe.msgprint("Abbreviation cannot have more than 5 characters",
|
||||
raise_exception=1)
|
||||
frappe.throw(_("Abbreviation cannot have more than 5 characters"))
|
||||
|
||||
self.previous_default_currency = frappe.db.get_value("Company", self.name, "default_currency")
|
||||
if self.default_currency and self.previous_default_currency and \
|
||||
self.default_currency != self.previous_default_currency and \
|
||||
self.check_if_transactions_exist():
|
||||
msgprint(_("Sorry! You cannot change company's default currency, because there are existing transactions against it. You will need to cancel those transactions if you want to change the default currency."), raise_exception=True)
|
||||
frappe.throw(_("Cannot change company's default currency, because there are existing transactions. Transactions must be cancelled to change the default currency."))
|
||||
|
||||
def on_update(self):
|
||||
if not frappe.db.sql("""select name from tabAccount
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _, msgprint
|
||||
from frappe import _
|
||||
from frappe.model.controller import DocListController
|
||||
|
||||
class CurrencyExchange(DocListController):
|
||||
@@ -17,4 +17,4 @@ class CurrencyExchange(DocListController):
|
||||
self.validate_value("exchange_rate", ">", 0)
|
||||
|
||||
if self.from_currency == self.to_currency:
|
||||
msgprint(_("From Currency and To Currency cannot be same"), raise_exception=True)
|
||||
frappe.throw(_("From Currency and To Currency cannot be same"))
|
||||
|
||||
@@ -3,20 +3,13 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import msgprint
|
||||
from frappe import _
|
||||
|
||||
|
||||
from frappe.utils.nestedset import NestedSet
|
||||
class CustomerGroup(NestedSet):
|
||||
nsm_parent_field = 'parent_customer_group';
|
||||
|
||||
def validate(self):
|
||||
if frappe.db.sql("select name from `tabCustomer Group` where name = %s and docstatus = 2",
|
||||
(self.customer_group_name)):
|
||||
msgprint("""Another %s record is trashed.
|
||||
To untrash please go to Setup -> Recycle Bin.""" %
|
||||
(self.customer_group_name), raise_exception = 1)
|
||||
|
||||
def on_update(self):
|
||||
self.validate_name_with_customer()
|
||||
super(CustomerGroup, self).on_update()
|
||||
@@ -24,24 +17,6 @@ class CustomerGroup(NestedSet):
|
||||
|
||||
def validate_name_with_customer(self):
|
||||
if frappe.db.exists("Customer", self.name):
|
||||
frappe.msgprint("An Customer exists with same name (%s), \
|
||||
please change the Customer Group name or rename the Customer" %
|
||||
frappe.msgprint(_("An Customer exists with same name (%s), \
|
||||
please change the Customer Group name or rename the Customer") %
|
||||
self.name, raise_exception=1)
|
||||
|
||||
def on_trash(self):
|
||||
cust = frappe.db.sql("select name from `tabCustomer` where ifnull(customer_group, '') = %s",
|
||||
self.name)
|
||||
cust = [d[0] for d in cust]
|
||||
if cust:
|
||||
msgprint("""Customer Group: %s can not be trashed/deleted \
|
||||
because it is used in customer: %s.
|
||||
To trash/delete this, remove/change customer group in customer master""" %
|
||||
(self.name, cust or ''), raise_exception=1)
|
||||
|
||||
if frappe.db.sql("select name from `tabCustomer Group` where parent_customer_group = %s \
|
||||
and docstatus != 2", self.name):
|
||||
msgprint("Child customer group exists for this customer group. \
|
||||
You can not trash/cancel/delete this customer group.", raise_exception=1)
|
||||
|
||||
# rebuild tree
|
||||
super(CustomerGroup, self).on_trash()
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
"""Global Defaults"""
|
||||
import frappe
|
||||
from frappe import _
|
||||
import frappe.defaults
|
||||
from frappe.utils import cint
|
||||
|
||||
@@ -56,8 +57,7 @@ class GlobalDefaults(Document):
|
||||
if self.session_expiry:
|
||||
parts = self.session_expiry.split(":")
|
||||
if len(parts)!=2 or not (cint(parts[0]) or cint(parts[1])):
|
||||
frappe.msgprint("""Session Expiry must be in format hh:mm""",
|
||||
raise_exception=1)
|
||||
frappe.throw(_("Session Expiry must be in format {0}").format("hh:mm"))
|
||||
|
||||
def set_country_and_timezone(self):
|
||||
frappe.db.set_default("country", self.country)
|
||||
|
||||
@@ -34,5 +34,4 @@ class ItemGroup(NestedSet, WebsiteGenerator):
|
||||
|
||||
def validate_name_with_item(self):
|
||||
if frappe.db.exists("Item", self.name):
|
||||
frappe.msgprint("An item exists with same name (%s), please change the \
|
||||
item group name or rename the item" % self.name, raise_exception=1)
|
||||
frappe.throw(frappe._("An item exists with same name ({0}), please change the item group name or rename the item").format(self.name))
|
||||
|
||||
@@ -16,5 +16,4 @@ class JobsEmailSettings(Document):
|
||||
if cint(self.extract_emails) and not (self.email_id and self.host and \
|
||||
self.username and self.password):
|
||||
|
||||
frappe.msgprint(_("""Host, Email and Password required if emails are to be pulled"""),
|
||||
raise_exception=True)
|
||||
frappe.throw(_("""Host, Email and Password required if emails are to be pulled"""))
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe import msgprint
|
||||
|
||||
from frappe import _
|
||||
|
||||
from frappe.model.document import Document
|
||||
|
||||
@@ -18,5 +17,5 @@ class NotificationControl(Document):
|
||||
def set_message(self, arg = ''):
|
||||
fn = self.select_transaction.lower().replace(' ', '_') + '_message'
|
||||
frappe.db.set(self, fn, self.custom_message)
|
||||
msgprint("Custom Message for %s updated!" % self.select_transaction)
|
||||
frappe.msgprint(_("Message updated"))
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import frappe
|
||||
|
||||
|
||||
from frappe.utils import flt
|
||||
from frappe import _
|
||||
|
||||
from frappe.utils.nestedset import NestedSet
|
||||
|
||||
@@ -15,8 +16,7 @@ class Territory(NestedSet):
|
||||
def validate(self):
|
||||
for d in self.get('target_details'):
|
||||
if not flt(d.target_qty) and not flt(d.target_amount):
|
||||
msgprint("Either target qty or target amount is mandatory.")
|
||||
raise Exception
|
||||
frappe.throw(_("Either target qty or target amount is mandatory"))
|
||||
|
||||
def on_update(self):
|
||||
super(Territory, self).on_update()
|
||||
|
||||
@@ -36,10 +36,6 @@ def get_price_list_currency(price_list):
|
||||
"enabled": 1}, "currency")
|
||||
|
||||
if not price_list_currency:
|
||||
throw("{message}: {price_list} {disabled}".format(**{
|
||||
"message": _("Price List"),
|
||||
"price_list": price_list,
|
||||
"disabled": _("is disabled.")
|
||||
}))
|
||||
throw(_("Price List {0} is disabled").format(price_list))
|
||||
else:
|
||||
return {"price_list_currency": price_list_currency}
|
||||
@@ -4,7 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe.utils import cstr, flt, cint
|
||||
from frappe.utils import flt, cint
|
||||
|
||||
from frappe import msgprint, _
|
||||
import frappe.defaults
|
||||
@@ -54,9 +54,7 @@ class DeliveryNote(SellingController):
|
||||
if frappe.db.get_value("Selling Settings", None, 'so_required') == 'Yes':
|
||||
for d in self.get('delivery_note_details'):
|
||||
if not d.against_sales_order:
|
||||
msgprint("Sales Order No. required against item %s"%d.item_code)
|
||||
raise Exception
|
||||
|
||||
frappe.throw(_("Sales Order required for Item {0}").format(d.item_code))
|
||||
|
||||
def validate(self):
|
||||
super(DeliveryNote, self).validate()
|
||||
@@ -108,8 +106,7 @@ class DeliveryNote(SellingController):
|
||||
where name = %s and (customer = %s or
|
||||
ifnull(customer,'')='')""", (self.project_name, self.customer))
|
||||
if not res:
|
||||
msgprint("Customer - %s does not belong to project - %s. \n\nIf you want to use project for multiple customers then please make customer details blank in project - %s."%(self.customer,self.project_name,self.project_name))
|
||||
raise Exception
|
||||
frappe.throw(_("Customer {0} does not belong to project {1}").format(self.customer, self.project_name))
|
||||
|
||||
def validate_for_items(self):
|
||||
check_list, chk_dupl_itm = [], []
|
||||
@@ -119,14 +116,12 @@ class DeliveryNote(SellingController):
|
||||
|
||||
if frappe.db.get_value("Item", d.item_code, "is_stock_item") == 'Yes':
|
||||
if e in check_list:
|
||||
msgprint("Please check whether item %s has been entered twice wrongly."
|
||||
% d.item_code)
|
||||
msgprint(_("Note: Item {0} entered multiple times").format(d.item_code))
|
||||
else:
|
||||
check_list.append(e)
|
||||
else:
|
||||
if f in chk_dupl_itm:
|
||||
msgprint("Please check whether item %s has been entered twice wrongly."
|
||||
% d.item_code)
|
||||
msgprint(_("Note: Item {0} entered multiple times").format(d.item_code))
|
||||
else:
|
||||
chk_dupl_itm.append(f)
|
||||
|
||||
@@ -134,8 +129,7 @@ class DeliveryNote(SellingController):
|
||||
for d in self.get_item_list():
|
||||
if frappe.db.get_value("Item", d['item_code'], "is_stock_item") == "Yes":
|
||||
if not d['warehouse']:
|
||||
msgprint("Please enter Warehouse for item %s as it is stock item"
|
||||
% d['item_code'], raise_exception=1)
|
||||
frappe.throw(_("Warehouse required for stock Item {0}").format(d["item_code"]))
|
||||
|
||||
|
||||
def update_current_stock(self):
|
||||
@@ -187,18 +181,13 @@ class DeliveryNote(SellingController):
|
||||
"""
|
||||
if not any([flt(d.get('packed_qty')) for d in self.get(self.fname)]):
|
||||
return
|
||||
packing_error_list = []
|
||||
has_error = False
|
||||
for d in self.get(self.fname):
|
||||
if flt(d.get('qty')) != flt(d.get('packed_qty')):
|
||||
packing_error_list.append([
|
||||
d.get('item_code', ''),
|
||||
d.get('qty', 0),
|
||||
d.get('packed_qty', 0)
|
||||
])
|
||||
if packing_error_list:
|
||||
err_msg = "\n".join([("Item: " + d[0] + ", Qty: " + cstr(d[1]) \
|
||||
+ ", Packed: " + cstr(d[2])) for d in packing_error_list])
|
||||
frappe.msgprint("Packing Error:\n" + err_msg, raise_exception=1)
|
||||
frappe.msgprint(_("Packed quantity must equal quantity for Item {0} in row {1}").format(d.item_code, d.idx))
|
||||
has_error = True
|
||||
if has_error:
|
||||
raise frappe.ValidationError
|
||||
|
||||
def check_next_docstatus(self):
|
||||
submit_rv = frappe.db.sql("""select t1.name
|
||||
@@ -206,16 +195,14 @@ class DeliveryNote(SellingController):
|
||||
where t1.name = t2.parent and t2.delivery_note = %s and t1.docstatus = 1""",
|
||||
(self.name))
|
||||
if submit_rv:
|
||||
msgprint("Sales Invoice : " + cstr(submit_rv[0][0]) + " has already been submitted !")
|
||||
raise Exception , "Validation Error."
|
||||
frappe.throw(_("Sales Invoice {0} has already been submitted").format(submit_rv[0][0]))
|
||||
|
||||
submit_in = frappe.db.sql("""select t1.name
|
||||
from `tabInstallation Note` t1, `tabInstallation Note Item` t2
|
||||
where t1.name = t2.parent and t2.prevdoc_docname = %s and t1.docstatus = 1""",
|
||||
(self.name))
|
||||
if submit_in:
|
||||
msgprint("Installation Note : "+cstr(submit_in[0][0]) +" has already been submitted !")
|
||||
raise Exception , "Validation Error."
|
||||
frappe.throw(_("Installation Note {0} has already been submitted").format(submit_in[0][0]))
|
||||
|
||||
def cancel_packing_slips(self):
|
||||
"""
|
||||
@@ -228,7 +215,7 @@ class DeliveryNote(SellingController):
|
||||
for r in res:
|
||||
ps = frappe.get_doc('Packing Slip', r[0])
|
||||
ps.cancel()
|
||||
frappe.msgprint(_("Packing Slip(s) Cancelled"))
|
||||
frappe.msgprint(_("Packing Slip(s) cancelled"))
|
||||
|
||||
|
||||
def update_stock_ledger(self):
|
||||
@@ -293,8 +280,7 @@ def make_sales_invoice(source_name, target_doc=None):
|
||||
si.run_method("onload_post_render")
|
||||
|
||||
if len(si.get("entries")) == 0:
|
||||
frappe.msgprint(_("All these items have already been invoiced."),
|
||||
raise_exception=True)
|
||||
frappe.throw(_("All these items have already been invoiced"))
|
||||
|
||||
def update_item(source_doc, target_doc, source_parent):
|
||||
target_doc.qty = source_doc.qty - invoiced_qty_map.get(source_doc.name, 0)
|
||||
|
||||
@@ -18,13 +18,13 @@ class Item(WebsiteGenerator):
|
||||
from frappe.model.naming import make_autoname
|
||||
self.item_code = make_autoname(self.naming_series+'.#####')
|
||||
elif not self.item_code:
|
||||
msgprint(_("Item Code (item_code) is mandatory because Item naming is not sequential."), raise_exception=1)
|
||||
msgprint(_("Item Code is mandatory because Item is not automatically numbered"), raise_exception=1)
|
||||
|
||||
self.name = self.item_code
|
||||
|
||||
def validate(self):
|
||||
if not self.stock_uom:
|
||||
msgprint(_("Please enter Default Unit of Measure"), raise_exception=1)
|
||||
msgprint(_("Please enter default Unit of Measure"), raise_exception=1)
|
||||
|
||||
self.check_warehouse_is_set_for_stock_item()
|
||||
self.check_stock_uom_with_bin()
|
||||
@@ -51,7 +51,7 @@ class Item(WebsiteGenerator):
|
||||
|
||||
def check_warehouse_is_set_for_stock_item(self):
|
||||
if self.is_stock_item=="Yes" and not self.default_warehouse:
|
||||
frappe.msgprint(_("Default Warehouse is mandatory for Stock Item."),
|
||||
frappe.msgprint(_("Default Warehouse is mandatory for stock Item."),
|
||||
raise_exception=WarehouseNotSet)
|
||||
|
||||
def add_default_uom_in_conversion_factor_table(self):
|
||||
@@ -97,17 +97,12 @@ class Item(WebsiteGenerator):
|
||||
check_list = []
|
||||
for d in self.get('uom_conversion_details'):
|
||||
if cstr(d.uom) in check_list:
|
||||
msgprint(_("UOM %s has been entered more than once in Conversion Factor Table." %
|
||||
cstr(d.uom)), raise_exception=1)
|
||||
frappe.throw(_("Unit of Measure {0} has been entered more than once in Conversion Factor Table").format(d.uom))
|
||||
else:
|
||||
check_list.append(cstr(d.uom))
|
||||
|
||||
if d.uom and cstr(d.uom) == cstr(self.stock_uom) and flt(d.conversion_factor) != 1:
|
||||
msgprint(_("""Conversion Factor of UOM: %s should be equal to 1. As UOM: %s is Stock UOM of Item: %s.""" %
|
||||
(d.uom, d.uom, self.name)), raise_exception=1)
|
||||
elif d.uom and cstr(d.uom)!= self.stock_uom and flt(d.conversion_factor) == 1:
|
||||
msgprint(_("""Conversion Factor of UOM: %s should not be equal to 1. As UOM: %s is not Stock UOM of Item: %s""" %
|
||||
(d.uom, d.uom, self.name)), raise_exception=1)
|
||||
frappe.throw(_("Conversion factor for default Unit of Measure must be 1 in row {0}").format(d.idx))
|
||||
|
||||
def validate_item_type(self):
|
||||
if cstr(self.is_manufactured_item) == "No":
|
||||
@@ -118,7 +113,7 @@ class Item(WebsiteGenerator):
|
||||
it must be a stock item."))
|
||||
|
||||
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)
|
||||
|
||||
def check_for_active_boms(self):
|
||||
if self.is_purchase_item != "Yes":
|
||||
@@ -153,10 +148,10 @@ class Item(WebsiteGenerator):
|
||||
account_type = frappe.db.get_value("Account", d.tax_type, "account_type")
|
||||
|
||||
if account_type not in ['Tax', 'Chargeable', 'Income Account', 'Expense Account']:
|
||||
msgprint("'%s' is not Tax / Chargeable / Income / Expense Account" % d.tax_type, raise_exception=1)
|
||||
frappe.throw(_("Item Tax Row {0} must have account of type Tax or Income or Expense or Chargeable").format(d.idx))
|
||||
else:
|
||||
if d.tax_type in check_list:
|
||||
msgprint("Rate is entered twice for: '%s'" % d.tax_type, raise_exception=1)
|
||||
frappe.throw(_("{0} entered twice in Item Tax").format(d.tax_type))
|
||||
else:
|
||||
check_list.append(d.tax_type)
|
||||
|
||||
@@ -165,8 +160,7 @@ class Item(WebsiteGenerator):
|
||||
duplicate = frappe.db.sql("""select name from tabItem where barcode = %s
|
||||
and name != %s""", (self.barcode, self.name))
|
||||
if duplicate:
|
||||
msgprint("Barcode: %s already used in item: %s" %
|
||||
(self.barcode, cstr(duplicate[0][0])), raise_exception = 1)
|
||||
frappe.throw(_("Barcode {0} already used in Item {1}").format(self.barcode, duplicate[0][0]))
|
||||
|
||||
def cant_change(self):
|
||||
if not self.get("__islocal"):
|
||||
@@ -182,8 +176,7 @@ class Item(WebsiteGenerator):
|
||||
def validate_item_type_for_reorder(self):
|
||||
if self.re_order_level or len(self.get("item_reorder", {"material_request_type": "Purchase"})):
|
||||
if not self.is_purchase_item:
|
||||
frappe.msgprint(_("""To set reorder level, item must be Purchase Item"""),
|
||||
raise_exception=1)
|
||||
frappe.throw(_("""To set reorder level, item must be Purchase Item"""))
|
||||
|
||||
def check_if_sle_exists(self):
|
||||
sle = frappe.db.sql("""select name from `tabStock Ledger Entry`
|
||||
@@ -193,9 +186,7 @@ class Item(WebsiteGenerator):
|
||||
def validate_name_with_item_group(self):
|
||||
# causes problem with tree build
|
||||
if frappe.db.exists("Item Group", self.name):
|
||||
frappe.msgprint("An item group exists with same name (%s), \
|
||||
please change the item name or rename the item group" %
|
||||
self.name, raise_exception=1)
|
||||
frappe.throw(_("An Item Group exists with same name, please change the item name or rename the item group"))
|
||||
|
||||
def update_item_price(self):
|
||||
frappe.db.sql("""update `tabItem Price` set item_name=%s,
|
||||
@@ -269,14 +260,7 @@ def validate_end_of_life(item_code, end_of_life=None, verbose=1):
|
||||
end_of_life = frappe.db.get_value("Item", item_code, "end_of_life")
|
||||
|
||||
if end_of_life and getdate(end_of_life) <= now_datetime().date():
|
||||
msg = (_("Item") + " %(item_code)s: " + _("reached its end of life on") + \
|
||||
" %(date)s. " + _("Please check") + ": %(end_of_life_label)s " + \
|
||||
"in Item master") % {
|
||||
"item_code": item_code,
|
||||
"date": formatdate(end_of_life),
|
||||
"end_of_life_label": frappe.get_meta("Item").get_label("end_of_life")
|
||||
}
|
||||
|
||||
msg = _("Item {0} has reached its end of life on {1}").format(item_code, formatdate(end_of_life))
|
||||
_msgprint(msg, verbose)
|
||||
|
||||
def validate_is_stock_item(item_code, is_stock_item=None, verbose=1):
|
||||
@@ -284,9 +268,7 @@ def validate_is_stock_item(item_code, is_stock_item=None, verbose=1):
|
||||
is_stock_item = frappe.db.get_value("Item", item_code, "is_stock_item")
|
||||
|
||||
if is_stock_item != "Yes":
|
||||
msg = (_("Item") + " %(item_code)s: " + _("is not a Stock Item")) % {
|
||||
"item_code": item_code,
|
||||
}
|
||||
msg = _("Item {0} is not a stock Item").format(item_code)
|
||||
|
||||
_msgprint(msg, verbose)
|
||||
|
||||
@@ -295,10 +277,7 @@ def validate_cancelled_item(item_code, docstatus=None, verbose=1):
|
||||
docstatus = frappe.db.get_value("Item", item_code, "docstatus")
|
||||
|
||||
if docstatus == 2:
|
||||
msg = (_("Item") + " %(item_code)s: " + _("is a cancelled Item")) % {
|
||||
"item_code": item_code,
|
||||
}
|
||||
|
||||
msg = _("Item {0} is cancelled").format(item_code)
|
||||
_msgprint(msg, verbose)
|
||||
|
||||
def _msgprint(msg, verbose):
|
||||
|
||||
@@ -22,7 +22,7 @@ class LandedCostWizard(Document):
|
||||
self.cancel_pr(purchase_receipts)
|
||||
self.add_charges_in_pr(purchase_receipts)
|
||||
self.submit_pr(purchase_receipts)
|
||||
msgprint("Landed Cost updated successfully")
|
||||
msgprint(_("Landed Cost updated successfully"))
|
||||
|
||||
def validate_purchase_receipts(self, purchase_receipts):
|
||||
for pr in purchase_receipts:
|
||||
|
||||
@@ -114,7 +114,7 @@ class MaterialRequest(BuyingController):
|
||||
self.check_modified_date()
|
||||
self.update_bin(is_submit = (status == 'Submitted') and 1 or 0, is_stopped = 1)
|
||||
frappe.db.set(self, 'status', cstr(status))
|
||||
msgprint(self.doctype + ": " + self.name + " has been %s." % ((status == 'Submitted') and 'Unstopped' or cstr(status)))
|
||||
frappe.msgprint(_("Status updated to {0}").format(_(status)))
|
||||
|
||||
def on_cancel(self):
|
||||
# Step 1:=> Get Purchase Common Obj
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.utils import flt, cint
|
||||
from frappe import msgprint, _
|
||||
from frappe import _
|
||||
|
||||
from frappe.model.document import Document
|
||||
|
||||
@@ -32,12 +32,12 @@ class PackingSlip(Document):
|
||||
Validates if delivery note has status as draft
|
||||
"""
|
||||
if cint(frappe.db.get_value("Delivery Note", self.delivery_note, "docstatus")) != 0:
|
||||
msgprint(_("""Invalid Delivery Note. Delivery Note should exist and should be in draft state. Please rectify and try again."""), raise_exception=1)
|
||||
frappe.throw(_("Delivery Note {0} must not be submitted").format(self.delivery_note))
|
||||
|
||||
def validate_items_mandatory(self):
|
||||
rows = [d.item_code for d in self.get("item_details")]
|
||||
if not rows:
|
||||
frappe.msgprint(_("No Items to Pack"), raise_exception=1)
|
||||
frappe.msgprint(_("No Items to pack"), raise_exception=1)
|
||||
|
||||
def validate_case_nos(self):
|
||||
"""
|
||||
@@ -60,9 +60,7 @@ class PackingSlip(Document):
|
||||
""", self.as_dict())
|
||||
|
||||
if res:
|
||||
frappe.msgprint(_("""Case No(s) already in use. Please rectify and try again.
|
||||
Recommended <b>From Case No. = %s</b>""") % self.get_recommended_case_no(),
|
||||
raise_exception=1)
|
||||
frappe.throw(_("""Case No(s) already in use. Try from Case No {0}""").format(self.get_recommended_case_no()))
|
||||
|
||||
def validate_qty(self):
|
||||
"""
|
||||
@@ -118,11 +116,7 @@ class PackingSlip(Document):
|
||||
item['specified_qty'] = flt(ps_item_qty[item['item_code']])
|
||||
if not item['packed_qty']: item['packed_qty'] = 0
|
||||
|
||||
frappe.msgprint("""
|
||||
Invalid Quantity specified (%(specified_qty)s %(stock_uom)s).
|
||||
%(packed_qty)s out of %(qty)s %(stock_uom)s already packed for %(item_code)s.
|
||||
<b>Recommended quantity for %(item_code)s = %(recommended_qty)s
|
||||
%(stock_uom)s</b>""" % item, raise_exception=1)
|
||||
frappe.throw(_("Quantity for Item {0} must be less than {1}").format(item.get("item_code"), item.get("recommended_qty")))
|
||||
|
||||
def update_item_details(self):
|
||||
"""
|
||||
|
||||
@@ -6,7 +6,7 @@ import frappe
|
||||
|
||||
from frappe.utils import cstr, flt, cint
|
||||
|
||||
from frappe import msgprint, _
|
||||
from frappe import _
|
||||
import frappe.defaults
|
||||
from erpnext.stock.utils import update_bin
|
||||
|
||||
@@ -86,21 +86,18 @@ class PurchaseReceipt(BuyingController):
|
||||
|
||||
# Check Received Qty = Accepted Qty + Rejected Qty
|
||||
if ((flt(d.qty) + flt(d.rejected_qty)) != flt(d.received_qty)):
|
||||
|
||||
msgprint("Sum of Accepted Qty and Rejected Qty must be equal to Received quantity. Error for Item: " + cstr(d.item_code))
|
||||
raise Exception
|
||||
frappe.throw(_("Accepted + Rejected Qty must be equal to Received quantity for Item {0}").format(d.item_code))
|
||||
|
||||
|
||||
def validate_challan_no(self):
|
||||
"Validate if same challan no exists for same supplier in a submitted purchase receipt"
|
||||
if self.challan_no:
|
||||
exists = frappe.db.sql("""
|
||||
exists = frappe.db.sql_list("""
|
||||
SELECT name FROM `tabPurchase Receipt`
|
||||
WHERE name!=%s AND supplier=%s AND challan_no=%s
|
||||
AND docstatus=1""", (self.name, self.supplier, self.challan_no))
|
||||
if exists:
|
||||
frappe.msgprint("Another Purchase Receipt using the same Challan No. already exists.\
|
||||
Please enter a valid Challan No.", raise_exception=1)
|
||||
frappe.throw(_("Supplier delivery number duplicate in {0}").format(exists))
|
||||
|
||||
def validate_with_previous_doc(self):
|
||||
super(PurchaseReceipt, self).validate_with_previous_doc(self.tname, {
|
||||
@@ -129,8 +126,7 @@ class PurchaseReceipt(BuyingController):
|
||||
if frappe.db.get_value("Buying Settings", None, "po_required") == 'Yes':
|
||||
for d in self.get('purchase_receipt_details'):
|
||||
if not d.prevdoc_docname:
|
||||
msgprint("Purchse Order No. required against item %s"%d.item_code)
|
||||
raise Exception
|
||||
frappe.throw(_("Purchase Order number required for Item {0}").format(d.item_code))
|
||||
|
||||
def update_stock(self):
|
||||
sl_entries = []
|
||||
@@ -212,7 +208,7 @@ class PurchaseReceipt(BuyingController):
|
||||
(d.item_code,), as_dict = 1)
|
||||
ins_reqd = ins_reqd and ins_reqd[0]['inspection_required'] or 'No'
|
||||
if ins_reqd == 'Yes' and not d.qa_no:
|
||||
msgprint("Item: " + d.item_code + " requires QA Inspection. Please enter QA No or report to authorized person to create Quality Inspection")
|
||||
frappe.throw(_("Quality Inspection required for Item {0}").format(d.item_code))
|
||||
|
||||
# Check for Stopped status
|
||||
def check_for_stopped_status(self, pc_obj):
|
||||
@@ -251,9 +247,7 @@ class PurchaseReceipt(BuyingController):
|
||||
where t1.name = t2.parent and t2.purchase_receipt = %s and t1.docstatus = 1""",
|
||||
(self.name))
|
||||
if submit_rv:
|
||||
msgprint("Purchase Invoice : " + cstr(self.submit_rv[0][0]) + " has already been submitted !")
|
||||
raise Exception , "Validation Error."
|
||||
|
||||
frappe.throw(_("Purchase Invoice {0} is already submitted").format(self.submit_rv[0][0]))
|
||||
|
||||
def on_cancel(self):
|
||||
pc_obj = frappe.get_doc('Purchase Common')
|
||||
|
||||
@@ -290,7 +290,7 @@ def make_serial_no(serial_no, sle):
|
||||
sr.warehouse = sle.warehouse
|
||||
sr.status = "Available"
|
||||
sr.save()
|
||||
frappe.msgprint(_("Serial No created") + ": " + sr.name)
|
||||
frappe.msgprint(_("Serial No {0} created").format(sr.name))
|
||||
return sr.name
|
||||
|
||||
def update_serial_nos_after_submit(controller, parentfield):
|
||||
|
||||
@@ -7,7 +7,7 @@ import frappe.defaults
|
||||
|
||||
from frappe.utils import cstr, cint, flt, comma_or, nowdate
|
||||
|
||||
from frappe import msgprint, _
|
||||
from frappe import _
|
||||
from erpnext.stock.utils import get_incoming_rate
|
||||
from erpnext.stock.stock_ledger import get_previous_sle
|
||||
from erpnext.controllers.queries import get_match_cond
|
||||
@@ -67,15 +67,13 @@ class StockEntry(StockController):
|
||||
valid_purposes = ["Material Issue", "Material Receipt", "Material Transfer",
|
||||
"Manufacture/Repack", "Subcontract", "Sales Return", "Purchase Return"]
|
||||
if self.purpose not in valid_purposes:
|
||||
msgprint(_("Purpose must be one of ") + comma_or(valid_purposes),
|
||||
raise_exception=True)
|
||||
frappe.throw(_("Purpose must be one of {0}").format(comma_or(valid_purposes)))
|
||||
|
||||
def validate_item(self):
|
||||
stock_items = self.get_stock_items()
|
||||
for item in self.get("mtn_details"):
|
||||
if item.item_code not in stock_items:
|
||||
msgprint(_("""Only Stock Items are allowed for Stock Entry"""),
|
||||
raise_exception=True)
|
||||
frappe.throw(_("""Only Stock Items are allowed for Stock Entry"""))
|
||||
|
||||
def validate_warehouse(self, pro_obj):
|
||||
"""perform various (sometimes conditional) validations on warehouse"""
|
||||
@@ -100,15 +98,13 @@ class StockEntry(StockController):
|
||||
d.t_warehouse = self.to_warehouse
|
||||
|
||||
if not (d.s_warehouse or d.t_warehouse):
|
||||
msgprint(_("Atleast one warehouse is mandatory"), raise_exception=1)
|
||||
frappe.throw(_("Atleast one warehouse is mandatory"))
|
||||
|
||||
if self.purpose in source_mandatory and not d.s_warehouse:
|
||||
msgprint(_("Row # ") + "%s: " % cint(d.idx)
|
||||
+ _("Source Warehouse") + _(" is mandatory"), raise_exception=1)
|
||||
frappe.throw(_("Source warehouse is mandatory for row {0}").format(d.idx))
|
||||
|
||||
if self.purpose in target_mandatory and not d.t_warehouse:
|
||||
msgprint(_("Row # ") + "%s: " % cint(d.idx)
|
||||
+ _("Target Warehouse") + _(" is mandatory"), raise_exception=1)
|
||||
frappe.throw(_("Target warehouse is mandatory for row {0}").format(d.idx))
|
||||
|
||||
if self.purpose == "Manufacture/Repack":
|
||||
if validate_for_manufacture_repack:
|
||||
@@ -116,23 +112,18 @@ class StockEntry(StockController):
|
||||
d.s_warehouse = None
|
||||
|
||||
if not d.t_warehouse:
|
||||
msgprint(_("Row # ") + "%s: " % cint(d.idx)
|
||||
+ _("Target Warehouse") + _(" is mandatory"), raise_exception=1)
|
||||
frappe.throw(_("Target warehouse is mandatory for row {0}").format(d.idx))
|
||||
|
||||
elif pro_obj and cstr(d.t_warehouse) != pro_obj.fg_warehouse:
|
||||
msgprint(_("Row # ") + "%s: " % cint(d.idx)
|
||||
+ _("Target Warehouse") + _(" should be same as that in ")
|
||||
+ _("Production Order"), raise_exception=1)
|
||||
frappe.throw(_("Target warehouse in row {0} must be same as Production Order").format(d.idx))
|
||||
|
||||
else:
|
||||
d.t_warehouse = None
|
||||
if not d.s_warehouse:
|
||||
msgprint(_("Row # ") + "%s: " % cint(d.idx)
|
||||
+ _("Source Warehouse") + _(" is mandatory"), raise_exception=1)
|
||||
frappe.throw(_("Source warehouse is mandatory for row {0}").format(d.idx))
|
||||
|
||||
if cstr(d.s_warehouse) == cstr(d.t_warehouse):
|
||||
msgprint(_("Source and Target Warehouse cannot be same"),
|
||||
raise_exception=1)
|
||||
frappe.throw(_("Source and target warehouse cannot be same for row {0}").format(d.idx))
|
||||
|
||||
def validate_production_order(self, pro_obj=None):
|
||||
if not pro_obj:
|
||||
@@ -228,17 +219,13 @@ class StockEntry(StockController):
|
||||
if d.bom_no and not frappe.db.sql("""select name from `tabBOM`
|
||||
where item = %s and name = %s and docstatus = 1 and is_active = 1""",
|
||||
(d.item_code, d.bom_no)):
|
||||
msgprint(_("Item") + " %s: " % cstr(d.item_code)
|
||||
+ _("does not belong to BOM: ") + cstr(d.bom_no)
|
||||
+ _(" or the BOM is cancelled or inactive"), raise_exception=1)
|
||||
frappe.throw(_("BOM {0} is not submitted or inactive BOM for Item {1}").format(d.bom_no, d.item_code))
|
||||
|
||||
def validate_finished_goods(self):
|
||||
"""validation: finished good quantity should be same as manufacturing quantity"""
|
||||
import json
|
||||
for d in self.get('mtn_details'):
|
||||
if d.bom_no and flt(d.transfer_qty) != flt(self.fg_completed_qty):
|
||||
msgprint(_("Row #") + " %s: " % d.idx
|
||||
+ _("Quantity should be equal to Manufacturing Quantity. To fetch items again, click on 'Get Items' button or update the Quantity manually."), raise_exception=1)
|
||||
frappe.throw(_("Quantity in row {0} must be same as manufactured quantity").format(d.idx))
|
||||
|
||||
def validate_return_reference_doc(self):
|
||||
"""validate item with reference doc"""
|
||||
@@ -247,14 +234,12 @@ class StockEntry(StockController):
|
||||
if ref.doc:
|
||||
# validate docstatus
|
||||
if ref.doc.docstatus != 1:
|
||||
frappe.msgprint(_(ref.doc.doctype) + ' "' + ref.doc.name + '": '
|
||||
+ _("Status should be Submitted"), raise_exception=frappe.InvalidStatusError)
|
||||
frappe.throw(_("{0} {1} must be submitted").format(ref.doc.doctype, ref.doc.name),
|
||||
frappe.InvalidStatusError)
|
||||
|
||||
# update stock check
|
||||
if ref.doc.doctype == "Sales Invoice" and cint(ref.doc.update_stock) != 1:
|
||||
frappe.msgprint(_(ref.doc.doctype) + ' "' + ref.doc.name + '": '
|
||||
+ _("Update Stock should be checked."),
|
||||
raise_exception=NotUpdateStockError)
|
||||
frappe.throw(_("'Update Stock' for Sales Invoice {0} must be set").format(ref.doc.name), NotUpdateStockError)
|
||||
|
||||
# posting date check
|
||||
ref_posting_datetime = "%s %s" % (cstr(ref.doc.posting_date),
|
||||
@@ -263,9 +248,7 @@ class StockEntry(StockController):
|
||||
cstr(self.posting_time))
|
||||
if this_posting_datetime < ref_posting_datetime:
|
||||
from frappe.utils.dateutils import datetime_in_user_format
|
||||
frappe.msgprint(_("Posting Date Time cannot be before")
|
||||
+ ": " + datetime_in_user_format(ref_posting_datetime),
|
||||
raise_exception=True)
|
||||
frappe.throw(_("Posting timestamp must be after {0}").format(datetime_in_user_format(ref_posting_datetime)))
|
||||
|
||||
stock_items = get_stock_items_for_return(ref.doc, ref.parentfields)
|
||||
already_returned_item_qty = self.get_already_returned_item_qty(ref.fieldname)
|
||||
@@ -273,9 +256,8 @@ class StockEntry(StockController):
|
||||
for item in self.get("mtn_details"):
|
||||
# validate if item exists in the ref doc and that it is a stock item
|
||||
if item.item_code not in stock_items:
|
||||
msgprint(_("Item") + ': "' + item.item_code + _("\" does not exist in ") +
|
||||
ref.doc.doctype + ": " + ref.doc.name,
|
||||
raise_exception=frappe.DoesNotExistError)
|
||||
frappe.throw(_("Item {0} does not exist in {1} {2}").format(item.item_code, ref.doc.doctype, ref.doc.name),
|
||||
frappe.DoesNotExistError)
|
||||
|
||||
# validate quantity <= ref item's qty - qty already returned
|
||||
ref_item = ref.doc.getone({"item_code": item.item_code})
|
||||
@@ -328,12 +310,10 @@ class StockEntry(StockController):
|
||||
def update_production_order(self):
|
||||
def _validate_production_order(pro_doc):
|
||||
if flt(pro_doc.docstatus) != 1:
|
||||
frappe.throw(_("Production Order must be submitted") + ": " +
|
||||
self.production_order)
|
||||
frappe.throw(_("Production Order {0} must be submitted").format(self.production_order))
|
||||
|
||||
if pro_doc.status == 'Stopped':
|
||||
msgprint(_("Transaction not allowed against stopped Production Order") + ": " +
|
||||
self.production_order)
|
||||
frappe.throw(_("Transaction not allowed against stopped Production Order {0}").format(self.production_order))
|
||||
|
||||
if self.production_order:
|
||||
pro_doc = frappe.get_doc("Production Order", self.production_order)
|
||||
@@ -372,7 +352,7 @@ class StockEntry(StockController):
|
||||
where name = %s and (ifnull(end_of_life,'')='' or end_of_life > now())""",
|
||||
(arg.get('item_code')), as_dict = 1)
|
||||
if not item:
|
||||
msgprint("Item is not active", raise_exception=1)
|
||||
frappe.throw(_("Item {0} is not active or end of life has been reached").format(arg.get("item_code")))
|
||||
|
||||
ret = {
|
||||
'uom' : item and item[0]['stock_uom'] or '',
|
||||
@@ -398,8 +378,7 @@ class StockEntry(StockController):
|
||||
uom = frappe.db.sql("""select conversion_factor from `tabUOM Conversion Detail`
|
||||
where parent = %s and uom = %s""", (arg['item_code'], arg['uom']), as_dict = 1)
|
||||
if not uom or not flt(uom[0].conversion_factor):
|
||||
msgprint("There is no Conversion Factor for UOM '%s' in Item '%s'" % (arg['uom'],
|
||||
arg['item_code']))
|
||||
frappe.msgprint(_("UOM coversion factor required for UOM {0} in Item {1}").format(arg["uom"], arg["item_code"]))
|
||||
ret = {'uom' : ''}
|
||||
else:
|
||||
ret = {
|
||||
@@ -531,12 +510,10 @@ class StockEntry(StockController):
|
||||
|
||||
# show some message
|
||||
if not len(item_dict):
|
||||
frappe.msgprint(_("""All items have already been transferred \
|
||||
for this Production Order."""))
|
||||
frappe.msgprint(_("""All items have already been transferred for this Production Order."""))
|
||||
|
||||
elif only_pending_fetched:
|
||||
frappe.msgprint(_("""Only quantities pending to be transferred \
|
||||
were fetched for the following items:\n""" + "\n".join(only_pending_fetched)))
|
||||
frappe.msgprint(_("Pending Items {0} updated").format(only_pending_fetched))
|
||||
|
||||
return item_dict
|
||||
|
||||
@@ -589,10 +566,8 @@ class StockEntry(StockController):
|
||||
{"name": item.material_request_item, "parent": item.material_request},
|
||||
["item_code", "warehouse", "idx"], as_dict=True)
|
||||
if mreq_item.item_code != item.item_code or mreq_item.warehouse != item.t_warehouse:
|
||||
msgprint(_("Row #") + (" %d: " % item.idx) + _("does not match")
|
||||
+ " " + _("Row #") + (" %d %s " % (mreq_item.idx, _("of")))
|
||||
+ _("Material Request") + (" - %s" % item.material_request),
|
||||
raise_exception=frappe.MappingMismatchError)
|
||||
frappe.throw(_("Item or Warehouse for row {0} does not match Material Request").format(item.idx),
|
||||
frappe.MappingMismatchError)
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_party_details(ref_dt, ref_dn):
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
from frappe import msgprint
|
||||
from frappe import _
|
||||
from frappe.utils import cint, flt, cstr, now
|
||||
from erpnext.stock.utils import get_valuation_method
|
||||
import json
|
||||
@@ -309,17 +309,11 @@ def get_fifo_values(qty_after_transaction, sle, stock_queue):
|
||||
|
||||
def _raise_exceptions(args, verbose=1):
|
||||
deficiency = min(e["diff"] for e in _exceptions)
|
||||
msg = """Negative stock error:
|
||||
Cannot complete this transaction because stock will start
|
||||
becoming negative (%s) for Item <b>%s</b> in Warehouse
|
||||
<b>%s</b> on <b>%s %s</b> in Transaction %s %s.
|
||||
Total Quantity Deficiency: <b>%s</b>""" % \
|
||||
(_exceptions[0]["diff"], args.get("item_code"), args.get("warehouse"),
|
||||
_exceptions[0]["posting_date"], _exceptions[0]["posting_time"],
|
||||
_exceptions[0]["voucher_type"], _exceptions[0]["voucher_no"],
|
||||
abs(deficiency))
|
||||
msg = _("Negative Stock Error ({6}) for Item {0} in Warehouse {1} on {2} {3} in {4} {5}").format(args["item_code"],
|
||||
args.get("warehouse"), _exceptions[0]["posting_date"], _exceptions[0]["posting_time"],
|
||||
_(_exceptions[0]["voucher_type"]), _exceptions[0]["voucher_no"], deficiency)
|
||||
if verbose:
|
||||
msgprint(msg, raise_exception=NegativeStockError)
|
||||
frappe.throw(msg, NegativeStockError)
|
||||
else:
|
||||
raise NegativeStockError, msg
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
|
||||
import frappe
|
||||
from frappe import msgprint, _
|
||||
from frappe import _
|
||||
import json
|
||||
from frappe.utils import flt, cstr, nowdate, add_days, cint
|
||||
from frappe.defaults import get_global_default
|
||||
@@ -58,8 +58,7 @@ def update_bin(args):
|
||||
bin.update_stock(args)
|
||||
return bin
|
||||
else:
|
||||
msgprint("[Stock Update] Ignored %s since it is not a stock item"
|
||||
% args.get("item_code"))
|
||||
frappe.msgprint(_("Item {0} ignored since it is not a stock item").format(args.get("item_code")))
|
||||
|
||||
def get_incoming_rate(args):
|
||||
"""Get Incoming Rate based on valuation method"""
|
||||
@@ -134,22 +133,20 @@ def get_valid_serial_nos(sr_nos, qty=0, item_code=''):
|
||||
if val:
|
||||
val = val.strip()
|
||||
if val in valid_serial_nos:
|
||||
msgprint("You have entered duplicate serial no: '%s'" % val, raise_exception=1)
|
||||
frappe.throw(_("Serial number {0} entered more than once").format(val))
|
||||
else:
|
||||
valid_serial_nos.append(val)
|
||||
|
||||
if qty and len(valid_serial_nos) != abs(qty):
|
||||
msgprint("Please enter serial nos for "
|
||||
+ cstr(abs(qty)) + " quantity against item code: " + item_code,
|
||||
raise_exception=1)
|
||||
frappe.throw(_("{0} valid serial nos for Item {1}").format(abs(qty), item_code))
|
||||
|
||||
return valid_serial_nos
|
||||
|
||||
def validate_warehouse_company(warehouse, company):
|
||||
warehouse_company = frappe.db.get_value("Warehouse", warehouse, "company")
|
||||
if warehouse_company and warehouse_company != company:
|
||||
frappe.msgprint(_("Warehouse does not belong to company.") + " (" + \
|
||||
warehouse + ", " + company +")", raise_exception=InvalidWarehouseCompany)
|
||||
frappe.throw(_("Warehouse {0} does not belong to company {1}").format(warehouse, company),
|
||||
InvalidWarehouseCompany)
|
||||
|
||||
def get_sales_bom_buying_amount(item_code, warehouse, voucher_type, voucher_no, voucher_detail_no,
|
||||
stock_ledger_entries, item_sales_bom):
|
||||
|
||||
Reference in New Issue
Block a user