mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-27 02:28:30 +00:00
fix: prevent manual cancellation of the linked Revaluation Journal Entry
(cherry picked from commit 73b038084b)
# Conflicts:
# erpnext/accounts/doctype/journal_entry/journal_entry.py
This commit is contained in:
@@ -177,6 +177,9 @@ class JournalEntry(AccountsController):
|
|||||||
else:
|
else:
|
||||||
return self._submit()
|
return self._submit()
|
||||||
|
|
||||||
|
def before_cancel(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def cancel(self):
|
def cancel(self):
|
||||||
if len(self.accounts) > 100:
|
if len(self.accounts) > 100:
|
||||||
queue_submission(self, "_cancel")
|
queue_submission(self, "_cancel")
|
||||||
@@ -224,6 +227,11 @@ class JournalEntry(AccountsController):
|
|||||||
"Advance Payment Ledger Entry",
|
"Advance Payment Ledger Entry",
|
||||||
)
|
)
|
||||||
self.make_gl_entries(1)
|
self.make_gl_entries(1)
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
JournalTaxWithholding(self).on_cancel()
|
||||||
|
self.has_asset_adjustment_entry()
|
||||||
|
>>>>>>> 73b038084b (fix: prevent manual cancellation of the linked Revaluation Journal Entry)
|
||||||
self.unlink_advance_entry_reference()
|
self.unlink_advance_entry_reference()
|
||||||
self.unlink_asset_reference()
|
self.unlink_asset_reference()
|
||||||
self.unlink_inter_company_jv()
|
self.unlink_inter_company_jv()
|
||||||
@@ -447,6 +455,20 @@ class JournalEntry(AccountsController):
|
|||||||
)
|
)
|
||||||
frappe.db.set_value("Journal Entry", self.name, "inter_company_journal_entry_reference", "")
|
frappe.db.set_value("Journal Entry", self.name, "inter_company_journal_entry_reference", "")
|
||||||
|
|
||||||
|
def has_asset_adjustment_entry(self):
|
||||||
|
if self.flags.get("via_asset_value_adjustment"):
|
||||||
|
return
|
||||||
|
|
||||||
|
asset_value_adjustment = frappe.db.get_value(
|
||||||
|
"Asset Value Adjustment", {"docstatus": 1, "journal_entry": self.name}, "name"
|
||||||
|
)
|
||||||
|
if asset_value_adjustment:
|
||||||
|
frappe.throw(
|
||||||
|
_(
|
||||||
|
"Cannot cancel this document as it is linked with the submitted Asset Value Adjustment <b>{0}</b>. Please cancel the Asset Value Adjustment to continue."
|
||||||
|
).format(frappe.utils.get_link_to_form("Asset Value Adjustment", asset_value_adjustment))
|
||||||
|
)
|
||||||
|
|
||||||
def unlink_asset_adjustment_entry(self):
|
def unlink_asset_adjustment_entry(self):
|
||||||
AssetValueAdjustment = frappe.qb.DocType("Asset Value Adjustment")
|
AssetValueAdjustment = frappe.qb.DocType("Asset Value Adjustment")
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ class AssetValueAdjustment(Document):
|
|||||||
if revaluation_entry.docstatus == 1:
|
if revaluation_entry.docstatus == 1:
|
||||||
# Ignore permissions to match Journal Entry submission behavior
|
# Ignore permissions to match Journal Entry submission behavior
|
||||||
revaluation_entry.flags.ignore_permissions = True
|
revaluation_entry.flags.ignore_permissions = True
|
||||||
|
revaluation_entry.flags.via_asset_value_adjustment = True
|
||||||
revaluation_entry.cancel()
|
revaluation_entry.cancel()
|
||||||
|
|
||||||
def update_asset(self):
|
def update_asset(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user