AttributeError: 'SalesOrderItem' object has no attribute 'batch_no'

Hello every one,
I was doing some customizations in Sales order, I needed to add new field in the item table to select the serial no for the selected item.
what happend is
1- added new field in the sales order item, the item is data.
2- replaced the previous item with anoter link filed with and mention Serial No in the options
the reusult in the both cases is the following message and no submit
AttributeError: ‘SalesOrderItem’ object has no attribute ‘batch_no’

could you help please

Hi,

It may help to post a screenshot of the row added to the Sales Order Item form.

Share full traceback from browser / console.

jquery.min.js:4 POST https://saleh.flexsofts.com/api/method/frappe.desk.form.save.savedocs 500 (INTERNAL SERVER ERROR)
send @ jquery.min.js:4
ajax @ jquery.min.js:4
frappe.request.call @ request.js:219
frappe.call @ request.js:91
u @ save.js:203
frappe.ui.form.save @ save.js:25
(anonymous) @ form.js:579
Promise.then (async)
(anonymous) @ dom.js:261
frappe.run_serially @ dom.js:259
validate_and_save @ form.js:570
(anonymous) @ form.js:518
save @ form.js:515
Save @ toolbar.js:432
(anonymous) @ page.js:171
dispatch @ jquery.min.js:3
r.handle @ jquery.min.js:3
request.js:355 Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py”, line 21, in savedocs
doc.save()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 273, in save
return self._save(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 296, in _save
self.insert()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 230, in insert
self.run_before_save_methods()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 901, in run_before_save_methods
self.run_method(“validate”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 802, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1081, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1064, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 796, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/stock/doctype/material_request/material_request.py”, line 62, in validate
super(MaterialRequest, self).validate()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/controllers/buying_controller.py”, line 39, in validate
super(BuyingController, self).validate()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/controllers/stock_controller.py”, line 24, in validate
self.validate_serialized_batch()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/controllers/stock_controller.py”, line 51, in validate_serialized_batch
if not (hasattr(d, ‘serial_no’) and d.serial_no and d.batch_no): continue
AttributeError: ‘MaterialRequestItem’ object has no attribute ‘batch_no’

request.js:355 Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 67, in application
response = frappe.api.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/api.py”, line 59, in handle
return frappe.handler.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 24, in handle
data = execute_cmd(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 64, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 1075, in call
return fn(*args, **newargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py”, line 21, in savedocs
doc.save()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 273, in save
return self._save(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 296, in _save
self.insert()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 230, in insert
self.run_before_save_methods()
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 901, in run_before_save_methods
self.run_method(“validate”)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 802, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1081, in composer
return composed(self, method, *args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 1064, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 796, in
fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/stock/doctype/material_request/material_request.py”, line 62, in validate
super(MaterialRequest, self).validate()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/controllers/buying_controller.py”, line 39, in validate
super(BuyingController, self).validate()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/controllers/stock_controller.py”, line 24, in validate
self.validate_serialized_batch()
File “/home/frappe/frappe-bench/apps/erpnext/erpnext/controllers/stock_controller.py”, line 51, in validate_serialized_batch
if not (hasattr(d, ‘serial_no’) and d.serial_no and d.batch_no): continue
AttributeError: ‘MaterialRequestItem’ object has no attribute ‘batch_no’

If you have edited existing link field of Sales Order Item, then probably it is causing the issue.
That replaced link field probably, has script in the sales_order_item.js which is causing the issue.
Replace with existing link field with original field and check if the issue persists.

Probably you will have to write custom script to fetch the replaced field in place of existing field.

I tried a link field type and small text feild with the same name in the sales order, the issue happend when there is a value in the new feild.
I hope if you can help, thanks in advance…