Before_update_after_submit not working

import frappe
from frappe.model.document import Document
from frappe.utils import today, getdate

class Doctypename(Document):
def validate(self):
# Check if status is being changed
if self.get_doc_before_save():
previous_status = self.get_doc_before_save().status
new_status = self.status

        restricted_statuses = ["Approved For Payment", "Paid"]
        roles = frappe.get_roles()

        # Check if the new status is restricted and has been changed
        if new_status in restricted_statuses and new_status != previous_status:
            # Ensure the user has the "Accounts Manager" role
            if "Accounts Manager" not in roles:
                frappe.throw(
                    f"Only Accounts Managers are allowed to change the vendor status to '{new_status}'."
                )                   
    if self.status == "Paid":
        self.status = "Paid"
    else:
        self.status = "Unpaid"   
        
def set_status(self):
    # Convert due_date to date object if it's in string format
    print("Run")
    due_date = getdate(self.due_date)

    # Check if due_date has passed and update status to "Overdue"
    if due_date and due_date < today() and self.status == "Unpaid":
        self.db_set('status', "Overdue", commit=True)         

def before_update_after_submit(self):
    self.set_status()

What is the bug can someone point out

The before_update_after_submit method only runs if the document is in a Submitted state. If the document is not submitted, this function will not be called.

  • Solution: Verify that the document has a docstatus = 1. For example:
print(doc.docstatus)

Document is submitted still not working

@management try on_update_after_submit