Outsourcing with Batch Numbers on Ver 15 SaaS

Hi,

I am trying to make an outsourcing transaction on ver 15 SaaS where both the transformed (or outsourced) item and the input item (or raw material) is batched, with expiry date. But when I’m trying to make the Subcontract Receipt, it’s giving me the following error:

App Versions

{
	"email_delivery_service": "0.0.1",
	"erpnext": "15.0.0",
	"frappe": "15.0.2",
	"india_compliance": "15.0.0-dev"
}

Route

Form/Subcontracting Receipt/new-subcontracting-receipt-fnfcnetcls

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 110, in application
    response = frappe.api.handle(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/__init__.py", line 49, in handle
    data = endpoint(**arguments)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
    return frappe.handler.handle()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 49, in handle
    data = execute_cmd(cmd)
           ^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1682, in call
    return fn(*args, **newargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/desk/form/save.py", line 39, in savedocs
    doc.save()
  File "apps/frappe/frappe/model/document.py", line 334, in save
    return self._save(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 356, in _save
    return self.insert()
           ^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 310, in insert
    self.run_post_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1118, in run_post_save_methods
    self.run_method("on_update")
  File "apps/frappe/frappe/model/document.py", line 950, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1316, in composer
    return composed(self, method, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1298, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 947, in fn
    return method_object(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py", line 87, in on_update
    self.set_serial_and_batch_bundle(table_field)
  File "apps/erpnext/erpnext/controllers/stock_controller.py", line 399, in set_serial_and_batch_bundle
    frappe.get_doc("Serial and Batch Bundle", row.get(field)).set_serial_and_batch_values(
  File "apps/erpnext/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py", line 298, in set_serial_and_batch_values
    self.validate_quantity(row, qty_field=qty_field)
  File "apps/erpnext/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py", line 404, in validate_quantity
    f"Total quantity {abs(self.total_qty)} in the Serial and Batch Bundle {bold(self.name)} does not match with the quantity {abs(row.get(qty_field))} for the Item {bold(self.item_code)} in the {self.voucher_type} # {self.voucher_no}"
                                                                                                                              ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: bad operand type for abs(): 'NoneType'

Request Data

{
	"type": "POST",
	"args": {
		"doc": "{\"owner\":\"jramns@gmail.com\",\"docstatus\":0,\"idx\":0,\"naming_series\":\"MAT-SCR-.YYYY.-\",\"supplier\":\"ABC Company\",\"supplier_name\":\"ABC Company\",\"company\":\"ROI Retrievers\",\"posting_date\":\"2023-12-01\",\"posting_time\":\"11:50:25.062430\",\"set_posting_time\":0,\"is_return\":0,\"set_warehouse\":\"Finished Goods - RR\",\"supplier_warehouse\":\"ABC Company - RR\",\"total_qty\":20,\"total\":20,\"distribute_additional_costs_based_on\":\"Qty\",\"total_additional_costs\":0,\"status\":\"Draft\",\"per_returned\":0,\"doctype\":\"Subcontracting Receipt\",\"items\":[{\"owner\":\"jramns@gmail.com\",\"docstatus\":0,\"idx\":1,\"item_code\":\"SIOutsourced\",\"item_name\":\"Sales Item Outsourced\",\"is_scrap_item\":0,\"description\":\"Sales Item Made\",\"received_qty\":20,\"qty\":20,\"rejected_qty\":0,\"returned_qty\":0,\"stock_uom\":\"Nos\",\"conversion_factor\":1,\"rate\":1,\"amount\":20,\"rm_cost_per_qty\":0,\"service_cost_per_qty\":1,\"additional_cost_per_qty\":0,\"scrap_cost_per_qty\":0,\"rm_supp_cost\":0,\"warehouse\":\"Finished Goods - RR\",\"subcontracting_order\":\"SC-ORD-2023-00003\",\"subcontracting_order_item\":\"ba972a284b\",\"bom\":\"BOM-SIOutsourced-001\",\"schedule_date\":\"2023-12-01\",\"cost_center\":\"Main - RR\",\"page_break\":0,\"parentfield\":\"items\",\"parenttype\":\"Subcontracting Receipt\",\"doctype\":\"Subcontracting Receipt Item\",\"__islocal\":1,\"__unsaved\":1,\"parent\":\"new-subcontracting-receipt-utwchouvqo\",\"name\":\"new-subcontracting-receipt-item-fnqizelitd\",\"serial_and_batch_bundle\":\"SABB-00000011\"}],\"supplied_items\":[],\"additional_costs\":[],\"__islocal\":1,\"__onload\":{\"load_after_mapping\":true},\"__unsaved\":1,\"name\":\"new-subcontracting-receipt-utwchouvqo\"}",
		"action": "Save"
	},
	"btn": {
		"jQuery3700035045160742733781": {
			"events": {
				"click": [
					{
						"type": "click",
						"origType": "click",
						"guid": 22936,
						"namespace": ""
					}
				]
			}
		}
	},
	"freeze": true,
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.form.save.savedocs",
	"request_id": "b76c81d1-a686-4520-bc4c-2809d3b5b817"
}

Response Data

{
	"exception": "TypeError: bad operand type for abs(): 'NoneType'",
	"exc_type": "TypeError",
	"_exc_source": "erpnext (app)"
}

Is there something I’m missing? Or is there a problem?

BTW: Managing Batch/Serial Numbers on Version 15 has become super complicated. Serial and Batch Bundle is a layer that has been added extra. I’m sure it’s been added for a good reason, can somebody please explain the logic so that I understand what it (the logic) is and how it works.

The Subcontracting process also has become more complicated with Subcontracting Order, Subcontracting Receipt. The Supplier PO for a service item.

Again, I’m sure it’s been done for a very good reason, but anything that adds more layers is definite to get super complicated for users.

The previous configuration worked great. Please revert to the previous configuration. Serious traceability users can get some reports to view traceability information of the supply chain. Or can get some customisations done to address their requirements.

What’s inadvertently occurred is that it’s supremely complicated. Please revert back to the traditional configuration.

Thanks

Jay

Hi,

This issue is fixed in ERPNExt v15.3.0. Please update your instance.

ref: fix: TypeError in Subcontracting Receipt (backport #38200) by mergify[bot] · Pull Request #38208 · frappe/erpnext · GitHub

2 Likes

Please check docs https://docs.erpnext.com/docs/user/manual/en/serial-and-batch-bundle

Hi Sagar,

This is on the SaaS Vesion. The SaaS is on 15.0.0. Can you guys update the SaaS version to 15.3.0 soonest?

Thanks

Jay

Hi Rohit,

Yes, Data Integrity Issues is a good reason to move to a different configuration. But the complexity is undesirable. Not for me, I will figure it out, but for new users stumbling into ERPNext.

Thanks

Jay

Hi Sagar,

I installed a self hosted version of ver 15 and have ERPNext v15.4.0 (version-15) on it. But I now encounter the following error as I try to submit the Subcontracting Receipt.

Update: I tried switching to v15.0.0 (version-15-hotfix), but I still have the same error.

Traceback (most recent call last):
File “apps/frappe/frappe/app.py”, line 110, in application
response = frappe.api.handle(request)
File “apps/frappe/frappe/api/init.py”, line 49, in handle
data = endpoint(**arguments)
File “apps/frappe/frappe/api/v1.py”, line 36, in handle_rpc_call
return frappe.handler.handle()
File “apps/frappe/frappe/handler.py”, line 49, in handle
data = execute_cmd(cmd)
File “apps/frappe/frappe/handler.py”, line 85, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “apps/frappe/frappe/init.py”, line 1689, in call
return fn(*args, **newargs)
File “apps/frappe/frappe/utils/typing_validations.py”, line 31, in wrapper
return func(*args, **kwargs)
File “apps/frappe/frappe/desk/form/save.py”, line 39, in savedocs
doc.save()
File “apps/frappe/frappe/model/document.py”, line 334, in save
return self.save(*args, **kwargs)
File “apps/frappe/frappe/model/document.py”, line 386, in save
self.run_post_save_methods()
File “apps/frappe/frappe/model/document.py”, line 1118, in run_post_save_methods
self.run_method(“on_update”)
File “apps/frappe/frappe/model/document.py”, line 950, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “apps/frappe/frappe/model/document.py”, line 1316, in composer
return composed(self, method, *args, **kwargs)
File “apps/frappe/frappe/model/document.py”, line 1298, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “apps/frappe/frappe/model/document.py”, line 947, in fn
return method_object(*args, **kwargs)
File “apps/erpnext/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py”, line 87, in on_update
self.set_serial_and_batch_bundle(table_field)
File “apps/erpnext/erpnext/controllers/stock_controller.py”, line 396, in set_serial_and_batch_bundle
frappe.get_doc(“Serial and Batch Bundle”, row.get(field)).set_serial_and_batch_values(
File “apps/erpnext/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py”, line 298, in set_serial_and_batch_values
self.validate_quantity(row, qty_field=qty_field)
File “apps/erpnext/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py”, line 403, in validate_quantity
self.throw_error_message(
File “apps/erpnext/erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.py”, line 122, in throw_error_message
frappe.throw(
(message), exception, title=
(“Error”))
File “apps/frappe/frappe/init.py”, line 577, in throw
msgprint(
File “apps/frappe/frappe/init.py”, line 549, in msgprint
_raise_exception()
File “apps/frappe/frappe/init.py”, line 500, in _raise_exception
raise exc
frappe.exceptions.ValidationError: Total quantity 100.0 in the Serial and Batch Bundle SABB-00000004 does not match with the quantity 0.0 for the Item SIOutsourced in the Subcontracting Receipt # MAT-SCR-2023-00001
request.js:473:14
Unable to handle failed response request.js:362:12
TypeError: o.exception.split(…).at is not a function
call request.js:346
jQuery 4
request.js:363:12
Source map error: Error: JSON.parse: unexpected character at line 1 column 1 of the JSON data
Resource URL: http://144.126.253.4/app/subcontracting-receipt/MAT-SCR-2023-00001
Source Map URL: file_uploader.bundle.4P3TSR2E.css.map

Is there something I am missing? Or is there a problem?

Thanks

Jay