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: address filter and quotation to for prospect #41040
base: develop
Are you sure you want to change the base?
Conversation
frappe.dynamic_link = { | ||
doc: this.frm.doc, | ||
fieldname: "party_name", | ||
doctype: doc.quotation_to == "Customer" ? "Customer" : "Lead", | ||
doctype: doctype, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just do:
doctype: doc.quotation_to
?
Futureproof.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code snippet uses a series of if and else if statements to explicitly set the variable doctype based on the value of doc.quotation_to. This approach clearly handles each case ("Customer," "Lead," "Prospect") individually, and it's easy to read and modify.
The suggested alternative in your question (doctype: doc.quotation_to == "Customer" ? "Customer" : "Lead") is not equivalent because it only checks if doc.quotation_to is "Customer" and incorrectly defaults to "Lead" without verifying if it should indeed be "Lead." This misses cases like "Prospect" and any other potential values.
Using a ternary operator for this purpose can lead to errors or reduced clarity, especially when multiple conditions are involved. The original method using if-else statements is more appropriate here for clarity and accuracy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No you misunderstand me. There is no need to do an if-else or ternary operator, because quotation_to
can only be the values in the Select field anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Nihantra-Patel nice work |
Version 15
fixes: #41015
Before:
When choosing "quotation_to" as a customer, the customer displays correctly. Similarly, when selecting "quotation_to" as the lead, the lead displays correctly. However, when "quotation_to" is set as a prospect, the lead list is shown instead. Moreover, when initially selecting "quotation_to" as a customer and then changing it to prospect, it displays properly.
In the case where "quotation_to" is set as a prospect, the address does not appear, and the address filter does not correspond to the prospect; instead, it shows the lead address.
before_prospect_quot.mp4
After:
after_prospect_quot.mp4