Skip to content

Purchase Order: "To Pay" missing from status field options — submission fails when advance_payment_status == "Initiated" #54491

@DeshchenkoHanna

Description

@DeshchenkoHanna

Information about bug

What happens

After creating and submitting a Payment Request (advance payment) against a Purchase Order, I can no longer submit the Purchase Order. I get this error:
"Status cannot be "To Pay". It should be one of "", "Draft", "On Hold", "To Receive and Bill",
"To Bill", "To Receive", "Completed", "Cancelled", "Closed", "Delivered""

Steps to reproduce

  1. Enable "Fetch Payment Schedule in Payment Request" in Accounts Settings.
  2. Create a Purchase Order with Payment Terms → save.
  3. From the PO, Create → Payment Request → select a schedule row → submit the Payment Request. (This sets advance_payment_status = 'Initiated')
  4. Go to the PO → click Submit on the draft.
  5. → Error: Status cannot be "To Pay".
Image

Root cause

Inconsistency between controller logic and the DocType field definition:

erpnext/controllers/status_updater.py — rule assigns "To Pay" to PO when advance_payment_status == 'Initiated':
[ "To Pay", "eval:self.advance_payment_status == 'Initiated' and self.docstatus == 1", ]
,
erpnext/buying/doctype/purchase_order/purchase_order.json — the status field's options list is missing "To Pay":
"options": "\nDraft\nOn Hold\nTo Receive and Bill\nTo Bill\nTo Receive\nCompleted\nCancelled\nClosed\nDelivered"

Module

buying

Version

Frappe version-16.15.0
ERPNext version-16.15.0

Installation method

docker

Relevant log output / Stack trace / Full Error Message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions