AttributeError: 'NoneType' object has no attribute 'fieldtype' Possible source of error: erpnext

Description of the issue

I found out an issue in Point of Sale using Tax-Rate.
Basically when I add a product with a defined tax in my basket and I’m going to checkout it I got following error:

AttributeError: 'NoneType' object has no attribute 'fieldtype' Possible source of error: erpnext (app)

Context information (for bug reports)

Digging inside code I found out the issue.
The function def update_itemised_tax_data(doc) in /frappe-bench/apps/erpnext/erpnext/regional/italy/utils.py is making an assignment in line 27 row.tax_rate = flt(tax_rate, row.precision("tax_rate")).

The call function row.precision("tax_rate") has its definition def precision(self, fieldname, parentfield=None) -> int | None in /frappe-bench/apps/frappe/frappe/model/base_document.py in line 1133.

At line 1155 (same function) basically we got this issue.
In this particular circumstances df = frappe.get_meta(doctype).get_field(fieldname) is None and it create the error in the next if statement at line 1157: if df.fieldtype in ("Currency", "Float", "Percent"):

Steps to sort the issue

To sort this annoying issue we need to apply changes at /frappe-bench/apps/frappe/frappe/model/base_document.py.
We need to check the existence of df in the if statement at line 1157: if df and df.fieldtype in ("Currency", "Float", "Percent"):

Additional information

OS Rocky Linux 9.4, Frappe Framework: v15.43.0, ERPNext: v15.38.0

GitHub issue report

I reported same issue with my solution also in GitHub AttributeError: 'NoneType' object has no attribute 'fieldtype' Possible source of error: erpnext (app) · Issue #28039 · frappe/frappe · GitHub

Can someone please help me to send the solution to the developer team?

Fork the Frappe and make PR. If it is really a bug, Frappe team will look into it.

Well… it is a bug because without this fix on a fresh installation I got the descripted problem. Same thing on another installation done by a friend of mine.