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

V12: Sales quotation set lost throws error #18707

Open
dasistwas opened this issue Aug 12, 2019 · 4 comments
Open

V12: Sales quotation set lost throws error #18707

dasistwas opened this issue Aug 12, 2019 · 4 comments
Labels
to-validate Old issues pending validation

Comments

@dasistwas
Copy link

Tested on:
ERPNext: v12.0.5 (version-12)
Frappe Framework: v12.0.5 (version-12)
Ubuntu 18.04

First create at least one lost reason at: desk#List/Quotation Lost Reason/List
(If you do not create a reason, there is also an error)

Steps to reproduce:

  1. Create new quotation
  2. Save and submit quotation
  3. Immediately afterwards set as "Lost"

In the field "Lost reasons" there should be the reasons autocompleted as soon as I start typing. But that is already broken. Typing a reason and submitting gives that error:

Error message

POSThttps://localhost/api/method/runserverobj
[HTTP/1.1 417 EXPECTATION FAILED 354ms]

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 60, in application
    response = frappe.api.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/api.py", line 55, in handle
    return frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 21, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 56, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1036, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 84, in runserverobj
    frappe.desk.form.run_method.runserverobj(method, docs=docs, dt=dt, dn=dn, arg=arg, args=args)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/run_method.py", line 42, in runserverobj
    r = doc.run_method(method, **args)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 786, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1055, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1038, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 780, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/erpnext/erpnext/selling/doctype/quotation/quotation.py", line 85, in declare_enquiry_lost
    self.save()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 271, in save
    return self._save(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 306, in _save
    self._validate_links()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 755, in _validate_links
    frappe.LinkValidationError)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 360, in throw
    msgprint(msg, raise_exception=exc, title=title, indicator='red')
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 346, in msgprint
    _raise_exception()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 315, in _raise_exception
    raise raise_exception(msg)
frappe.exceptions.LinkValidationError: Could not find Row #1: Opportunity Lost Reason: Fehlerhaftes Angebot, Row #2: Opportunity Lost Reason: Fehlerhaftes Angebot, Row #3: Opportunity Lost Reason: Fehlerhaftes Angebot, Row #4: Opportunity Lost Reason: Fehlerhaftes Angebot

Screenshot of "Set Lost" dialogue

screenshot

@dasistwas
Copy link
Author

The AJAX request:

lost_reasons_list	
[{"lost_reason":"Fehlerhaftes+Angebot"},{"lost_reason":"Fehlerhaftes+Angebot"},{"lost_reason":"Fehlerhaftes+Angebot"},{"lost_reason":"Fehlerhaftes+Angebot"}]
docs	
{"name":"SAL-QTN-2019-00018","owner":"test@example.com","creation":"2019-08-12+20:46:42.856906","modified":"2019-08-12+20:47:08.226808","modified_by":"test@example.com","idx":0,"docstatus":1,"title":"customer name","naming_series":"SAL-QTN-.YYYY.-","quotation_to":"Customer","party_name":"test","customer_name":"customer name","company":"Test Company","transaction_date":"2019-08-12","valid_till":"2019-08-13","order_type":"Sales","customer_addres…octype":"Sales+Taxes+and+Charges"}],"payment_schedule":[{"name":"cee28b7f4e","owner":"test@example.com","creation":"2019-08-12+20:46:43.071943","modified":"2019-08-12+20:47:08.226808","modified_by":"test@example.com","parent":"SAL-QTN-2019-00018","parentfield":"payment_schedule","parenttype":"Quotation","idx":1,"docstatus":1,"due_date":"2019-08-12","invoice_portion":100,"payment_amount":2520,"doctype":"Payment+Schedule"}],"lost_reasons":[],"__onload":{"make_payment_via_journal_entry":0}}
method	
declare_enquiry_lost
args	
{"lost_reasons_list":[{"lost_reason":"Fehlerhaftes+Angebot"},{"lost_reason":"Fehlerhaftes+Angebot"},{"lost_reason":"Fehlerhaftes+Angebot"},{"lost_reason":"Fehlerhaftes+Angebot"}]}

Response:

exc_type	
LinkValidationError
exc	
["Traceback (most recent call last):\n File \"/home/frappe/frappe-bench/apps/frappe/frappe/app.py\", line 60, in application\n response = frappe.api.handle()\n File \"/home/frappe/frappe-bench/apps/frappe/frappe/api.py\", line 55, in handle\n return frappe.handler.handle()\n File \"/home/frappe/frappe-bench/apps/frappe/frappe/handler.py\", line 21, in handle\n data = execute_cmd(cmd)\n File \"/home/frappe/frappe-bench/apps/frappe/frappe/handler.py\", line 56, in execute_cmd\n return frappe.c…e/frappe/frappe-bench/apps/frappe/frappe/__init__.py\", line 346, in msgprint\n _raise_exception()\n File \"/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py\", line 315, in _raise_exception\n raise raise_exception(msg)\nfrappe.exceptions.LinkValidationError: Could not find Row #1: Opportunity Lost Reason: Fehlerhaftes Angebot, Row #2: Opportunity Lost Reason: Fehlerhaftes Angebot, Row #3: Opportunity Lost Reason: Fehlerhaftes Angebot, Row #4: Opportunity Lost Reason: Fehlerhaftes Angebot\n"]
_server_messages	
["{\"message\": \"Could not find Row #1: Opportunity Lost Reason: Fehlerhaftes Angebot, Row #2: Opportunity Lost Reason: Fehlerhaftes Angebot, Row #3: Opportunity Lost Reason: Fehlerhaftes Angebot, Row #4: Opportunity Lost Reason: Fehlerhaftes Angebot\", \"indicator\": \"red\"}"]

@clarkejj
Copy link
Contributor

clarkejj commented Aug 14, 2019

Please also post this to discuss for folks there to benefit too - be sure to link to both threads thanks!

@dasistwas
Copy link
Author

Thank you @clarkejj for that hint. Just posted it: https://discuss.erpnext.com/t/v12-sales-quotation-set-lost-throws-error/51844

@szufisher
Copy link
Contributor

because per the doctype definition and the error message, you should define the opportunity lost reason other than quotation lost reason because refer it in quotation maybe this is the design bug or the lost reason should be more generic, otherwise there will be confusing like what you encountered.

@ankush ankush added the to-validate Old issues pending validation label Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to-validate Old issues pending validation
Projects
None yet
Development

No branches or pull requests

4 participants