From e6d65bc2a1ee73a23299268ffc5de3c0f51bd1d7 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 14 Feb 2018 17:44:06 +0530 Subject: [PATCH] Fixed translations and tests (#12900) * Fixed translations and tests * minor fixes * minor test fixes --- .../bank_reconciliation.py | 2 +- .../doctype/share_transfer/share_transfer.py | 38 +++++---- .../doctype/share_transfer/test_records.json | 76 ----------------- .../share_transfer/test_share_transfer.py | 82 +++++++++++++++++-- .../doctype/shareholder/shareholder.json | 5 +- .../doctype/shareholder/test_records.json | 15 ++-- erpnext/agriculture/doctype/crop/crop.py | 3 +- .../doctype/crop_cycle/crop_cycle.py | 3 +- .../agriculture/doctype/disease/disease.py | 3 +- .../doctype/soil_texture/soil_texture.py | 5 +- .../doctype/water_analysis/water_analysis.py | 5 +- .../quoted_item_comparison.js | 2 +- .../crm/doctype/opportunity/opportunity.py | 2 +- erpnext/education/api.py | 2 +- .../assessment_criteria.py | 3 +- .../doctype/instructor/instructor.py | 2 +- .../program_enrollment_tool.py | 2 +- .../doctype/consultation/consultation.js | 6 +- .../doctype/consultation/consultation.py | 2 +- .../healthcare_settings.py | 3 +- .../healthcare/doctype/lab_test/lab_test.js | 10 +-- .../lab_test_template/lab_test_template.py | 2 +- erpnext/healthcare/doctype/patient/patient.js | 6 +- erpnext/healthcare/doctype/patient/patient.py | 5 +- .../patient_appointment.js | 2 +- .../doctype/hotel_room/test_hotel_room.py | 2 +- .../test_hotel_room_pricing.py | 2 +- .../test_hotel_room_reservation.py | 2 +- .../hr/doctype/expense_claim/expense_claim.js | 2 +- .../test_leave_application.py | 4 - .../hr/doctype/payroll_entry/payroll_entry.py | 6 +- .../doctype/hub_settings/hub_settings.js | 2 +- erpnext/patches.txt | 2 +- .../added_extra_gst_custom_field_in_gstr2.py | 11 ++- .../repost_bin_qty_and_item_projected_qty.py | 1 - erpnext/public/js/controllers/accounts.js | 2 +- erpnext/public/js/controllers/buying.js | 8 +- erpnext/public/js/setup_wizard.js | 2 +- .../doctype/gst_settings/gst_settings.py | 9 +- erpnext/regional/india/setup.py | 6 +- erpnext/setup/doctype/company/company.js | 2 +- .../doctype/naming_series/naming_series.py | 2 +- erpnext/stock/doctype/batch/batch.py | 4 +- 43 files changed, 187 insertions(+), 168 deletions(-) delete mode 100644 erpnext/accounts/doctype/share_transfer/test_records.json diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py index 0aaed8f530c..e8b60ac09a2 100644 --- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py +++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py @@ -14,7 +14,7 @@ form_grid_templates = { class BankReconciliation(Document): def get_payment_entries(self): if not (self.bank_account and self.from_date and self.to_date): - msgprint("Bank Account, From Date and To Date are Mandatory") + msgprint(_("Bank Account, From Date and To Date are Mandatory")) return condition = "" diff --git a/erpnext/accounts/doctype/share_transfer/share_transfer.py b/erpnext/accounts/doctype/share_transfer/share_transfer.py index c2eaa033752..2a2d9ff0f10 100644 --- a/erpnext/accounts/doctype/share_transfer/share_transfer.py +++ b/erpnext/accounts/doctype/share_transfer/share_transfer.py @@ -4,8 +4,12 @@ from __future__ import unicode_literals import frappe +from frappe import _ from frappe.model.document import Document from frappe.model.naming import make_autoname +from frappe.exceptions import ValidationError + +class ShareDontExists(ValidationError): pass class ShareTransfer(Document): def before_save(self): @@ -66,44 +70,45 @@ class ShareTransfer(Document): # validate share doesnt exist in company ret_val = self.share_exists(self.get_shareholder_doc(self.company).name) if ret_val != False: - frappe.throw('The shares already exist') + frappe.throw(_('The shares already exist'), frappe.DuplicateEntryError) else: # validate share exists with from_shareholder ret_val = self.share_exists(self.from_shareholder) if ret_val != True: - frappe.throw('The shares don\'t exist with the {0}'.format(self.from_shareholder)) + frappe.throw(_("The shares don't exist with the {0}") + .format(self.from_shareholder), ShareDontExists) def basic_validations(self): if self.transfer_type == 'Purchase': self.to_shareholder = '' if self.from_shareholder is None or self.from_shareholder is '': - frappe.throw('The field \'From Shareholder\' cannot be blank') + frappe.throw(_('The field From Shareholder cannot be blank')) if self.from_folio_no is None or self.from_folio_no is '': self.to_folio_no = self.autoname_folio(self.to_shareholder) elif (self.transfer_type == 'Issue'): self.from_shareholder = '' if self.to_shareholder is None or self.to_shareholder == '': - frappe.throw('The field \'To Shareholder\' cannot be blank') + frappe.throw(_('The field To Shareholder cannot be blank')) if self.to_folio_no is None or self.to_folio_no is '': self.to_folio_no = self.autoname_folio(self.to_shareholder) else: if self.from_shareholder is None or self.to_shareholder is None: - frappe.throw('The fields \'From Shareholder\' and \'To Shareholder\' cannot be blank') + frappe.throw(_('The fields From Shareholder and To Shareholder cannot be blank')) if self.to_folio_no is None or self.to_folio_no is '': self.to_folio_no = self.autoname_folio(self.to_shareholder) if self.from_shareholder == self.to_shareholder: - frappe.throw('The seller and the buyer cannot be the same') + frappe.throw(_('The seller and the buyer cannot be the same')) if self.no_of_shares != self.to_no - self.from_no + 1: - frappe.throw('The number of shares and the share numbers are inconsistent!') + frappe.throw(_('The number of shares and the share numbers are inconsistent')) if self.amount is None: self.amount = self.rate * self.no_of_shares if self.amount != self.rate * self.no_of_shares: - frappe.throw('There\'s inconsistency between the rate, no of shares and the amount calculated') + frappe.throw(_('There are inconsistencies between the rate, no of shares and the amount calculated')) def share_exists(self, shareholder): - # return True if exits, - # False if completely doesn't exist, - # 'partially exists' if partailly doesn't exist + # return True if exits, + # False if completely doesn't exist, + # 'partially exists' if partailly doesn't exist ret_val = self.recursive_share_check(shareholder, self.share_type, query = { 'from_no': self.from_no, @@ -177,13 +182,14 @@ class ShareTransfer(Document): for shareholder in shareholders: doc = frappe.get_doc('Shareholder', self.get(shareholder)) if doc.company != self.company: - frappe.throw('The shareholder doesn\'t belong to this company') + frappe.throw(_('The shareholder does not belong to this company')) if doc.folio_no is '' or doc.folio_no is None: - doc.folio_no = self.from_folio_no if (shareholder == 'from_shareholder') else self.to_folio_no; + doc.folio_no = self.from_folio_no \ + if (shareholder == 'from_shareholder') else self.to_folio_no; doc.save() else: if doc.folio_no != (self.from_folio_no if (shareholder == 'from_shareholder') else self.to_folio_no): - frappe.throw('The folio numbers are not matching') + frappe.throw(_('The folio numbers are not matching')) def autoname_folio(self, shareholder, is_company=False): if is_company: @@ -200,8 +206,8 @@ class ShareTransfer(Document): 'from_no': self.from_no, 'to_no' : self.to_no }, - rate = self.rate, - amount = self.amount + rate = self.rate, + amount = self.amount ) def iterative_share_removal(self, shareholder, share_type, query, rate, amount): diff --git a/erpnext/accounts/doctype/share_transfer/test_records.json b/erpnext/accounts/doctype/share_transfer/test_records.json deleted file mode 100644 index 13b37b46e1d..00000000000 --- a/erpnext/accounts/doctype/share_transfer/test_records.json +++ /dev/null @@ -1,76 +0,0 @@ - -[ - { - "doctype" : "Company", - "company_name" : "Stark Tower", - "abbr" : "ST", - "default_currency" : "INR" - }, - { - "doctype" : "Share Type", - "title" : "Class A" - }, - { - "doctype" : "Share Transfer", - "transfer_type" : "Issue", - "date" : "2018-01-01", - "to_shareholder" : "SH-00001", - "share_type" : "Equity", - "from_no" : 1, - "to_no" : 500, - "no_of_shares" : 500, - "rate" : 10, - "company" : "Stark Tower" - }, - { - "doctype" : "Share Transfer", - "transfer_type" : "Transfer", - "date" : "2018-01-02", - "from_shareholder" : "SH-00001", - "to_shareholder" : "SH-00002", - "share_type" : "Equity", - "from_no" : 101, - "to_no" : 200, - "no_of_shares" : 100, - "rate" : 15, - "company" : "Stark Tower" - }, - { - "doctype" : "Share Transfer", - "transfer_type" : "Transfer", - "date" : "2018-01-03", - "from_shareholder" : "SH-00001", - "to_shareholder" : "SH-00003", - "share_type" : "Equity", - "from_no" : 201, - "to_no" : 500, - "no_of_shares" : 300, - "rate" : 20, - "company" : "Stark Tower" - }, - { - "doctype" : "Share Transfer", - "transfer_type" : "Transfer", - "date" : "2018-01-04", - "from_shareholder" : "SH-00001", - "to_shareholder" : "SH-00002", - "share_type" : "Equity", - "from_no" : 201, - "to_no" : 400, - "no_of_shares" : 200, - "rate" : 15, - "company" : "Stark Tower" - }, - { - "doctype" : "Share Transfer", - "transfer_type" : "Purchase", - "date" : "2018-01-05", - "from_shareholder" : "SH-00003", - "share_type" : "Equity", - "from_no" : 401, - "to_no" : 500, - "no_of_shares" : 100, - "rate" : 25, - "company" : "Stark Tower" - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/share_transfer/test_share_transfer.py b/erpnext/accounts/doctype/share_transfer/test_share_transfer.py index 8dee358e08b..b74d6d6a820 100644 --- a/erpnext/accounts/doctype/share_transfer/test_share_transfer.py +++ b/erpnext/accounts/doctype/share_transfer/test_share_transfer.py @@ -5,11 +5,82 @@ from __future__ import unicode_literals import frappe import unittest -from frappe import ValidationError +from erpnext.accounts.doctype.share_transfer.share_transfer import ShareDontExists test_dependencies = ["Share Type", "Shareholder"] class TestShareTransfer(unittest.TestCase): + def setUp(self): + frappe.db.sql("delete from `tabShare Transfer`") + frappe.db.sql("delete from `tabShare Balance`") + share_transfers = [ + { + "doctype" : "Share Transfer", + "transfer_type" : "Issue", + "date" : "2018-01-01", + "to_shareholder" : "SH-00001", + "share_type" : "Equity", + "from_no" : 1, + "to_no" : 500, + "no_of_shares" : 500, + "rate" : 10, + "company" : "_Test Company" + }, + { + "doctype" : "Share Transfer", + "transfer_type" : "Transfer", + "date" : "2018-01-02", + "from_shareholder" : "SH-00001", + "to_shareholder" : "SH-00002", + "share_type" : "Equity", + "from_no" : 101, + "to_no" : 200, + "no_of_shares" : 100, + "rate" : 15, + "company" : "_Test Company" + }, + { + "doctype" : "Share Transfer", + "transfer_type" : "Transfer", + "date" : "2018-01-03", + "from_shareholder" : "SH-00001", + "to_shareholder" : "SH-00003", + "share_type" : "Equity", + "from_no" : 201, + "to_no" : 500, + "no_of_shares" : 300, + "rate" : 20, + "company" : "_Test Company" + }, + { + "doctype" : "Share Transfer", + "transfer_type" : "Transfer", + "date" : "2018-01-04", + "from_shareholder" : "SH-00003", + "to_shareholder" : "SH-00002", + "share_type" : "Equity", + "from_no" : 201, + "to_no" : 400, + "no_of_shares" : 200, + "rate" : 15, + "company" : "_Test Company" + }, + { + "doctype" : "Share Transfer", + "transfer_type" : "Purchase", + "date" : "2018-01-05", + "from_shareholder" : "SH-00003", + "share_type" : "Equity", + "from_no" : 401, + "to_no" : 500, + "no_of_shares" : 100, + "rate" : 25, + "company" : "_Test Company" + } + ] + for d in share_transfers: + frappe.get_doc(d).insert() + def test_invalid_share_transfer(self): doc = frappe.get_doc({ "doctype" : "Share Transfer", @@ -22,11 +93,10 @@ class TestShareTransfer(unittest.TestCase): "to_no" : 100, "no_of_shares" : 100, "rate" : 15, - "company" : "Stark Tower" + "company" : "_Test Company" }) - self.assertRaises(ValidationError, doc.insert) + self.assertRaises(ShareDontExists, doc.insert) - def test_invalid_share_purchase(self): doc = frappe.get_doc({ "doctype" : "Share Transfer", "transfer_type" : "Purchase", @@ -37,6 +107,6 @@ class TestShareTransfer(unittest.TestCase): "to_no" : 200, "no_of_shares" : 200, "rate" : 15, - "company" : "Stark Tower" + "company" : "_Test Company" }) - self.assertRaises(ValidationError, doc.insert) + self.assertRaises(ShareDontExists, doc.insert) diff --git a/erpnext/accounts/doctype/shareholder/shareholder.json b/erpnext/accounts/doctype/shareholder/shareholder.json index be35e7bf9f4..22a3061316e 100644 --- a/erpnext/accounts/doctype/shareholder/shareholder.json +++ b/erpnext/accounts/doctype/shareholder/shareholder.json @@ -42,7 +42,7 @@ "reqd": 0, "search_index": 0, "set_only_once": 0, - "unique": 1 + "unique": 0 }, { "allow_bulk_edit": 0, @@ -79,6 +79,7 @@ "bold": 0, "collapsible": 0, "columns": 0, + "default": "SH-", "fieldname": "naming_series", "fieldtype": "Select", "hidden": 0, @@ -477,7 +478,7 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2018-01-23 17:49:02.941363", + "modified": "2018-02-13 06:43:36.319549", "modified_by": "Administrator", "module": "Accounts", "name": "Shareholder", diff --git a/erpnext/accounts/doctype/shareholder/test_records.json b/erpnext/accounts/doctype/shareholder/test_records.json index ca289cb8fe8..39b72d47770 100644 --- a/erpnext/accounts/doctype/shareholder/test_records.json +++ b/erpnext/accounts/doctype/shareholder/test_records.json @@ -1,17 +1,20 @@ [ { "doctype": "Shareholder", - "series": "SH-", - "title": "Iron Man" + "naming_series": "SH-", + "title": "Iron Man", + "company": "_Test Company" }, { "doctype": "Shareholder", - "series": "SH-", - "title": "Thor" + "naming_series": "SH-", + "title": "Thor", + "company": "_Test Company" }, { "doctype": "Shareholder", - "series": "SH-", - "title": "Hulk" + "naming_series": "SH-", + "title": "Hulk", + "company": "_Test Company" } ] \ No newline at end of file diff --git a/erpnext/agriculture/doctype/crop/crop.py b/erpnext/agriculture/doctype/crop/crop.py index 7eeb8af6ce7..9121b544975 100644 --- a/erpnext/agriculture/doctype/crop/crop.py +++ b/erpnext/agriculture/doctype/crop/crop.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe +from frappe import _ from frappe.model.document import Document class Crop(Document): @@ -12,7 +13,7 @@ class Crop(Document): for task in self.agriculture_task: # validate start_day is not > end_day if task.start_day > task.end_day: - frappe.throw("Start day is greater than end day in task '{0}'".format(task.subject)) + frappe.throw(_("Start day is greater than end day in task '{0}'").format(task.subject)) # to calculate the period of the Crop Cycle if task.end_day > max_period: max_period = task.end_day if max_period > self.period: self.period = max_period diff --git a/erpnext/agriculture/doctype/crop_cycle/crop_cycle.py b/erpnext/agriculture/doctype/crop_cycle/crop_cycle.py index 21dfe317b7d..1d9f3242b01 100644 --- a/erpnext/agriculture/doctype/crop_cycle/crop_cycle.py +++ b/erpnext/agriculture/doctype/crop_cycle/crop_cycle.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe +from frappe import _ from frappe.model.document import Document import ast @@ -31,7 +32,7 @@ class CropCycle(Document): old_disease.append(detected_disease.name) if list(set(new_disease)-set(old_disease)) != []: self.update_disease(list(set(new_disease)-set(old_disease))) - frappe.msgprint("All tasks for the detected diseases were imported") + frappe.msgprint(_("All tasks for the detected diseases were imported")) def update_disease(self, disease_hashes): new_disease = [] diff --git a/erpnext/agriculture/doctype/disease/disease.py b/erpnext/agriculture/doctype/disease/disease.py index 42005d6b06c..8a0e6f33d68 100644 --- a/erpnext/agriculture/doctype/disease/disease.py +++ b/erpnext/agriculture/doctype/disease/disease.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe +from frappe import _ from frappe.model.document import Document class Disease(Document): @@ -12,7 +13,7 @@ class Disease(Document): for task in self.treatment_task: # validate start_day is not > end_day if task.start_day > task.end_day: - frappe.throw("Start day is greater than end day in task '{0}'".format(task.task_name)) + frappe.throw(_("Start day is greater than end day in task '{0}'").format(task.task_name)) # to calculate the period of the Crop Cycle if task.end_day > max_period: max_period = task.end_day self.treatment_period = max_period \ No newline at end of file diff --git a/erpnext/agriculture/doctype/soil_texture/soil_texture.py b/erpnext/agriculture/doctype/soil_texture/soil_texture.py index 7345e862b95..b66d00cbfdf 100644 --- a/erpnext/agriculture/doctype/soil_texture/soil_texture.py +++ b/erpnext/agriculture/doctype/soil_texture/soil_texture.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe +from frappe import _ from frappe.model.document import Document from frappe.utils import flt, cint @@ -20,9 +21,9 @@ class SoilTexture(Document): self.update_soil_edit('sand_composition') for soil_type in self.soil_types: if self.get(soil_type) > 100 or self.get(soil_type) < 0: - frappe.throw("{0} should be a value between 0 and 100".format(soil_type)) + frappe.throw(_("{0} should be a value between 0 and 100").format(soil_type)) if sum(self.get(soil_type) for soil_type in self.soil_types) != 100: - frappe.throw('Soil compositions do not add up to 100') + frappe.throw(_('Soil compositions do not add up to 100')) def update_soil_edit(self, soil_type): self.soil_edit_order[self.soil_types.index(soil_type)] = max(self.soil_edit_order)+1 diff --git a/erpnext/agriculture/doctype/water_analysis/water_analysis.py b/erpnext/agriculture/doctype/water_analysis/water_analysis.py index 81fdf14a372..bd2cd118e1d 100644 --- a/erpnext/agriculture/doctype/water_analysis/water_analysis.py +++ b/erpnext/agriculture/doctype/water_analysis/water_analysis.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe +from frappe import _ from frappe.model.document import Document class WaterAnalysis(Document): @@ -18,6 +19,6 @@ class WaterAnalysis(Document): def validate(self): if self.collection_datetime > self.laboratory_testing_datetime: - frappe.throw('Lab testing datetime cannot be before collection datetime') + frappe.throw(_('Lab testing datetime cannot be before collection datetime')) if self.laboratory_testing_datetime > self.result_datetime: - frappe.throw('Lab result datetime cannot be before testing datetime') \ No newline at end of file + frappe.throw(_('Lab result datetime cannot be before testing datetime')) \ No newline at end of file diff --git a/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.js b/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.js index 0dc0ee6b7ce..41d9ef38b00 100644 --- a/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.js +++ b/erpnext/buying/report/quoted_item_comparison/quoted_item_comparison.js @@ -94,7 +94,7 @@ frappe.query_reports["Quoted Item Comparison"] = { }, freeze: true, callback: (r) => { - frappe.msgprint("Successfully Set Supplier"); + frappe.msgprint(__("Successfully Set Supplier")); dialog.hide(); } }); diff --git a/erpnext/crm/doctype/opportunity/opportunity.py b/erpnext/crm/doctype/opportunity/opportunity.py index 75f9deac220..fc886ac69da 100644 --- a/erpnext/crm/doctype/opportunity/opportunity.py +++ b/erpnext/crm/doctype/opportunity/opportunity.py @@ -194,7 +194,7 @@ class Opportunity(TransactionBase): self.customer = None elif self.enquiry_from == 'Customer': if not self.customer: - msgprint("Customer is mandatory if 'Opportunity From' is selected as Customer", raise_exception=1) + msgprint(_("Customer is mandatory if 'Opportunity From' is selected as Customer"), raise_exception=1) else: self.lead = None diff --git a/erpnext/education/api.py b/erpnext/education/api.py index 99fb36e52cb..5edc0378e16 100644 --- a/erpnext/education/api.py +++ b/erpnext/education/api.py @@ -335,7 +335,7 @@ def get_assessment_result_doc(student, assessment_plan): if doc.docstatus == 0: return doc elif doc.docstatus == 1: - frappe.msgprint("Result already Submitted") + frappe.msgprint(_("Result already Submitted")) return None else: return frappe.new_doc("Assessment Result") diff --git a/erpnext/education/doctype/assessment_criteria/assessment_criteria.py b/erpnext/education/doctype/assessment_criteria/assessment_criteria.py index eadc0de95b9..1ea37023b24 100644 --- a/erpnext/education/doctype/assessment_criteria/assessment_criteria.py +++ b/erpnext/education/doctype/assessment_criteria/assessment_criteria.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe +from frappe import _ from frappe.model.document import Document STD_CRITERIA = ["total", "total score", "total grade", "maximum score", "score", "grade"] @@ -11,4 +12,4 @@ STD_CRITERIA = ["total", "total score", "total grade", "maximum score", "score", class AssessmentCriteria(Document): def validate(self): if self.assessment_criteria.lower() in STD_CRITERIA: - frappe.throw("Can't create standard criteria. Please rename the criteria") \ No newline at end of file + frappe.throw(_("Can't create standard criteria. Please rename the criteria")) \ No newline at end of file diff --git a/erpnext/education/doctype/instructor/instructor.py b/erpnext/education/doctype/instructor/instructor.py index 44a4e4c5c58..78e42613756 100644 --- a/erpnext/education/doctype/instructor/instructor.py +++ b/erpnext/education/doctype/instructor/instructor.py @@ -18,7 +18,7 @@ class Instructor(Document): self.name = make_autoname(self.naming_series + '.####') elif naming_method == 'Employee Number': if not self.employee: - frappe.throw("Please select Employee") + frappe.throw(_("Please select Employee")) self.name = self.employee elif naming_method == 'Full Name': self.name = self.instructor_name diff --git a/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.py b/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.py index bc6021839a5..e15be5001d3 100644 --- a/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.py +++ b/erpnext/education/doctype/program_enrollment_tool/program_enrollment_tool.py @@ -63,4 +63,4 @@ class ProgramEnrollmentTool(Document): prog_enrollment.academic_term = self.academic_term prog_enrollment.student_batch_name = stud.student_batch_name if stud.student_batch_name else self.new_student_batch prog_enrollment.save() - frappe.msgprint("{0} Students have been enrolled.".format(total)) + frappe.msgprint(_("{0} Students have been enrolled").format(total)) diff --git a/erpnext/healthcare/doctype/consultation/consultation.js b/erpnext/healthcare/doctype/consultation/consultation.js index 89b88616029..b0dbff5a554 100644 --- a/erpnext/healthcare/doctype/consultation/consultation.js +++ b/erpnext/healthcare/doctype/consultation/consultation.js @@ -41,7 +41,7 @@ frappe.ui.form.on('Consultation', { frappe.route_options = {"patient": frm.doc.patient}; frappe.set_route("medical_record"); } else { - frappe.msgprint("Please select Patient"); + frappe.msgprint(__("Please select Patient")); } },"View"); frm.add_custom_button(__('Vital Signs'), function() { @@ -121,7 +121,7 @@ var btn_invoice_consultation = function(frm){ var create_medical_record = function (frm) { if(!frm.doc.patient){ - frappe.throw("Please select patient"); + frappe.throw(__("Please select patient")); } frappe.route_options = { "patient": frm.doc.patient, @@ -134,7 +134,7 @@ var create_medical_record = function (frm) { var btn_create_vital_signs = 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/healthcare/doctype/consultation/consultation.py b/erpnext/healthcare/doctype/consultation/consultation.py index 809074e94b8..7d41afe65e0 100755 --- a/erpnext/healthcare/doctype/consultation/consultation.py +++ b/erpnext/healthcare/doctype/consultation/consultation.py @@ -21,7 +21,7 @@ class Consultation(Document): def on_submit(self): if not self.diagnosis or not self.symptoms: - frappe.throw("Diagnosis and Complaints cannot be left blank") + frappe.throw(_("Diagnosis and Complaints cannot be left blank")) def on_cancel(self): if(self.appointment): diff --git a/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.py b/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.py index 0d3d6e76508..ae7c4c58a63 100644 --- a/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.py +++ b/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe +from frappe import _ from frappe.model.document import Document from frappe.core.doctype.sms_settings.sms_settings import send_sms import json @@ -15,7 +16,7 @@ class HealthcareSettings(Document): frappe.db.set_default(key, self.get(key, "")) if(self.collect_registration_fee): if self.registration_fee <= 0 : - frappe.throw("Registration fee can not be Zero") + frappe.throw(_("Registration fee can not be Zero")) @frappe.whitelist() def get_sms_text(doc): diff --git a/erpnext/healthcare/doctype/lab_test/lab_test.js b/erpnext/healthcare/doctype/lab_test/lab_test.js index 2a453cd898a..02aa001127c 100644 --- a/erpnext/healthcare/doctype/lab_test/lab_test.js +++ b/erpnext/healthcare/doctype/lab_test/lab_test.js @@ -101,14 +101,14 @@ frappe.ui.form.on("Lab Test", "patient", function(frm) { frappe.ui.form.on('Normal Test Items', { normal_test_items_remove: function() { - frappe.msgprint("Not permitted, configure Lab Test Template as required"); + frappe.msgprint(__("Not permitted, configure Lab Test Template as required")); cur_frm.reload_doc(); } }); frappe.ui.form.on('Special Test Items', { special_test_items_remove: function() { - frappe.msgprint("Not permitted, configure Lab Test Template as required"); + frappe.msgprint(__("Not permitted, configure Lab Test Template as required")); cur_frm.reload_doc(); } }); @@ -142,7 +142,7 @@ var get_lab_test_prescribed = function(frm){ }); } else{ - frappe.msgprint("Please select Patient to get Lab Tests"); + frappe.msgprint(__("Please select Patient to get Lab Tests")); } }; @@ -217,7 +217,7 @@ cur_frm.cscript.custom_before_submit = function(doc) { if(doc.normal_test_items){ for(let result in doc.normal_test_items){ if(!doc.normal_test_items[result].result_value && doc.normal_test_items[result].require_result_value == 1){ - frappe.msgprint("Please input all required Result Value(s)"); + frappe.msgprint(__("Please input all required Result Value(s)")); throw("Error"); } } @@ -225,7 +225,7 @@ cur_frm.cscript.custom_before_submit = function(doc) { if(doc.special_test_items){ for(let result in doc.special_test_items){ if(!doc.special_test_items[result].result_value && doc.special_test_items[result].require_result_value == 1){ - frappe.msgprint("Please input all required Result Value(s)"); + frappe.msgprint(__("Please input all required Result Value(s)")); throw("Error"); } } diff --git a/erpnext/healthcare/doctype/lab_test_template/lab_test_template.py b/erpnext/healthcare/doctype/lab_test_template/lab_test_template.py index bb0ead62cfe..d178b0b326f 100644 --- a/erpnext/healthcare/doctype/lab_test_template/lab_test_template.py +++ b/erpnext/healthcare/doctype/lab_test_template/lab_test_template.py @@ -36,7 +36,7 @@ class LabTestTemplate(Document): try: frappe.delete_doc("Item",self.item) except Exception: - frappe.throw("""Not permitted. Please disable the Test Template""") + frappe.throw(_("""Not permitted. Please disable the Test Template""")) def item_price_exist(doc): item_price = frappe.db.exists({ diff --git a/erpnext/healthcare/doctype/patient/patient.js b/erpnext/healthcare/doctype/patient/patient.js index 57e5eef8d98..b1150abb3a0 100644 --- a/erpnext/healthcare/doctype/patient/patient.js +++ b/erpnext/healthcare/doctype/patient/patient.js @@ -53,7 +53,7 @@ frappe.ui.form.on("Patient", "dob", function(frm) { var today = new Date(); var birthDate = new Date(frm.doc.dob); if(today < birthDate){ - frappe.msgprint("Please select a valid Date"); + frappe.msgprint(__("Please select a valid Date")); frappe.model.set_value(frm.doctype,frm.docname, "dob", ""); } else{ @@ -83,7 +83,7 @@ var get_age = function (birth) { var btn_create_vital_signs = function (frm) { if (!frm.doc.name) { - frappe.throw("Please save the patient first"); + frappe.throw(__("Please save the patient first")); } frappe.route_options = { "patient": frm.doc.name, @@ -93,7 +93,7 @@ var btn_create_vital_signs = function (frm) { var btn_create_consultation = function (frm) { if (!frm.doc.name) { - frappe.throw("Please save the patient first"); + frappe.throw(__("Please save the patient first")); } frappe.route_options = { "patient": frm.doc.name, diff --git a/erpnext/healthcare/doctype/patient/patient.py b/erpnext/healthcare/doctype/patient/patient.py index e73482d87c3..b01f56ad6de 100644 --- a/erpnext/healthcare/doctype/patient/patient.py +++ b/erpnext/healthcare/doctype/patient/patient.py @@ -116,8 +116,9 @@ def make_invoice(patient, company): def get_patient_detail(patient): patient_dict = frappe.db.sql("""select * from tabPatient where name=%s""", (patient), as_dict=1) if not patient_dict: - frappe.throw("Patient not found") - vital_sign = frappe.db.sql("""select * from `tabVital Signs` where patient=%s order by signs_date desc limit 1""", (patient), as_dict=1) + frappe.throw(_("Patient not found")) + vital_sign = frappe.db.sql("""select * from `tabVital Signs` where patient=%s + order by signs_date desc limit 1""", (patient), as_dict=1) details = patient_dict[0] if vital_sign: diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js index a58516ca8b9..89121573f66 100644 --- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js +++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js @@ -181,7 +181,7 @@ var btn_create_consultation = function(frm){ var btn_create_vital_signs = 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/hotels/doctype/hotel_room/test_hotel_room.py b/erpnext/hotels/doctype/hotel_room/test_hotel_room.py index ab2f8293ade..e307b5ac37a 100644 --- a/erpnext/hotels/doctype/hotel_room/test_hotel_room.py +++ b/erpnext/hotels/doctype/hotel_room/test_hotel_room.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals import frappe import unittest -test_dependents = ["Hotel Room Package"] +test_dependencies = ["Hotel Room Package"] test_records = [ dict(doctype="Hotel Room", name="1001", hotel_room_type="Basic Room"), diff --git a/erpnext/hotels/doctype/hotel_room_pricing/test_hotel_room_pricing.py b/erpnext/hotels/doctype/hotel_room_pricing/test_hotel_room_pricing.py index 2b7848bb452..b73fd44cd5e 100644 --- a/erpnext/hotels/doctype/hotel_room_pricing/test_hotel_room_pricing.py +++ b/erpnext/hotels/doctype/hotel_room_pricing/test_hotel_room_pricing.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals import frappe import unittest - +test_dependencies = ["Hotel Room Package"] test_records = [ dict(doctype="Hotel Room Pricing", enabled=1, name="Winter 2017", diff --git a/erpnext/hotels/doctype/hotel_room_reservation/test_hotel_room_reservation.py b/erpnext/hotels/doctype/hotel_room_reservation/test_hotel_room_reservation.py index 55c63112cd8..d4979968e61 100644 --- a/erpnext/hotels/doctype/hotel_room_reservation/test_hotel_room_reservation.py +++ b/erpnext/hotels/doctype/hotel_room_reservation/test_hotel_room_reservation.py @@ -6,7 +6,7 @@ from __future__ import unicode_literals import frappe import unittest from erpnext.hotels.doctype.hotel_room_reservation.hotel_room_reservation import HotelRoomPricingNotSetError, HotelRoomUnavailableError -test_dependencies = ["Hotel Room Pricing", "Hotel Room"] +test_dependencies = ["Hotel Room Package", "Hotel Room Pricing", "Hotel Room"] class TestHotelRoomReservation(unittest.TestCase): def setUp(self): diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.js b/erpnext/hr/doctype/expense_claim/expense_claim.js index f40e77c53c7..a99311dda02 100644 --- a/erpnext/hr/doctype/expense_claim/expense_claim.js +++ b/erpnext/hr/doctype/expense_claim/expense_claim.js @@ -311,7 +311,7 @@ frappe.ui.form.on("Expense Claim Advance", { employee_advance: function(frm, cdt, cdn) { var child = locals[cdt][cdn]; if(!frm.doc.employee){ - frappe.msgprint('Select an employee to get the employee advance.'); + frappe.msgprint(__('Select an employee to get the employee advance.')); frm.doc.advances = []; refresh_field("advances"); } diff --git a/erpnext/hr/doctype/leave_application/test_leave_application.py b/erpnext/hr/doctype/leave_application/test_leave_application.py index 520d7c97035..4a9a001339d 100644 --- a/erpnext/hr/doctype/leave_application/test_leave_application.py +++ b/erpnext/hr/doctype/leave_application/test_leave_application.py @@ -245,10 +245,6 @@ class TestLeaveApplication(unittest.TestCase): application.insert() frappe.set_user("test@example.com") - - # clear permlevel access cache on change user - del application._has_access_to - self.assertRaises(LeaveDayBlockedError, application.submit) frappe.db.set_value("Leave Block List", "_Test Leave Block List", diff --git a/erpnext/hr/doctype/payroll_entry/payroll_entry.py b/erpnext/hr/doctype/payroll_entry/payroll_entry.py index 2a5b467845d..a023cc3ea94 100644 --- a/erpnext/hr/doctype/payroll_entry/payroll_entry.py +++ b/erpnext/hr/doctype/payroll_entry/payroll_entry.py @@ -455,13 +455,13 @@ def format_as_links(salary_slip): def create_submit_log(submitted_ss, not_submitted_ss, jv_name): if not submitted_ss and not not_submitted_ss: - frappe.msgprint("No salary slip found to submit for the above selected criteria OR salary slip already submitted") + frappe.msgprint(_("No salary slip found to submit for the above selected criteria OR salary slip already submitted")) if not_submitted_ss: - frappe.msgprint("Could not submit any Salary Slip
\ + frappe.msgprint(_("Could not submit any Salary Slip
\ Possible reasons:
\ 1. Net pay is less than 0.
\ - 2. Company Email Address specified in employee master is not valid.
") + 2. Company Email Address specified in employee master is not valid.
")) def get_salary_slip_list(name, docstatus, as_dict=0): diff --git a/erpnext/hub_node/doctype/hub_settings/hub_settings.js b/erpnext/hub_node/doctype/hub_settings/hub_settings.js index ce0f8bc3520..bc789274766 100644 --- a/erpnext/hub_node/doctype/hub_settings/hub_settings.js +++ b/erpnext/hub_node/doctype/hub_settings/hub_settings.js @@ -46,7 +46,7 @@ frappe.ui.form.on("Hub Settings", { set_enable_hub_primary_button: (frm) => { frm.page.set_primary_action(__("Enable Hub"), () => { if(frappe.session.user === "Administrator") { - frappe.msgprint("Please login as another user.") + frappe.msgprint(__("Please login as another user.")) } else { frappe.verify_password(() => { this.frm.call({ diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 69d8a4752cd..762a046c81d 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -492,5 +492,5 @@ erpnext.patches.v10_0.added_extra_gst_custom_field erpnext.patches.v10_0.workflow_leave_application #2018-01-24 #2018-02-02 #2018-02-08 erpnext.patches.v10_0.set_default_payment_terms_based_on_company erpnext.patches.v10_0.update_sales_order_link_to_purchase_order -erpnext.patches.v10_0.added_extra_gst_custom_field_in_gstr2 +erpnext.patches.v10_0.added_extra_gst_custom_field_in_gstr2 #2018-02-13 erpnext.patches.v10_0.item_barcode_childtable_migrate diff --git a/erpnext/patches/v10_0/added_extra_gst_custom_field_in_gstr2.py b/erpnext/patches/v10_0/added_extra_gst_custom_field_in_gstr2.py index a1512ed9b77..185e20d42e1 100644 --- a/erpnext/patches/v10_0/added_extra_gst_custom_field_in_gstr2.py +++ b/erpnext/patches/v10_0/added_extra_gst_custom_field_in_gstr2.py @@ -6,4 +6,13 @@ def execute(): if not company: return - make_custom_fields() \ No newline at end of file + make_custom_fields() + + frappe.db.sql(""" + update `tabCustom Field` + set reqd = 0, `default` = '' + where fieldname = 'reason_for_issuing_document' + """) + + frappe.db.sql("""delete from `tabCustom Field` where dt = 'Purchase Invoice' + and fieldname in ('port_code', 'shipping_bill_number', 'shipping_bill_date')""") \ No newline at end of file diff --git a/erpnext/patches/v7_0/repost_bin_qty_and_item_projected_qty.py b/erpnext/patches/v7_0/repost_bin_qty_and_item_projected_qty.py index 20ee814fda6..5d763047569 100644 --- a/erpnext/patches/v7_0/repost_bin_qty_and_item_projected_qty.py +++ b/erpnext/patches/v7_0/repost_bin_qty_and_item_projected_qty.py @@ -3,7 +3,6 @@ from __future__ import unicode_literals import frappe -from erpnext.stock.doctype.bin.bin import update_item_projected_qty def execute(): repost_bin_qty() diff --git a/erpnext/public/js/controllers/accounts.js b/erpnext/public/js/controllers/accounts.js index 860c8c1dbfc..5baf84873ec 100644 --- a/erpnext/public/js/controllers/accounts.js +++ b/erpnext/public/js/controllers/accounts.js @@ -133,7 +133,7 @@ var get_payment_mode_account = function(frm, mode_of_payment, callback) { cur_frm.cscript.account_head = function(doc, cdt, cdn) { var d = locals[cdt][cdn]; if(!d.charge_type && d.account_head){ - frappe.msgprint("Please select Charge Type first"); + frappe.msgprint(__("Please select Charge Type first")); frappe.model.set_value(cdt, cdn, "account_head", ""); } else if(d.account_head && d.charge_type!=="Actual") { frappe.call({ diff --git a/erpnext/public/js/controllers/buying.js b/erpnext/public/js/controllers/buying.js index a9e3ad4e924..bd3a03da3d0 100644 --- a/erpnext/public/js/controllers/buying.js +++ b/erpnext/public/js/controllers/buying.js @@ -252,10 +252,12 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ d.qty = d.qty - my_qty; cur_frm.doc.items[i].stock_qty = my_qty*cur_frm.doc.items[i].conversion_factor; cur_frm.doc.items[i].qty = my_qty; - - frappe.msgprint("Assigning " + d.mr_name + " to " + d.item_code + " (row " + cur_frm.doc.items[i].idx + ")"); + + frappe.msgprint(__("Assigning {0} to {1} (row {2})", + [d.mr_name, d.item_code, cur_frm.doc.items[i].idx]); + if (qty > 0) { - frappe.msgprint("Splitting " + qty + " units of " + d.item_code); + frappe.msgprint(__("Splitting {0} units of {1}", [qty, d.item_code]); var newrow = frappe.model.add_child(cur_frm.doc, cur_frm.doc.items[i].doctype, "items"); item_length++; diff --git a/erpnext/public/js/setup_wizard.js b/erpnext/public/js/setup_wizard.js index 6fa710d982a..2652f9510b9 100644 --- a/erpnext/public/js/setup_wizard.js +++ b/erpnext/public/js/setup_wizard.js @@ -84,7 +84,7 @@ erpnext.setup.slides_settings = [ slide.get_input("company_abbr").on("change", function () { if (slide.get_input("company_abbr").val().length > 5) { - frappe.msgprint("Company Abbreviation cannot have more than 5 characters"); + frappe.msgprint(__("Company Abbreviation cannot have more than 5 characters")); slide.get_field("company_abbr").set_value(""); } }); diff --git a/erpnext/regional/doctype/gst_settings/gst_settings.py b/erpnext/regional/doctype/gst_settings/gst_settings.py index 45c565d193d..bc956e9fa88 100644 --- a/erpnext/regional/doctype/gst_settings/gst_settings.py +++ b/erpnext/regional/doctype/gst_settings/gst_settings.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import frappe, os +from frappe import _ from frappe.utils import get_url, nowdate, date_diff from frappe.model.document import Document from frappe.contacts.doctype.contact.contact import get_default_contact @@ -24,13 +25,13 @@ def send_reminder(): last_sent = frappe.db.get_single_value('GST Settings', 'gstin_email_sent_on') if last_sent and date_diff(nowdate(), last_sent) < 3: - frappe.throw("Please wait 3 days before resending the reminder.") + frappe.throw(_("Please wait 3 days before resending the reminder.")) frappe.db.set_value('GST Settings', 'GST Settings', 'gstin_email_sent_on', nowdate()) # enqueue if large number of customers, suppliser frappe.enqueue('erpnext.regional.doctype.gst_settings.gst_settings.send_gstin_reminder_to_all_parties') - frappe.msgprint('Email Reminders will be sent to all parties with email contacts') + frappe.msgprint(_('Email Reminders will be sent to all parties with email contacts')) def send_gstin_reminder_to_all_parties(): parties = [] @@ -60,7 +61,7 @@ def send_gstin_reminder(party_type, party): frappe.has_permission(party_type, throw=True) email = _send_gstin_reminder(party_type ,party) if email: - frappe.msgprint('Reminder to update GSTIN Sent', title='Reminder sent', indicator='green') + frappe.msgprint(_('Reminder to update GSTIN Sent'), title='Reminder sent', indicator='green') def _send_gstin_reminder(party_type, party, default_email_id=None, sent_to=None): '''Send GST Reminder email''' @@ -70,7 +71,7 @@ def _send_gstin_reminder(party_type, party, default_email_id=None, sent_to=None) email_id = default_email_id if not email_id: - frappe.throw('Email not found in default contact', exc=EmailMissing) + frappe.throw(_('Email not found in default contact'), exc=EmailMissing) if sent_to and email_id in sent_to: return diff --git a/erpnext/regional/india/setup.py b/erpnext/regional/india/setup.py index c11337aac25..ac68a92ba79 100644 --- a/erpnext/regional/india/setup.py +++ b/erpnext/regional/india/setup.py @@ -95,7 +95,7 @@ def make_custom_fields(): fieldtype='Select', insert_after='invoice_copy', print_hide=1, options='Y\nN', default='N'), dict(fieldname='invoice_type', label='Invoice Type', - fieldtype='Select', insert_after='gst_col_break', print_hide=1, + fieldtype='Select', insert_after='invoice_copy', print_hide=1, options='Regular\nSEZ\nExport\nDeemed Export', default='Regular'), dict(fieldname='export_type', label='Export Type', fieldtype='Select', insert_after='invoice_type', print_hide=1, @@ -103,10 +103,10 @@ def make_custom_fields(): options='\nWith Payment of Tax\nWithout Payment of Tax'), dict(fieldname='ecommerce_gstin', label='E-commerce GSTIN', fieldtype='Data', insert_after='export_type', print_hide=1), - dict(fieldname='gst_col_break', fieldtype='Column Break', insert_after='reason_for_issuing_document'), + dict(fieldname='gst_col_break', fieldtype='Column Break', insert_after='ecommerce_gstin'), dict(fieldname='reason_for_issuing_document', label='Reason For Issuing document', fieldtype='Select', insert_after='gst_col_break', print_hide=1, - depends_on='eval:doc.is_return==1', reqd=1, + depends_on='eval:doc.is_return==1', options='\n01-Sales Return\n02-Post Sale Discount\n03-Deficiency in services\n04-Correction in Invoice\n05-Change in POS\n06-Finalization of Provisional assessment\n07-Others') ] diff --git a/erpnext/setup/doctype/company/company.js b/erpnext/setup/doctype/company/company.js index 44757ab404e..84e0a2037cd 100644 --- a/erpnext/setup/doctype/company/company.js +++ b/erpnext/setup/doctype/company/company.js @@ -92,7 +92,7 @@ frappe.ui.form.on("Company", { }, function(data) { if(data.company_name !== frm.doc.name) { - frappe.msgprint("Company name not same"); + frappe.msgprint(__("Company name not same")); return; } frappe.call({ diff --git a/erpnext/setup/doctype/naming_series/naming_series.py b/erpnext/setup/doctype/naming_series/naming_series.py index 45345846bc2..6455be0de7b 100644 --- a/erpnext/setup/doctype/naming_series/naming_series.py +++ b/erpnext/setup/doctype/naming_series/naming_series.py @@ -27,7 +27,7 @@ class NamingSeries(Document): try: options = self.get_options(d) except frappe.DoesNotExistError: - frappe.msgprint('Unable to find DocType {0}'.format(d)) + frappe.msgprint(_('Unable to find DocType {0}').format(d)) #frappe.pass_does_not_exist_error() continue diff --git a/erpnext/stock/doctype/batch/batch.py b/erpnext/stock/doctype/batch/batch.py index 645ab1bc7e2..5b4f4b531c3 100644 --- a/erpnext/stock/doctype/batch/batch.py +++ b/erpnext/stock/doctype/batch/batch.py @@ -115,8 +115,8 @@ class Batch(Document): self.expiry_date = add_days(self.manufacturing_date, shelf_life_in_days) if has_expiry_date and not self.expiry_date: - frappe.throw('Expiry date is mandatory for selected item') - frappe.msgprint('Set items shelf life in days, to set expiry based on manufacturing_date plus self life ') + frappe.throw(_('Expiry date is mandatory for selected item')) + frappe.msgprint(_('Set items shelf life in days, to set expiry based on manufacturing_date plus self life')) def get_name_from_naming_series(self): """