fix(sales_invoice): reset payment methods on pos_profile change (backport #53514) (#53561)

Co-authored-by: diptanilsaha <diptanil@frappe.io>
fix(sales_invoice): reset payment methods on `pos_profile` change (#53514)
This commit is contained in:
mergify[bot]
2026-03-17 17:21:11 +00:00
committed by GitHub
parent 535543d406
commit 4d197b1b7c

View File

@@ -919,11 +919,9 @@ class SalesInvoice(SellingController):
if self.pos_profile:
pos = frappe.get_doc("POS Profile", self.pos_profile)
if not self.get("payments") and not for_validate:
update_multi_mode_option(self, pos)
if pos:
if not for_validate:
update_multi_mode_option(self, pos)
self.tax_category = pos.get("tax_category")
if not for_validate and not self.customer:
@@ -3008,6 +3006,8 @@ def update_multi_mode_option(doc, pos_profile):
payment.account = payment_mode.default_account
payment.type = payment_mode.type
mop_refetched = bool(doc.payments) and not doc.is_created_using_pos
doc.set("payments", [])
invalid_modes = []
mode_of_payments = [d.mode_of_payment for d in pos_profile.get("payments")]
@@ -3029,6 +3029,12 @@ def update_multi_mode_option(doc, pos_profile):
msg = _("Please set default Cash or Bank account in Mode of Payments {}")
frappe.throw(msg.format(", ".join(invalid_modes)), title=_("Missing Account"))
if mop_refetched:
frappe.toast(
_("Payment methods refreshed. Please review before proceeding."),
indicator="orange",
)
def get_all_mode_of_payments(doc):
return frappe.db.sql(