Try ERPNext Buy Support Partners Foundation

Problems Rest API Quotation

Hello everybody,

we have got problems with creating Quotations with the rest api.
The systems creates the quotation but the customer and the material data ist not filled,

We will show you the json code perhaps anybody has a solution

{
“data”: {
company: “BRÜGGEMANN DÄCHER GmbH”,
conversion_rate: 1,
currency: “EUR”,
customer: “Schmidt & Partner Consulting”,
customer_group: “Unternehmen”,
customer_name: “Schmidt & Partner Consulting”,
doctype: “Quotation”,
base_grand_total: 1000.0,
grand_total: 1000.0,
order_type: “Sales”,
plc_conversion_rate: 1,
price_list_currency: “EUR”,
items: [
{
base_amount: 1000.0,
base_rate: 100.0,
description: “AKS PIXX-Transp.Qua.50cm TRAN Taubenstopleiste/Kunstst/V2A-Spikes”,
doctype: “Quotation Item”,
item_code: “35013”,
item_name: “AKS PIXX-Transp.Qua.50cm TRAN Taubenstopleiste/Kunstst/V2A-Spikes”,
parentfield: “items”,
qty: 10.0,
rate: 19,
uom: “M”,
stock_uom: “M”,
conversion_factor: 1.0
}
],
quotation_to: “Customer”,
selling_price_list: “Standard-Vertrieb”,
territory: “Hamburg”,
transaction_date: “2017-05-16”

kind regards

Frank Woischke

@Woischke,

Is there any error traceback? Which API you are using custom API or frappe’s REST API please provide some details

We are using the normal api
http://xxx/api/resource/Quotation

i have teste the following json code
{
“data”: {
“company”: “BRÜGGEMANN DÄCHER GmbH”,
“conversion_rate”: 1,
“currency”: “EUR”,
“customer”: “Schmidt & Partner Consulting”,
“customer_group”: “Unternehmen”,
“customer_name”: “Schmidt & Partner Consulting”,
“doctype”: “Quotation”,
“base_grand_total”: 1000.0,
“grand_total”: 1000.0,
“order_type”: “Sales”,
“plc_conversion_rate”: 1,
“price_list_currency”: “EUR”,
“items”: {
“base_amount”: 1000.0,
“base_rate”: 100.0,
“description”: “AKS PIXX-Transp.Qua.50cm TRAN Taubenstopleiste/Kunstst/V2A-Spikes”,
“doctype”: “Quotation Item”,
“item_code”: “35013”,
“item_name”: “AKS PIXX-Transp.Qua.50cm TRAN Taubenstopleiste/Kunstst/V2A-Spikes”,
“parentfield”: “items”,
“qty”: 10.0,
“rate”: 19,
“uom”: “M”,
“stock_uom”: “M”,
“conversion_factor”: 1.0
}
},
“quotation_to”: “Customer”,
“selling_price_list”: “Standard-Vertrieb”,
“territory”: “Hamburg”,
“transaction_date”: “2017-05-22”
}

the reply from the Server is

{
“data”: {
“additional_discount_percentage”: 0,
“base_in_words”: “”,
“campaign”: null,
“naming_series”: “QTN-”,
“creation”: “2017-05-22 08:15:23.795428”,
“doctype”: “Quotation”,
“currency”: “EUR”,
“conversion_rate”: 1,
“owner”: “frank.woischke@zedach.eu”,
“total”: 0,
“shipping_rule”: null,
“customer_name”: null,
“taxes_and_charges”: null,
“language”: null,
“select_print_heading”: null,
“modified_by”: “frank.woischke@zedach.eu”,
“order_type”: “Sales”,
“lead”: null,
“title”: “”,
“base_total”: 0,
“selling_price_list”: “Standard-Vertrieb”,
“supplier_quotation”: null,
“tc_name”: null,
“amended_from”: null,
“transaction_date”: “2017-05-22”,
“contact_display”: null,
“docstatus”: 0,
“territory”: “Hamburg”,
“company”: “BRÜGGEMANN DÄCHER GmbH”,
“address_display”: null,
“letter_head”: “BRÜGGEMANN”,
“terms”: null,
“ignore_pricing_rule”: 0,
“parent”: null,
“base_rounded_total”: 0,
“quotation_to”: “Customer”,
“total_taxes_and_charges”: 0,
“grand_total”: 0,
“base_discount_amount”: 0,
“customer_address”: null,
“contact_email”: null,
“base_total_taxes_and_charges”: 0,
“contact_mobile”: null,
“items”: [],
“base_grand_total”: 0,
“discount_amount”: 0,
“customer”: null,
“order_lost_reason”: null,
“base_net_total”: 0,
“enq_det”: null,
“name”: “QTN-00047”,
“idx”: 0,
“rounded_total”: 0,
“shipping_address_name”: null,
“price_list_currency”: “EUR”,
“modified”: “2017-05-22 08:15:23.795428”,
“taxes”: [],
“plc_conversion_rate”: 1,
“parenttype”: null,
“net_total”: 0,
“status”: “Draft”,
“source”: null,
“shipping_address”: null,
“apply_discount_on”: “Grand Total”,
“contact_person”: null,
“in_words”: “”,
“customer_group”: null,
“parentfield”: null
}
}

So normaly i would say everything is fine, but he hasn’t recognized the customer an the items. An we did not understand why.
Is there another trace in the file System? can you tell me where ?

Kind regards

Frank Woischke

@Woischke,

Check Error Log or Error Snapshot for error traceback. or check if you have any custom script on Quotation might be Customer field is cleared after Form refresh or onload?

We have no Custom script in use and in the log in /home/frappe/frappe-bench/logs there i can’t see any error.
in worker.error.log

09:57:06 default: frappe.utils.background_jobs.execute_job(async=True, event=None, job_name=u’frappe.utils.global_search.update_global_search’, kwargs={‘doc’: <frappe.core.doctype.communication.communication.Communication object at 0x7fe2b888e610>}, method=u’frappe.utils.global_search.update_global_search’, site=u’site1.local’, user=u’frank.woischke’) (c77fb100-5da0-41e6-8a62-718e2298140b)
09:57:06 default: Job OK (c77fb100-5da0-41e6-8a62-718e2298140b)
09:57:06 Result is kept for 500 seconds

that ist the only log

Can anybody helps me?. We have Gott a big Presentation For erpnext on thursday.

Kind regards

Frank Woischke

Hi @Woischke @makarand_b,
I am using normal api for creating quotation
my json code is

{
“data”: {
“company”: “AG Pvt. Ltd”,
“conversion_rate”: 1,
“currency”: “INR”,
“customer”: “JAY”,
“customer_group”: “Individual”,
“customer_name”: “JAY”,
“doctype”: “Quotation”,
“base_grand_total”: 10.0,
“grand_total”: 10.0,
“order_type”: “Sales”,
“plc_conversion_rate”: 1,
“price_list_currency”: “INR”,
“items”: {
“base_amount”: 10.0,
“base_rate”: 10.0,
“description”: “HHS”,
“doctype”: “Quotation Item”,
“item_code”: “123”,
“item_name”: “LATHE MACHINE”,
“parentfield”: “items”,
“qty”: 10.0,
“rate”: 21,
“uom”: “Nos”,
“stock_uom”: “Nos”,
“conversion_factor”: 1.0
}
},
“quotation_to”: “Customer”,
“selling_price_list”: “Standard Selling”,
“transaction_date”: “2020-01-02”
}

But i am getting this error

Traceback (most recent call last):
File “/home/user/frappe-bench/apps/frappe/frappe/app.py”, line 60, in application
response = frappe.api.handle()
File “/home/user/frappe-bench/apps/frappe/frappe/api.py”, line 127, in handle
“data”: frappe.get_doc(data).insert().as_dict()
File “/home/user/frappe-bench/apps/frappe/frappe/model/document.py”, line 229, in insert
self.run_before_save_methods()
File “/home/user/frappe-bench/apps/frappe/frappe/model/document.py”, line 888, in run_before_save_methods
self.run_method(“validate”)
File “/home/user/frappe-bench/apps/frappe/frappe/model/document.py”, line 787, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/user/frappe-bench/apps/frappe/frappe/model/document.py”, line 1058, in composer
return composed(self, method, *args, **kwargs)
File “/home/user/frappe-bench/apps/frappe/frappe/model/document.py”, line 1041, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/user/frappe-bench/apps/frappe/frappe/model/document.py”, line 781, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/user/frappe-bench/apps/erpnext/erpnext/selling/doctype/quotation/quotation.py”, line 27, in validate
super(Quotation, self).validate()
File “/home/user/frappe-bench/apps/erpnext/erpnext/controllers/selling_controller.py”, line 39, in validate
super(SellingController, self).validate()
File “/home/user/frappe-bench/apps/erpnext/erpnext/controllers/stock_controller.py”, line 21, in validate
super(StockController, self).validate()
File “/home/user/frappe-bench/apps/erpnext/erpnext/controllers/accounts_controller.py”, line 80, in validate
self.set_total_in_words()
File “/home/user/frappe-bench/apps/erpnext/erpnext/controllers/selling_controller.py”, line 117, in set_total_in_words
if self.is_rounded_total_disabled() else self.base_rounded_total)
TypeError: bad operand type for abs(): ‘NoneType’

Hi @Woischke & @makarand_b
I am able to create quotation using rest api but the customer and the item child table is not filled ?
How to implement the child item table & customer data in quotation using rest api ?