frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)
https://erpnext.com
GNU General Public License v3.0
21.87k stars 7.33k forks source link

Bug: Unknown Column 'tax_type' in offline POS #18266

Closed madappally closed 5 years ago

madappally commented 5 years ago

I can’t open POS in offline mode becasue of Unknown Column ‘tax_type’ error (See screenshot) Screenshot (38)

I’ve checked the database table and confirmed that there no such a column in tabItem Tax;

Here is the result of ‘tabItem Tax’ table MariaDB [_7f9f4ce860d7d369]> desc tabItem Tax; ±------------------±-------------±-----±----±--------±------+ | Field | Type | Null | Key | Default | Extra | ±------------------±-------------±-----±----±--------±------+ | name | varchar(140) | NO | PRI | NULL | | | creation | datetime(6) | YES | | NULL | | | modified | datetime(6) | YES | MUL | NULL | | | modified_by | varchar(140) | YES | | NULL | | | owner | varchar(140) | YES | | NULL | | | docstatus | int(1) | NO | | 0 | | | parent | varchar(140) | YES | MUL | NULL | | | parentfield | varchar(140) | YES | | NULL | | | parenttype | varchar(140) | YES | | NULL | | | idx | int(8) | NO | | 0 | | | item_tax_template | varchar(140) | YES | | NULL | | | tax_category | varchar(140) | YES | | NULL | | ±------------------±-------------±-----±----±--------±------+ 12 rows in set (0.002 sec)

Installation Details: ERPNext: v12.x.x-develop () (develop) Frappe Framework: v12.x.x-develop () (develop) OS: Centos7 Python: 2.7 Database: mysql Ver 15.1 Distrib 10.3.16-MariaDB

madappally commented 5 years ago

This is the code that causing problem. File: erpnext/accounts/doctype/sales_invoice/pos.py

def get_item_tax_data():

    itemwise_tax = {}
    taxes = frappe.db.sql(""" select parent, tax_type, tax_rate from `tabItem Tax`""", as_dict=1)

    for tax in taxes:
        if tax.parent not in itemwise_tax:
            itemwise_tax.setdefault(tax.parent, {})
        itemwise_tax[tax.parent][tax.tax_type] = tax.tax_rate

    return itemwise_tax
madappally commented 5 years ago

Solved the problem by changing 'tabItem Tax' to 'tabItem Tax Template Detail'. taxes = frappe.db.sql(""" select parent, tax_type, tax_rate fromtabItem Tax Template Detail""", as_dict=1)