diff --git a/erpnext/accounts/doctype/accounting_period/accounting_period.py b/erpnext/accounts/doctype/accounting_period/accounting_period.py index f7190b75e2..de45f3a252 100644 --- a/erpnext/accounts/doctype/accounting_period/accounting_period.py +++ b/erpnext/accounts/doctype/accounting_period/accounting_period.py @@ -5,6 +5,7 @@ from __future__ import unicode_literals import frappe from frappe.model.document import Document +from frappe import _ class AccountingPeriod(Document): def validate(self): @@ -16,7 +17,7 @@ class AccountingPeriod(Document): def autoname(self): company_abbr = frappe.get_cached_value('Company', self.company, "abbr") self.name = " - ".join([self.period_name, company_abbr]) - + def validate_overlap(self): existing_accounting_period = frappe.db.sql("""select name from `tabAccounting Period` where ( @@ -33,7 +34,7 @@ class AccountingPeriod(Document): }, as_dict=True) if len(existing_accounting_period) > 0: - frappe.throw("Accounting Period overlaps with {0}".format(existing_accounting_period[0].get("name"))) + frappe.throw(_("Accounting Period overlaps with {0}".format(existing_accounting_period[0].get("name")))) def get_doctypes_for_closing(self): docs_for_closing = [] diff --git a/erpnext/accounts/doctype/bank_statement_transaction_entry/bank_statement_transaction_entry.py b/erpnext/accounts/doctype/bank_statement_transaction_entry/bank_statement_transaction_entry.py index 101b9f2194..1318cf18d7 100644 --- a/erpnext/accounts/doctype/bank_statement_transaction_entry/bank_statement_transaction_entry.py +++ b/erpnext/accounts/doctype/bank_statement_transaction_entry/bank_statement_transaction_entry.py @@ -48,7 +48,7 @@ class BankStatementTransactionEntry(Document): def get_statement_headers(self): if not self.bank_settings: - frappe.throw("Bank Data mapper doesn't exist") + frappe.throw(_("Bank Data mapper doesn't exist")) mapper_doc = frappe.get_doc("Bank Statement Settings", self.bank_settings) headers = {entry.mapped_header:entry.stmt_header for entry in mapper_doc.header_items} return headers @@ -57,7 +57,7 @@ class BankStatementTransactionEntry(Document): if self.bank_statement is None: return filename = self.bank_statement.split("/")[-1] if (len(self.new_transaction_items + self.reconciled_transaction_items) > 0): - frappe.throw("Transactions already retreived from the statement") + frappe.throw(_("Transactions already retreived from the statement")) date_format = frappe.get_value("Bank Statement Settings", self.bank_settings, "date_format") if (date_format is None): @@ -314,7 +314,7 @@ class BankStatementTransactionEntry(Document): try: reconcile_against_document(lst) except: - frappe.throw("Exception occurred while reconciling {0}".format(payment.reference_name)) + frappe.throw(_("Exception occurred while reconciling {0}".format(payment.reference_name))) def submit_payment_entries(self): for payment in self.new_transaction_items: @@ -414,7 +414,7 @@ def get_transaction_entries(filename, headers): elif (filename.lower().endswith("xls")): rows = get_rows_from_xls_file(filename) else: - frappe.throw("Only .csv and .xlsx files are supported currently") + frappe.throw(_("Only .csv and .xlsx files are supported currently")) stmt_headers = headers.values() for row in rows: diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index dd4f51ca4e..f4b656d3f6 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -157,7 +157,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ can_change_release_date: function(date) { const diff = frappe.datetime.get_diff(date, frappe.datetime.nowdate()); if (diff < 0) { - frappe.throw('New release date should be in the future'); + frappe.throw(__('New release date should be in the future')); return false; } else { return true; diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 1bd833b5ce..a6f6acea66 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -105,7 +105,7 @@ class PurchaseInvoice(BuyingController): def validate_release_date(self): if self.release_date and getdate(nowdate()) >= getdate(self.release_date): - frappe.msgprint('Release date must be in the future', raise_exception=True) + frappe.throw(_('Release date must be in the future')) def validate_cash(self): if not self.cash_bank_account and flt(self.paid_amount): diff --git a/erpnext/accounts/doctype/subscription_plan/subscription_plan.py b/erpnext/accounts/doctype/subscription_plan/subscription_plan.py index d3fef6023b..625979bee1 100644 --- a/erpnext/accounts/doctype/subscription_plan/subscription_plan.py +++ b/erpnext/accounts/doctype/subscription_plan/subscription_plan.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe +from frappe import _ from frappe.model.document import Document from erpnext.utilities.product import get_price @@ -13,7 +14,7 @@ class SubscriptionPlan(Document): def validate_interval_count(self): if self.billing_interval_count < 1: - frappe.throw('Billing Interval Count cannot be less than 1') + frappe.throw(_('Billing Interval Count cannot be less than 1')) @frappe.whitelist() def get_plan_rate(plan, quantity=1, customer=None): @@ -26,7 +27,7 @@ def get_plan_rate(plan, quantity=1, customer=None): customer_group = frappe.db.get_value("Customer", customer, "customer_group") else: customer_group = None - + price = get_price(item_code=plan.item, price_list=plan.price_list, customer_group=customer_group, company=None, qty=quantity) if not price: return 0 diff --git a/erpnext/controllers/item_variant.py b/erpnext/controllers/item_variant.py index 9152c316cf..669aa9be7e 100644 --- a/erpnext/controllers/item_variant.py +++ b/erpnext/controllers/item_variant.py @@ -176,7 +176,7 @@ def enqueue_multiple_variant_creation(item, args): for key in variants: total_variants *= len(variants[key]) if total_variants >= 600: - frappe.msgprint("Please do not create more than 500 items at a time", raise_exception=1) + frappe.throw(_("Please do not create more than 500 items at a time")) return if total_variants < 10: return create_multiple_variants(item, args) diff --git a/erpnext/education/doctype/question/question.py b/erpnext/education/doctype/question/question.py index b8221081fa..9a973c7615 100644 --- a/erpnext/education/doctype/question/question.py +++ b/erpnext/education/doctype/question/question.py @@ -38,7 +38,7 @@ class Question(Document): options = self.options answers = [item.name for item in options if item.is_correct == True] if len(answers) == 0: - frappe.throw("No correct answer is set for {0}".format(self.name)) + frappe.throw(_("No correct answer is set for {0}".format(self.name))) return None elif len(answers) == 1: return answers[0] diff --git a/erpnext/education/doctype/quiz/quiz.py b/erpnext/education/doctype/quiz/quiz.py index 8e54745464..ae1cb6ce42 100644 --- a/erpnext/education/doctype/quiz/quiz.py +++ b/erpnext/education/doctype/quiz/quiz.py @@ -4,12 +4,13 @@ from __future__ import unicode_literals import frappe +from frappe import _ from frappe.model.document import Document class Quiz(Document): def validate(self): if self.passing_score > 100: - frappe.throw("Passing Score value should be between 0 and 100") + frappe.throw(_("Passing Score value should be between 0 and 100")) def allowed_attempt(self, enrollment, quiz_name): if self.max_attempts == 0: @@ -17,7 +18,7 @@ class Quiz(Document): try: if len(frappe.get_all("Quiz Activity", {'enrollment': enrollment.name, 'quiz': quiz_name})) >= self.max_attempts: - frappe.msgprint("Maximum attempts for this quiz reached!") + frappe.msgprint(_("Maximum attempts for this quiz reached!")) return False else: return True @@ -56,5 +57,5 @@ def compare_list_elementwise(*args): else: return False except TypeError: - frappe.throw("Compare List function takes on list arguments") + frappe.throw(_("Compare List function takes on list arguments")) diff --git a/erpnext/education/doctype/student_report_generation_tool/student_report_generation_tool.py b/erpnext/education/doctype/student_report_generation_tool/student_report_generation_tool.py index f9979752f7..16933dcfe0 100644 --- a/erpnext/education/doctype/student_report_generation_tool/student_report_generation_tool.py +++ b/erpnext/education/doctype/student_report_generation_tool/student_report_generation_tool.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe, json +from frappe import _ from frappe.model.document import Document from erpnext.education.api import get_grade from frappe.utils.pdf import get_pdf @@ -79,7 +80,7 @@ def get_attendance_count(student, academic_year, academic_term=None): from_date, to_date = frappe.db.get_value("Academic Term", academic_term, ["term_start_date", "term_end_date"]) if from_date and to_date: attendance = dict(frappe.db.sql('''select status, count(student) as no_of_days - from `tabStudent Attendance` where student = %s + from `tabStudent Attendance` where student = %s and date between %s and %s group by status''', (student, from_date, to_date))) if "Absent" not in attendance.keys(): @@ -88,4 +89,4 @@ def get_attendance_count(student, academic_year, academic_term=None): attendance["Present"] = 0 return attendance else: - frappe.throw("Provide the academic year and set the starting and ending date.") \ No newline at end of file + frappe.throw(_("Provide the academic year and set the starting and ending date.")) \ No newline at end of file diff --git a/erpnext/education/utils.py b/erpnext/education/utils.py index 8cd5bbb95b..e0b278c2b1 100644 --- a/erpnext/education/utils.py +++ b/erpnext/education/utils.py @@ -148,7 +148,7 @@ def enroll_in_program(program_name, student=None): # Check if self enrollment in allowed program = frappe.get_doc('Program', program_name) if not program.allow_self_enroll: - return frappe.throw("You are not allowed to enroll for this course") + return frappe.throw(_("You are not allowed to enroll for this course")) student = get_current_student() if not student: @@ -162,7 +162,7 @@ def enroll_in_program(program_name, student=None): # Check if self enrollment in allowed program = frappe.get_doc('Program', program_name) if not program.allow_self_enroll: - return frappe.throw("You are not allowed to enroll for this course") + return frappe.throw(_("You are not allowed to enroll for this course")) # Enroll in program program_enrollment = student.enroll_in_program(program_name) @@ -185,7 +185,7 @@ def add_activity(course, content_type, content, program): student = get_current_student() if not student: - return frappe.throw("Student with email {0} does not exist".format(frappe.session.user), frappe.DoesNotExistError) + return frappe.throw(_("Student with email {0} does not exist".format(frappe.session.user)), frappe.DoesNotExistError) enrollment = get_or_create_course_enrollment(course, program) if content_type == 'Quiz': @@ -220,7 +220,7 @@ def get_quiz(quiz_name, course): quiz = frappe.get_doc("Quiz", quiz_name) questions = quiz.get_questions() except: - frappe.throw("Quiz {0} does not exist".format(quiz_name)) + frappe.throw(_("Quiz {0} does not exist".format(quiz_name))) return None questions = [{ @@ -347,7 +347,7 @@ def get_or_create_course_enrollment(course, program): if not course_enrollment: program_enrollment = get_enrollment('program', program, student.name) if not program_enrollment: - frappe.throw("You are not enrolled in program {0}".format(program)) + frappe.throw(_("You are not enrolled in program {0}".format(program))) return return student.enroll_in_course(course_name=course, program_enrollment=get_enrollment('program', program, student.name)) else: diff --git a/erpnext/erpnext_integrations/connectors/shopify_connection.py b/erpnext/erpnext_integrations/connectors/shopify_connection.py index 88078ab74f..1d6e8917f5 100644 --- a/erpnext/erpnext_integrations/connectors/shopify_connection.py +++ b/erpnext/erpnext_integrations/connectors/shopify_connection.py @@ -124,7 +124,7 @@ def create_sales_order(shopify_order, shopify_settings, company=None): else: so = frappe.get_doc("Sales Order", so) - + frappe.db.commit() return so @@ -252,6 +252,6 @@ def get_tax_account_head(tax): {"parent": "Shopify Settings", "shopify_tax": tax_title}, "tax_account") if not tax_account: - frappe.throw("Tax Account not specified for Shopify Tax {0}".format(tax.get("title"))) + frappe.throw(_("Tax Account not specified for Shopify Tax {0}".format(tax.get("title")))) return tax_account diff --git a/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template.py b/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template.py index 90bf95770f..141329b3db 100644 --- a/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template.py +++ b/erpnext/healthcare/doctype/clinical_procedure_template/clinical_procedure_template.py @@ -30,7 +30,7 @@ class ClinicalProcedureTemplate(Document): try: frappe.delete_doc("Item",self.item) except Exception: - frappe.throw("""Not permitted. Please disable the Procedure Template""") + frappe.throw(_("""Not permitted. Please disable the Procedure Template""")) def get_item_details(self, args=None): item = frappe.db.sql("""select stock_uom, item_name diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js index 2f328de1bc..b3cbd1f753 100644 --- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js +++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js @@ -298,7 +298,7 @@ var get_procedure_prescribed = function(frm){ }); } else{ - frappe.msgprint("Please select Patient to get prescribed procedure"); + frappe.msgprint(__("Please select Patient to get prescribed procedure")); } }; diff --git a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js index c7df5b7cd9..7ea45688fd 100644 --- a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js +++ b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js @@ -160,7 +160,7 @@ var btn_create_vital_signs = function (frm) { var btn_create_procedure = function (frm) { if(!frm.doc.patient){ - frappe.throw("Please select patient"); + frappe.throw(__("Please select patient")); } frappe.route_options = { "patient": frm.doc.patient, diff --git a/erpnext/hr/doctype/employee_benefit_claim/employee_benefit_claim.py b/erpnext/hr/doctype/employee_benefit_claim/employee_benefit_claim.py index 3a80b30365..abb82f2cdd 100644 --- a/erpnext/hr/doctype/employee_benefit_claim/employee_benefit_claim.py +++ b/erpnext/hr/doctype/employee_benefit_claim/employee_benefit_claim.py @@ -84,7 +84,7 @@ def get_benefit_pro_rata_ratio_amount(employee, on_date, sal_struct): pay_against_benefit_claim, max_benefit_amount = frappe.db.get_value("Salary Component", sal_struct_row.salary_component, ["pay_against_benefit_claim", "max_benefit_amount"]) except TypeError: # show the error in tests? - frappe.throw("Unable to find Salary Component {0}".format(sal_struct_row.salary_component)) + frappe.throw(_("Unable to find Salary Component {0}".format(sal_struct_row.salary_component))) if sal_struct_row.is_flexible_benefit == 1 and pay_against_benefit_claim != 1: total_pro_rata_max += max_benefit_amount if total_pro_rata_max > 0: diff --git a/erpnext/hr/doctype/hr_settings/hr_settings.js b/erpnext/hr/doctype/hr_settings/hr_settings.js index d8be46bee7..9e5effe6a3 100644 --- a/erpnext/hr/doctype/hr_settings/hr_settings.js +++ b/erpnext/hr/doctype/hr_settings/hr_settings.js @@ -15,7 +15,7 @@ frappe.ui.form.on('HR Settings', { let policy = frm.doc.password_policy; if (policy) { if (policy.includes(' ') || policy.includes('--')) { - frappe.msgprint("Password policy cannot contain spaces or simultaneous hyphens. The format will be restructured automatically"); + frappe.msgprint(_("Password policy cannot contain spaces or simultaneous hyphens. The format will be restructured automatically")); } frm.set_value('password_policy', policy.split(new RegExp(" |-", 'g')).filter((token) => token).join('-')); } diff --git a/erpnext/hub_node/api.py b/erpnext/hub_node/api.py index 0c94df3159..0d01c67650 100644 --- a/erpnext/hub_node/api.py +++ b/erpnext/hub_node/api.py @@ -120,7 +120,7 @@ def get_valid_items(search_value=''): def publish_selected_items(items_to_publish): items_to_publish = json.loads(items_to_publish) if not len(items_to_publish): - frappe.throw('No items to publish') + frappe.throw(_('No items to publish')) for item in items_to_publish: item_code = item.get('item_code') @@ -165,7 +165,7 @@ def item_sync_preprocess(intended_item_publish_count): frappe.db.set_value("Marketplace Settings", "Marketplace Settings", "sync_in_progress", 1) return response else: - frappe.throw('Unable to update remote activity') + frappe.throw(_('Unable to update remote activity')) def item_sync_postprocess(): @@ -173,7 +173,7 @@ def item_sync_postprocess(): if response: frappe.db.set_value('Marketplace Settings', 'Marketplace Settings', 'last_sync_datetime', frappe.utils.now()) else: - frappe.throw('Unable to update remote activity') + frappe.throw(_('Unable to update remote activity')) frappe.db.set_value('Marketplace Settings', 'Marketplace Settings', 'sync_in_progress', 0) diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py index ded1e5388c..55a689259a 100644 --- a/erpnext/projects/doctype/project/project.py +++ b/erpnext/projects/doctype/project/project.py @@ -645,7 +645,7 @@ def set_project_status(project, status): set status for project and all related tasks ''' if not status in ('Completed', 'Cancelled'): - frappe.throw('Status must be Cancelled or Completed') + frappe.throw(_('Status must be Cancelled or Completed')) project = frappe.get_doc('Project', project) frappe.has_permission(doc = project, throw = True) diff --git a/erpnext/public/js/education/lms/quiz.js b/erpnext/public/js/education/lms/quiz.js index 1b520eb9f5..52481291e0 100644 --- a/erpnext/public/js/education/lms/quiz.js +++ b/erpnext/public/js/education/lms/quiz.js @@ -68,7 +68,7 @@ class Quiz { }).then(res => { this.submit_btn.remove() if (!res.message) { - frappe.throw("Something went wrong while evaluating the quiz.") + frappe.throw(__("Something went wrong while evaluating the quiz.")) } let indicator = 'red' diff --git a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py index 448abe8f28..aad267e90a 100644 --- a/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py +++ b/erpnext/regional/doctype/gstr_3b_report/gstr_3b_report.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe +from frappe import _ from frappe.model.document import Document import json from six import iteritems @@ -414,7 +415,7 @@ class GSTR3BReport(Document): if gst_details: return gst_details[0] else: - frappe.throw("Please enter GSTIN and state for the Company Address {0}".format(self.company_address)) + frappe.throw(_("Please enter GSTIN and state for the Company Address {0}".format(self.company_address))) def get_account_heads(self): @@ -427,7 +428,7 @@ class GSTR3BReport(Document): if account_heads: return account_heads else: - frappe.throw("Please set account heads in GST Settings for Compnay {0}".format(self.company)) + frappe.throw(_("Please set account heads in GST Settings for Compnay {0}".format(self.company))) def get_missing_field_invoices(self):