AttributeError: 'NoneType' object has no attribute 'fieldtype' error

@NCP @Jeel While creating new sales invoice with sales tax template getting this error. when we do this same without sales tax charges it is getting saved. anybody please?

Share the full error log and which version you are using.

1 Like

@NCP Thanks for your respose
here is the version you asked for
ERPNext: v15.33.2 (version-15)
Frappe Framework: v15.39.0 (version-15)
and here is the error log you asked for

App Versions

{
	"erpnext": "15.33.2",
	"erpnext_ksa": "0.0.1",
	"frappe": "15.39.0"
}

Route

Form/Sales Invoice/new-sales-invoice-hnhbuzqyeo

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 114, 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 1768, 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 337, in save
    return self._save(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 359, in _save
    return self.insert()
           ^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 291, in insert
    self.run_before_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1091, in run_before_save_methods
    self.run_method("validate")
  File "apps/frappe/frappe/model/document.py", line 962, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1322, in composer
    return composed(self, method, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1304, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 959, in fn
    return method_object(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py", line 265, in validate
    super().validate()
  File "apps/erpnext/erpnext/controllers/selling_controller.py", line 29, in validate
    super().validate()
  File "apps/erpnext/erpnext/controllers/stock_controller.py", line 52, in validate
    super().validate()
  File "apps/erpnext/erpnext/controllers/accounts_controller.py", line 198, in validate
    self.calculate_taxes_and_totals()
  File "apps/erpnext/erpnext/controllers/accounts_controller.py", line 522, in calculate_taxes_and_totals
    calculate_taxes_and_totals(self)
  File "apps/erpnext/erpnext/controllers/taxes_and_totals.py", line 35, in __init__
    self.calculate()
  File "apps/erpnext/erpnext/controllers/taxes_and_totals.py", line 66, in calculate
    self.set_item_wise_tax_breakup()
  File "apps/erpnext/erpnext/controllers/taxes_and_totals.py", line 945, in set_item_wise_tax_breakup
    self.doc.other_charges_calculation = get_itemised_tax_breakup_html(self.doc)
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/controllers/taxes_and_totals.py", line 994, in get_itemised_tax_breakup_html
    update_itemised_tax_data(doc)
  File "apps/erpnext/erpnext/__init__.py", line 149, in caller
    return frappe.get_attr(overrides[function_path][-1])(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext_ksa/erpnext_ksa/utils.py", line 174, in update_itemised_tax_data
    row.tax_rate = flt(tax_rate, row.precision("tax_rate"))
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/base_document.py", line 1153, in precision
    if df.fieldtype in ("Currency", "Float", "Percent"):
       ^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'fieldtype'

Request Data

{
	"type": "POST",
	"args": {
		"doc": "{\"docstatus\":0,\"doctype\":\"Sales Invoice\",\"name\":\"new-sales-invoice-isffdbrqtp\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"Administrator\",\"naming_series\":\"ACC-SINV-.YYYY.-\",\"company\":\"AGC Networks (Demo)\",\"posting_date\":\"2024-08-20\",\"set_posting_time\":0,\"is_pos\":0,\"is_consolidated\":0,\"is_return\":0,\"update_outstanding_for_self\":1,\"update_billed_amount_in_sales_order\":0,\"update_billed_amount_in_delivery_note\":1,\"is_debit_note\":0,\"currency\":\"SAR\",\"selling_price_list\":\"Standard Selling\",\"price_list_currency\":\"SAR\",\"ignore_pricing_rule\":0,\"update_stock\":0,\"items\":[{\"docstatus\":0,\"doctype\":\"Sales Invoice Item\",\"name\":\"new-sales-invoice-item-ryvtqejzmk\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"Administrator\",\"has_item_scanned\":0,\"stock_uom\":\"Nos\",\"margin_type\":\"\",\"is_free_item\":0,\"grant_commission\":1,\"delivered_by_supplier\":0,\"is_fixed_asset\":0,\"enable_deferred_revenue\":0,\"use_serial_batch_fields\":0,\"allow_zero_valuation_rate\":0,\"cost_center\":\"Main - AND\",\"page_break\":0,\"parent\":\"new-sales-invoice-isffdbrqtp\",\"parentfield\":\"items\",\"parenttype\":\"Sales Invoice\",\"idx\":1,\"net_rate\":100,\"qty\":1,\"amount\":100,\"net_amount\":100,\"total_weight\":0,\"base_price_list_rate\":100,\"base_rate\":100,\"base_amount\":100,\"base_net_rate\":100,\"base_net_amount\":100,\"is_zero_rated\":0,\"is_exempt\":0,\"item_code\":\"SKU005\",\"weight_per_unit\":0,\"weight_uom\":null,\"conversion_factor\":1,\"barcode\":null,\"pricing_rules\":\"\",\"item_name\":\"Sneakers\",\"description\":\"Sneakers\",\"image\":\"https://images.pexels.com/photos/1598505/pexels-photo-1598505.jpeg\",\"warehouse\":null,\"income_account\":\"Sales - AND\",\"expense_account\":\"Cost of Goods Sold - AND\",\"discount_account\":null,\"provisional_expense_account\":null,\"has_serial_no\":0,\"has_batch_no\":0,\"batch_no\":null,\"uom\":\"Nos\",\"min_order_qty\":\"\",\"stock_qty\":1,\"price_list_rate\":100,\"rate\":100,\"discount_percentage\":0,\"discount_amount\":0,\"update_stock\":0,\"last_purchase_rate\":0,\"transaction_date\":\"2024-08-20\",\"against_blanket_order\":null,\"bom_no\":null,\"item_group\":\"Demo Item Group\",\"brand\":null,\"manufacturer\":null,\"manufacturer_part_no\":null,\"item_tax_rate\":\"{}\",\"customer_item_code\":null,\"has_margin\":false,\"free_item_data\":[],\"child_docname\":\"new-sales-invoice-item-ryvtqejzmk\",\"rate_with_margin\":0,\"base_rate_with_margin\":0,\"margin_rate_or_amount\":0,\"stock_uom_rate\":100}],\"taxes\":[{\"docstatus\":0,\"doctype\":\"Sales Taxes and Charges\",\"name\":\"new-sales-taxes-and-charges-tvwvwjlfgd\",\"__islocal\":1,\"__unsaved\":1,\"owner\":\"Administrator\",\"charge_type\":\"On Net Total\",\"included_in_print_rate\":0,\"included_in_paid_amount\":0,\"cost_center\":\"Main - AND\",\"account_currency\":\"SAR\",\"dont_recompute_tax\":0,\"parent\":\"new-sales-invoice-isffdbrqtp\",\"parentfield\":\"taxes\",\"parenttype\":\"Sales Invoice\",\"idx\":1,\"row_id\":null,\"account_head\":\"VAT 15% - AND\",\"description\":\"VAT 15%\",\"rate\":15,\"tax_amount\":15,\"total\":115,\"tax_amount_after_discount_amount\":15,\"base_tax_amount\":15,\"base_total\":115,\"base_tax_amount_after_discount_amount\":15,\"item_wise_tax_detail\":\"{\\\"SKU005\\\":[15,15]}\"}],\"use_company_roundoff_cost_center\":0,\"disable_rounded_total\":0,\"apply_discount_on\":\"Grand Total\",\"is_cash_or_non_trade_discount\":0,\"pricing_rules\":[],\"packed_items\":[],\"timesheets\":[],\"total_billing_amount\":0,\"payments\":[],\"allocate_advances_automatically\":0,\"only_include_allocated_payments\":0,\"advances\":[],\"write_off_outstanding_amount_automatically\":0,\"redeem_loyalty_points\":0,\"ignore_default_payment_terms_template\":0,\"payment_schedule\":[],\"party_account_currency\":\"SAR\",\"is_opening\":\"No\",\"sales_team\":[],\"group_same_items\":0,\"status\":\"Draft\",\"is_internal_customer\":0,\"is_discounted\":0,\"conversion_rate\":1,\"plc_conversion_rate\":1,\"total_billing_hours\":0,\"company_tax_id\":\"311111111111113\",\"company_trn\":\"311111111111113\",\"company_address\":null,\"posting_time\":\"14:12:10\",\"company_address_display\":null,\"base_net_total\":100,\"net_total\":100,\"base_total\":100,\"total\":100,\"total_qty\":1,\"rounding_adjustment\":0,\"grand_total\":115,\"base_grand_total\":115,\"total_taxes_and_charges\":15,\"base_total_taxes_and_charges\":15,\"base_rounding_adjustment\":0,\"rounded_total\":115,\"base_rounded_total\":115,\"in_words\":\"\",\"base_in_words\":\"\",\"base_discount_amount\":0,\"total_advance\":0,\"base_paid_amount\":0,\"paid_amount\":0,\"change_amount\":0,\"base_change_amount\":0,\"outstanding_amount\":null,\"amount_eligible_for_commission\":100,\"total_commission\":null,\"tax_id\":null,\"customer_name\":\"Palmer Productions Ltd.\",\"customer_name_in_arabic\":null,\"loyalty_program\":null,\"represents_company\":null,\"customer\":\"Palmer Productions Ltd.\",\"debit_to\":\"Debtors - AND\",\"due_date\":\"2024-08-20\",\"customer_address\":null,\"address_display\":null,\"shipping_address_name\":null,\"shipping_address\":null,\"tax_category\":\"\",\"contact_person\":null,\"contact_display\":null,\"contact_email\":null,\"contact_mobile\":null,\"customer_group\":\"Demo Customer Group\",\"territory\":null,\"language\":\"en\",\"payment_terms_template\":null,\"total_net_weight\":0,\"taxes_and_charges\":\"VAT 15% - AND\"}",
		"action": "Save"
	},
	"btn": {
		"jQuery370086228839449238251": {
			"events": {
				"click": [
					{
						"type": "click",
						"origType": "click",
						"guid": 23598,
						"namespace": ""
					}
				]
			}
		}
	},
	"freeze": true,
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.form.save.savedocs",
	"request_id": null
}

Response Data

{
	"exception": "AttributeError: 'NoneType' object has no attribute 'fieldtype'",
	"exc_type": "AttributeError",
	"_exc_source": "erpnext (app)"
}

Error from the erpnext_ksa app, and I don’t have any idea about that app. I also don’t know if it is supported for version 15 or not.

@NCP Thanking again for your fast response. So may i know if i remove this app from the sites will resolve ?

yes … ! and remove the app, and migrate the site.

@NCP also in my error it indicates that the error source is from erpnext.

Because many methods and functions have been updated in the latest version, your erpnext_ksa has not been updated for 2 years. The issue lies in the outdated erpnext_ksa app.

1 Like

@NCP thanks for your reply and after removing the problem is solved

@NCP Thank you very much.

Hi @jaassim

Use this app for KSA VAT same functionality

@Usama_Naveed Thanks for your information. This repository works fine.