fix(translations): Replace translations by keyword with indexed version (#15426)

* fix(translations): Replace translations by keyword with indexed version

Keywords in the translation also gets translated which
results in an error because python cannot find the key

* Update buying_controller.py
This commit is contained in:
Faris Ansari 2018-09-19 13:13:59 +05:30 committed by Nabin Hait
parent 63a58a6752
commit 2ab6e0e39b
4 changed files with 15 additions and 17 deletions

View File

@ -61,7 +61,7 @@ class OpeningInvoiceCreationTool(Document):
def make_invoices(self):
names = []
mandatory_error_msg = _("Row {idx}: {field} is required to create the Opening {invoice_type} Invoices")
mandatory_error_msg = _("Row {0}: {1} is required to create the Opening {2} Invoices")
if not self.company:
frappe.throw(_("Please select the Company"))
@ -73,7 +73,7 @@ class OpeningInvoiceCreationTool(Document):
if not row.temporary_opening_account:
row.temporary_opening_account = get_temporary_opening_account(self.company)
row.party_type = "Customer" if self.invoice_type == "Sales" else "Supplier"
# Allow to create invoice even if no party present in customer or supplier.
if not frappe.db.exists(row.party_type, row.party):
if self.create_missing_party:
@ -90,11 +90,7 @@ class OpeningInvoiceCreationTool(Document):
for d in ("Party", "Outstanding Amount", "Temporary Opening Account"):
if not row.get(scrub(d)):
frappe.throw(mandatory_error_msg.format(
idx=row.idx,
field=_(d),
invoice_type=self.invoice_type
))
frappe.throw(mandatory_error_msg.format(row.idx, _(d), self.invoice_type))
args = self.get_invoice_dict(row=row)
if not args:
@ -128,7 +124,7 @@ class OpeningInvoiceCreationTool(Document):
party_doc.supplier_group = supplier_group
party_doc.flags.ignore_mandatory = True
party_doc.save(ignore_permissions=True)
party_doc.save(ignore_permissions=True)
def get_invoice_dict(self, row=None):
def get_item_dict():

View File

@ -772,8 +772,7 @@ class AccountsController(TransactionBase):
if li:
duplicates = '<br>' + '<br>'.join(li)
frappe.throw(_("Rows with duplicate due dates in other rows were found: {list}")
.format(list=duplicates))
frappe.throw(_("Rows with duplicate due dates in other rows were found: {0}").format(duplicates))
def validate_payment_schedule_amount(self):
if self.doctype == 'Sales Invoice' and self.is_pos: return

View File

@ -753,8 +753,11 @@ def validate_item_type(doc, fieldname, message):
""".format(item_list, fieldname), as_list=True)]
if invalid_items:
frappe.throw(_("Following item {items} {verb} marked as {message} item.\
You can enable them as {message} item from its Item master".format(
items = ", ".join([d for d in invalid_items]),
verb = _("are not") if len(invalid_items) > 1 else _("is not"),
message = message)))
items = ", ".join([d for d in invalid_items])
if len(invalid_items) > 1:
error_message = _("Following items {0} are not marked as {1} item. You can enable them as {1} item from its Item master".format(items, message))
else:
error_message = _("Following item {0} is not marked as {1} item. You can enable them as {1} item from its Item master".format(items, message))
frappe.throw(error_message)

View File

@ -60,8 +60,8 @@ class LandedCostVoucher(Document):
if not item.receipt_document:
frappe.throw(_("Item must be added using 'Get Items from Purchase Receipts' button"))
elif item.receipt_document not in receipt_documents:
frappe.throw(_("Item Row {idx}: {doctype} {docname} does not exist in above '{doctype}' table")
.format(idx=item.idx, doctype=item.receipt_document_type, docname=item.receipt_document))
frappe.throw(_("Item Row {0}: {1} {2} does not exist in above '{1}' table")
.format(item.idx, item.receipt_document_type, item.receipt_document))
if not item.cost_center:
frappe.throw(_("Row {0}: Cost center is required for an item {1}")