import frappe

def update_serial_nos(doc, method):
    """Update serial nos linked to this pallet."""
    if doc.pallet_number:
        serials = frappe.get_all("Serial No", filters={"pallet": doc.pallet_number}, fields=["name"])
        doc.db_set("serial_count", len(serials))
