Skip to content

Commit

Permalink
fix: use correct variable in error message (backport #43790) (#43792)
Browse files Browse the repository at this point in the history
Co-authored-by: Raffael Meyer <[email protected]>
fix: use correct variable in error message (#43790)
  • Loading branch information
mergify[bot] and barredterra authored Oct 22, 2024
1 parent 1253061 commit 879b2b7
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions erpnext/controllers/accounts_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,16 +393,14 @@ def remove_serial_and_batch_bundle(self):
def validate_return_against_account(self):
if self.doctype in ["Sales Invoice", "Purchase Invoice"] and self.is_return and self.return_against:
cr_dr_account_field = "debit_to" if self.doctype == "Sales Invoice" else "credit_to"
cr_dr_account_label = self.meta.get_label(cr_dr_account_field)
cr_dr_account = self.get(cr_dr_account_field)
original_account = frappe.get_value(self.doctype, self.return_against, cr_dr_account_field)
if original_account != cr_dr_account:
if original_account != self.get(cr_dr_account_field):
frappe.throw(
_(
"Please set {0} to {1}, the same account that was used in the original invoice {2}."
).format(
frappe.bold(_(cr_dr_account_label, context=self.doctype)),
frappe.bold(cr_dr_account),
frappe.bold(_(self.meta.get_label(cr_dr_account_field), context=self.doctype)),
frappe.bold(original_account),
frappe.bold(self.return_against),
)
)
Expand Down

0 comments on commit 879b2b7

Please sign in to comment.