Skip to content

fix: allow clearing of default fields (Sales Invoice Terms & Purchase Invoice Terms)#1350

Merged
ableksaju merged 1 commit intofrappe:masterfrom
mukulpadwal:fix/clear-default-fields
Sep 29, 2025
Merged

fix: allow clearing of default fields (Sales Invoice Terms & Purchase Invoice Terms)#1350
ableksaju merged 1 commit intofrappe:masterfrom
mukulpadwal:fix/clear-default-fields

Conversation

@mukulpadwal
Copy link
Copy Markdown
Contributor

Summary:
This PR fixes a bug where clearing default fields did not persist after saving and restarting the app.

Fixes: #1333

Issue:
Users were unable to clear certain default fields, specifically the Sales Invoice Terms. When a field was cleared and saved, the previous value would reappear after restarting the app. (Ref: #1333)

Root Cause:

  • When a field was cleared, the value sent to the database was null.
  • SQLite and the Frappe Books model treat null as “no value,” which does not overwrite the existing value in the database.
  • As a result, the field was repopulated with the previous value on app restart.

Fix:

  • Updated the onValueChange method to convert null to an empty string before saving:
    await this.doc?.set(fieldname, value ?? '');
  • This ensures that clearing a field sets an explicit empty string in the database, so the cleared value persists.

Impact:

  • Fixes clearing behavior for Sales Invoice Terms & Purchase Invoice Terms.
  • Also resolves the same issue for any other default fields affected by this null persistence problem.

Testing:

  • Manually cleared Sales Invoice Terms & Purchase Invoice Terms, saved, and restarted the app, the field remained empty.
  • Verified that saving non-empty values still works correctly.

Demo / Video:

  • Clear Sales Invoice Terms field.
  • Save settings.
  • Restart the app.
  • Verify the field remains empty.
clear-sales-invoice-terms.mp4

@ableksaju ableksaju merged commit 4968fb2 into frappe:master Sep 29, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants