Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Correctly update fields on doctype form #22860

Merged
merged 1 commit into from
Oct 23, 2023

Conversation

ankush
Copy link
Member

@ankush ankush commented Oct 22, 2023

Problem:
frm.save fails with mandatory error because form builder is modifying df.name of newly created docfields. DFs are located by locals.doctype.docname and if you change the name it's orphaned.

This was working so far only because we follow this naming: new-doctype-# so it would pick up any arbitrary document and move on.


Alternate solution: Since form builder was directly updating doc.fields changes were not reflected in underlying model. doing frm.set_value prevent this out-of-sync model problems.

closes #22851
closes #22723

@ankush ankush requested review from a team and surajshetty3416 and removed request for a team October 22, 2023 13:36
@ankush ankush mentioned this pull request Oct 22, 2023
@ankush ankush marked this pull request as draft October 22, 2023 13:44
Just updating frm.doc object doesn't update the underlying model. In Frappe `frm.doc` is NOT the primary representation or source of truth for better or worse.
@ankush ankush changed the title fix: Don't override name in model fix: Correctly update fields on doctype form Oct 23, 2023
@ankush ankush marked this pull request as ready for review October 23, 2023 08:32
@ankush ankush added the backport version-15-hotfix Backport the PR to v15 label Oct 23, 2023
@ankush ankush merged commit a3db75e into frappe:develop Oct 23, 2023
21 of 22 checks passed
@ankush ankush deleted the form_builder_data branch October 23, 2023 08:44
mergify bot pushed a commit that referenced this pull request Oct 23, 2023
Just updating frm.doc object doesn't update the underlying model. In Frappe `frm.doc` is NOT the primary representation or source of truth for better or worse.

(cherry picked from commit a3db75e)
ankush added a commit that referenced this pull request Oct 23, 2023
Just updating frm.doc object doesn't update the underlying model. In Frappe `frm.doc` is NOT the primary representation or source of truth for better or worse.

(cherry picked from commit a3db75e)
ankush added a commit that referenced this pull request Oct 23, 2023
Just updating frm.doc object doesn't update the underlying model. In Frappe `frm.doc` is NOT the primary representation or source of truth for better or worse.

(cherry picked from commit a3db75e)

Co-authored-by: Ankush Menat <ankush@frappe.io>
frappe-pr-bot pushed a commit that referenced this pull request Oct 23, 2023
## [15.0.1](v15.0.0...v15.0.1) (2023-10-23)

### Bug Fixes

* use frm.set_value for updating fields ([#22860](#22860)) ([89b5ea9](89b5ea9))
@ankush ankush mentioned this pull request Oct 23, 2023
2 tasks
frappe-pr-bot pushed a commit that referenced this pull request Oct 31, 2023
## [15.0.2](v15.0.1...v15.0.2) (2023-10-31)

### Bug Fixes

* Add translation to "Not Saved" state in print format builder ([#22920](#22920)) ([#22995](#22995)) ([8e8274e](8e8274e))
* developer mode in website theme ([#22958](#22958)) ([#22998](#22998)) ([138e679](138e679))
* don't encode `/` in html escaping ([#22871](#22871)) ([#22875](#22875)) ([2e456f8](2e456f8))
* escape print format code field([#22852](#22852)) ([#22866](#22866)) ([82d8809](82d8809))
* font loading on custom website theme (backport [#22967](#22967)) ([#22992](#22992)) ([3984214](3984214))
* Footer should show up once at end if not repeating header/footer ([#22902](#22902)) ([#22910](#22910)) ([e7ce38a](e7ce38a))
* group by didn't work for the frappe.client.get_value ([#22969](#22969)) ([#22973](#22973)) ([773b74f](773b74f))
* ignore stale custom fields while checking back-links ([#22940](#22940)) ([#22943](#22943)) ([7ce96d9](7ce96d9))
* ignore workspace links on delete ([#22895](#22895)) ([#22897](#22897)) ([821d1e9](821d1e9))
* improve label and description for `fetch_if_empty` ([9e690be](9e690be))
* list view formatting logic (backport [#22646](#22646)) ([#22849](#22849)) ([16363ab](16363ab))
* **migrate:** raise exception even if db is not available ([#22922](#22922)) ([#23000](#23000)) ([a02ba82](a02ba82))
* **minor:** hide grid row on modal close ([#22930](#22930)) ([#22932](#22932)) ([c5a9fdf](c5a9fdf))
* **minor:** use inline-flex in page-actions btn ([#22846](#22846)) ([#22868](#22868)) ([59114ef](59114ef))
* resolve page not found error ([fc9b644](fc9b644))
* revert to setting `frappe.dynamic_link` instead of using `cur_frm` ([37243c6](37243c6))
* revert unintentional quick entry default for Address ([#22974](#22974)) ([f7aaaf3](f7aaaf3))
* skip invalid numbers on SMS `receiver_list` (backport [#22879](#22879)) ([#23003](#23003)) ([5b905e3](5b905e3))
* use frm.set_value for updating fields ([#22860](#22860)) ([#22869](#22869)) ([1df1a27](1df1a27))
* web styles espresso (backport [#22924](#22924)) ([#22933](#22933)) ([b2c6f07](b2c6f07))

### Performance Improvements

* query fields only once ([#22982](#22982)) ([#22988](#22988)) ([7e2adb4](7e2adb4))
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport version-15-hotfix Backport the PR to v15
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot able to save the new doctype Form builder sometimes silently fails to save
2 participants