Hello,
I have created an API to handle the creation, updating, and submission of Stock Reconciliation records. My goal is to submit a record by sending only its status, instead of providing all the data for the record.
Here’s an example flow:
- I create a Stock Reconciliation record using the API:
curl 'https://erp.mydomain.com/api/resource/Stock%20Reconciliation' \
--header 'Authorization: token xxx:yyy' \
--header 'Content-Type: application/json' \
--data '{
"docstatus": 0,
"doctype": "Stock Reconciliation",
"owner": "Administrator",
"naming_series": "MAT-RECO-.YYYY.-",
"company": "My Company",
"purpose": "Stock Reconciliation",
"posting_date": "2023-07-28",
"set_posting_time": 1,
"items": [
{
"owner": "Administrator",
"allow_zero_valuation_rate": 1,
"item_code": "SKU-007",
"warehouse": "Warehouse1",
"qty": 10,
"valuation_rate": 0
}
],
"posting_time": "13:34:38"
}'
- I receive the name ID of this document, which is
MAT-RECO-2023-00006
. Now, I want to submit this Stock Reconciliation without making any changes to its data (items, quantities, values, etc.).
Here’s an example request for submitting the record:
curl --request PUT 'https://erp.mydomain.com/api/resource/Stock%20Reconciliation/MAT-RECO-2023-00006' \
--header 'Authorization: token xxx:yyy' \
--header 'Content-Type: application/json' \
--data '{
"name": "MAT-RECO-2023-00006",
"docstatus": 1
}'
However, I encountered an error message:
{
"exc_type": "EmptyStockReconciliationItemsError",
"exception": "erpnext.stock.doctype.stock_reconciliation.stock_reconciliation.EmptyStockReconciliationItemsError: None of the items have any change in quantity or value.",
"exc": "[\"Traceback (most recent call last):\\n File \\\"apps/frappe/frappe/app.py\\\", line 94, in application\\n response = frappe.api.handle()\\n File \\\"apps/frappe/frappe/api.py\\\", line 94, in handle\\n doc.save()\\n File \\\"apps/frappe/frappe/model/document.py\\\", line 305, in save\\n return self._save(*args, **kwargs)\\n File \\\"apps/frappe/frappe/model/document.py\\\", line 339, in _save\\n self.run_before_save_methods()\\n File \\\"apps/frappe/frappe/model/document.py\\\", line 1048, in run_before_save_methods\\n self.run_method(\\\"validate\\\")\\n File \\\"apps/frappe/frappe/model/document.py\\\", line 914, in run_method\\n out = Document.hook(fn)(self, *args, **kwargs)\\n File \\\"apps/frappe/frappe/model/document.py\\\", line 1267, in composer\\n return composed(self, method, *args, **kwargs)\\n File \\\"apps/frappe/frappe/model/document.py\\\", line 1249, in runner\\n add_to_return_value(self, fn(self, *args, **kwargs))\\n File \\\"apps/frappe/frappe/model/document.py\\\", line 911, in fn\\n return method_object(*args, **kwargs)\\n File \\\"apps/erpnext/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py\\\", line 40, in validate\\n self.remove_items_with_no_change()\\n File \\\"apps/erpnext/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py\\\", line 108, in remove_items_with_no_change\\n frappe.throw(\\n File \\\"apps/frappe/frappe/__init__.py\\\", line 533, in throw\\n msgprint(\\n File \\\"apps/frappe/frappe/__init__.py\\\", line 501, in msgprint\\n _raise_exception()\\n File \\\"apps/frappe/frappe/__init__.py\\\", line 450, in _raise_exception\\n raise raise_exception(msg)\\nerpnext.stock.doctype.stock_reconciliation.stock_reconciliation.EmptyStockReconciliationItemsError: None of the items have any change in quantity or value.\\n\"]",
"_server_messages": "[\"{\\\"message\\\": \\\"None of the items have any change in quantity or value.\\\", \\\"title\\\": \\\"Message\\\", \\\"indicator\\\": \\\"red\\\", \\\"raise_exception\\\": 1}\"]"
}
Could you please help me understand how to submit a record by only providing its status? Thank you for your assistance.