Skip to content

Stock Entry Save Fails Due to Missing taxes Attribute in India Compliance GST Validation #3401

@sagarrgarg

Description

@sagarrgarg

Information about bug

erpnext: 15.58.2
frappe: 15.65.2
india_compliance: 15.17.1

File "apps/india_compliance/india_compliance/gst_india/overrides/transaction.py", line 639, in validate_items
if not any(row.get("dont_recompute_tax") for row in doc.taxes):
AttributeError: 'StockEntry' object has no attribute 'taxes'

Steps to Reproduce
Go to Stock Entry

Choose Material Transfer

Fill in all required fields

Click Save

Expected Behavior
Stock Entry should save successfully if all mandatory and logical validations pass.

Actual Behavior
System throws an exception due to assumption that .taxes field exists in Stock Entry document.

Root Cause
validate_items(doc) in transaction.py assumes all documents passed to it will contain a .taxes attribute. However, Stock Entry does not have a taxes field in its schema.

Suggested Fix
Add a guard clause in validate_items to ensure .taxes exists:

python
Copy
Edit
if not hasattr(doc, "taxes"):
return True
Or update the ignore_gst_validations logic to skip Stock Entries entirely if GST isn't relevant:

python
Copy
Edit
if doc.doctype == "Stock Entry":
return True
Additional Notes
This issue breaks basic functionality of ERPNext Stock Entry, which is unrelated to tax validations. Kindly prioritize a patch. I'm happy to raise a PR if needed.

Version

erpnext: 15.58.2
frappe: 15.65.2
india_compliance: 15.17.1

Relevant log output / Stack trace / Full Error Message.

### App Versions

{
	"business_needed_solutions": "0.0.1",
	"erpnext": "15.58.2",
	"frappe": "15.65.2",
	"india_compliance": "15.17.1",
	"insights": "2.2.9",
	"location_based_series": "0.0.1"
}

### Route

Form/Stock Entry/new-stock-entry-vtnwkihaxc

### Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 115, 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 51, in handle
    data = execute_cmd(cmd)
           ^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 84, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1739, 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 378, in save
    return self._save(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 400, in _save
    return self.insert()
           ^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 309, in insert
    self.run_before_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1136, in run_before_save_methods
    self.run_method("validate")
  File "apps/frappe/frappe/model/document.py", line 1007, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1367, in composer
    return composed(self, method, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1351, in runner
    add_to_return_value(self, f(self, method, *args, **kwargs))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/india_compliance/india_compliance/gst_india/overrides/subcontracting_transaction.py", line 181, in validate
    if ignore_gst_validations_for_subcontracting(doc):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/india_compliance/india_compliance/gst_india/overrides/subcontracting_transaction.py", line 531, in ignore_gst_validations_for_subcontracting
    if ignore_gst_validations(doc):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/india_compliance/india_compliance/gst_india/overrides/transaction.py", line 1883, in ignore_gst_validations
    or validate_items(doc, throw) is False
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/india_compliance/india_compliance/gst_india/overrides/transaction.py", line 639, in validate_items
    if not any(row.get("dont_recompute_tax") for row in doc.taxes):
                                                        ^^^^^^^^^
AttributeError: 'StockEntry' object has no attribute 'taxes'


### Request Data

{
	"type": "POST",
	"args": {
		"doc": "{\"docstatus\":0,\"doctype\":\"Stock Entry\",\"name\":\"new-stock-entry-vtnwkihaxc\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"sagarratangarg@rbcolour.com\",\"naming_series\":\"MAT-STE-\",\"purpose\":\"Material Transfer\",\"add_to_transit\":1,\"custom_sales_order\":[],\"company\":\"Radha Kishan Color World\",\"posting_date\":\"2025-05-25\",\"set_posting_time\":0,\"inspection_required\":0,\"apply_putaway_rule\":0,\"from_bom\":0,\"use_multi_level_bom\":1,\"items\":[{\"docstatus\":0,\"doctype\":\"Stock Entry Detail\",\"name\":\"new-stock-entry-detail-xlpcfaxbdc\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"sagarratangarg@rbcolour.com\",\"has_item_scanned\":0,\"is_finished_item\":0,\"is_scrap_item\":0,\"retain_sample\":0,\"stock_uom\":\"Pcs\",\"allow_zero_valuation_rate\":0,\"set_basic_rate_manually\":0,\"use_serial_batch_fields\":0,\"cost_center\":\"Main - RKCW\",\"allow_alternative_item\":0,\"parent\":\"new-stock-entry-vtnwkihaxc\",\"parentfield\":\"items\",\"parenttype\":\"Stock Entry\",\"idx\":1,\"s_warehouse\":\"Kalwari Finished Goods - RKCW\",\"actual_qty\":50400,\"basic_rate\":8.331,\"basic_amount\":419882.4,\"t_warehouse\":\"Kalwari  - RKCW\",\"gst_hsn_code\":\"32049000\",\"item_group\":\"Gulal\",\"item_code\":\"Kay-1\",\"qty\":50400,\"transfer_qty\":50400,\"conversion_factor\":1,\"sample_quantity\":0,\"additional_cost\":0,\"valuation_rate\":0,\"amount\":0,\"taxable_value\":0,\"igst_rate\":0,\"cgst_rate\":0,\"sgst_rate\":0,\"cess_rate\":0,\"cess_non_advol_rate\":0,\"igst_amount\":0,\"cgst_amount\":0,\"sgst_amount\":0,\"cess_amount\":0,\"cess_non_advol_amount\":0,\"transferred_qty\":0,\"uom\":\"Pcs\",\"description\":\"<div><p>Captain Color Powder </p></div>\",\"item_name\":\"Captain Color Powder \",\"expense_account\":\"Stock Adjustment - RKCW\"}],\"doc_references\":[],\"additional_costs\":[],\"mode_of_transport\":\"Road\",\"lr_date\":\"2025-05-25\",\"gst_vehicle_type\":\"Regular\",\"is_opening\":\"No\",\"is_return\":0,\"bill_to_address_display\":\"\",\"taxes_and_charges\":\"\",\"posting_time\":\"22:15:06\",\"stock_entry_type\":\"Material Transfer\",\"total_additional_costs\":0,\"idx\":0,\"fg_completed_qty\":0,\"process_loss_percentage\":0,\"process_loss_qty\":0,\"total_outgoing_value\":0,\"total_incoming_value\":0,\"value_difference\":0,\"distance\":0,\"per_transferred\":0,\"total_amount\":0,\"total_taxes\":0,\"base_grand_total\":0,\"to_warehouse\":\"\",\"address_display\":null,\"purchase_receipt_no\":null,\"supplier_address\":null,\"supplier_name\":null,\"supplier\":null,\"sales_invoice_no\":null,\"delivery_note_no\":null,\"customer_address\":null,\"customer_name\":null,\"customer\":null,\"custom_for_which_warehouse_to_transfer\":\"Kalwari  - RKCW\"}",
		"action": "Save"
	},
	"btn": {
		"jQuery370086236341749534961": {
			"events": {
				"click": [
					{
						"type": "click",
						"origType": "click",
						"guid": 4383,
						"namespace": ""
					}
				]
			}
		}
	},
	"freeze": true,
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.form.save.savedocs",
	"request_id": "c6ae85fd-b33b-4689-b8e5-1af346d1af8b"
}

### Response Data

{
	"exception": "AttributeError: 'StockEntry' object has no attribute 'taxes'",
	"exc_type": "AttributeError",
	"_exc_source": "india_compliance (app)"
}

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

vorasmit

vorasmit commented on May 30, 2025

@vorasmit
Member

Custom field should be there. Not sure why it doesn't exist. Did you migrate your site?

added
questionFurther information is requested
and removed
bugSomething isn't working
on May 30, 2025
sagarrgarg

sagarrgarg commented on Jul 22, 2025

@sagarrgarg
Author

Migration didn't work, Reinstalling worked, Which caused EInvoices and Ewaybills log missing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sagarrgarg@vorasmit

        Issue actions

          Stock Entry Save Fails Due to Missing taxes Attribute in India Compliance GST Validation · Issue #3401 · resilient-tech/india-compliance