mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-13 03:45:08 +00:00
Co-authored-by: diptanilsaha <diptanil@frappe.io> fix(sales_invoice): reset payment methods on `pos_profile` change (#53514)
This commit is contained in:
@@ -804,11 +804,9 @@ class SalesInvoice(SellingController):
|
|||||||
if self.pos_profile:
|
if self.pos_profile:
|
||||||
pos = frappe.get_doc("POS Profile", 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 pos:
|
||||||
if not for_validate:
|
if not for_validate:
|
||||||
|
update_multi_mode_option(self, pos)
|
||||||
self.tax_category = pos.get("tax_category")
|
self.tax_category = pos.get("tax_category")
|
||||||
|
|
||||||
if not for_validate and not self.customer:
|
if not for_validate and not self.customer:
|
||||||
@@ -2747,6 +2745,8 @@ def update_multi_mode_option(doc, pos_profile):
|
|||||||
payment.account = payment_mode.default_account
|
payment.account = payment_mode.default_account
|
||||||
payment.type = payment_mode.type
|
payment.type = payment_mode.type
|
||||||
|
|
||||||
|
mop_refetched = bool(doc.payments) and not doc.is_created_using_pos
|
||||||
|
|
||||||
doc.set("payments", [])
|
doc.set("payments", [])
|
||||||
invalid_modes = []
|
invalid_modes = []
|
||||||
mode_of_payments = [d.mode_of_payment for d in pos_profile.get("payments")]
|
mode_of_payments = [d.mode_of_payment for d in pos_profile.get("payments")]
|
||||||
@@ -2768,6 +2768,12 @@ def update_multi_mode_option(doc, pos_profile):
|
|||||||
msg = _("Please set default Cash or Bank account in Mode of Payments {}")
|
msg = _("Please set default Cash or Bank account in Mode of Payments {}")
|
||||||
frappe.throw(msg.format(", ".join(invalid_modes)), title=_("Missing Account"))
|
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):
|
def get_all_mode_of_payments(doc):
|
||||||
return frappe.db.sql(
|
return frappe.db.sql(
|
||||||
|
|||||||
Reference in New Issue
Block a user