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

Item_code error in POS [Bug V11] #15799

Closed Ravn10 closed 6 years ago

Ravn10 commented 6 years ago

Traceback (most recent call last): File "/home/vickyreddy1995/frappe-bench/apps/frappe/frappe/app.py", line 55, in application response = frappe.handler.handle() File "/home/vickyreddy1995/frappe-bench/apps/frappe/frappe/handler.py", line 20, in handle data = execute_cmd(cmd) File "/home/vickyreddy1995/frappe-bench/apps/frappe/frappe/handler.py", line 55, in execute_cmd return frappe.call(method, *frappe.form_dict) File "/home/vickyreddy1995/frappe-bench/apps/frappe/frappe/init.py", line 1007, in call return fn(args, **newargs) File "/home/vickyreddy1995/frappe-bench/apps/erpnext/erpnext/selling/page/point_of_sale/point_of_sale.py", line 71, in get_items }, as_dict=1) File "/home/vickyreddy1995/frappe-bench/apps/frappe/frappe/database/database.py", line 154, in sql self._cursor.execute(query, values) File "/home/vickyreddy1995/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py", line 168, in execute query = self.mogrify(query, args) File "/home/vickyreddy1995/frappe-bench/env/local/lib/python2.7/site-packages/pymysql/cursors.py", line 147, in mogrify query = query % self._escape_args(args, conn) KeyError: 'item_code'

Ravn10 commented 6 years ago

output of bench version erpnext 12.x.x-develop foundation 0.0.1 frappe 12.x.x-develop

jigneshpshah commented 6 years ago

Please mention the steps to reproduce the error.

Actual Behavior

Expected Behavior

umairsy commented 6 years ago

As requested, please mention the steps. If still replicating, we can reopen this issue.

agustincl commented 6 years ago

Need 'item_code': item_code, in the sql expression.

Bug Fix: Add in point_of_sale.py 'item_code': item_code

    if display_items_in_stock == 0:
        res = frappe.db.sql("""select i.name as item_code, i.item_name, i.image as item_image,
            i.is_stock_item, item_det.price_list_rate, item_det.currency
            from `tabItem` i LEFT JOIN
                (select item_code, price_list_rate, currency from
                    `tabItem Price` where price_list=%(price_list)s) item_det
            ON
                (item_det.item_code=i.name or item_det.item_code=i.variant_of)
            where
                i.disabled = 0 and i.has_variants = 0 and i.is_sales_item = 1
                and i.item_group in (select name from `tabItem Group` where lft >= {lft} and rgt <= {rgt})
                and {condition} limit {start}, {page_length}""".format(
                    start=start,
                    page_length=page_length,
                    lft=lft,
                    rgt=rgt,
                    condition=condition
            ), {
                'price_list': price_list,
                'item_code': item_code
            }, as_dict=1)

        res = {
        'items': res
        }

    elif display_items_in_stock == 1:
ahmadRagheb commented 6 years ago

new issue raise when fixing this one File "/home/frappe/frappe-bench/apps/erpnext/erpnext/selling/page/point_of_sale/point_of_sale.py", line 27, in get_items item_code = data.get("item_code") if data.get("item_code") else search_value AttributeError: 'NoneType' object has no attribute 'get'

ahmadRagheb commented 6 years ago

@umairsy

ahmadRagheb commented 6 years ago

i tried it with new fresh database and the latest versions of erpnext and frappe still have the issue

ahmadRagheb commented 6 years ago

@agustincl even after you fix it this way no items shows and new error raise

ahmadRagheb commented 6 years ago

this happen in version 12 not v11 (for me )

ahmadRagheb commented 6 years ago

okay okay .. guys i add this this line as @agustincl said .. and then i go to pos profile and check on ( Display Items In Stock) and POS Settings i checked Use POS in Offline Mode and it works like a charm

ahmadRagheb commented 6 years ago

i stashed my changes .. it works .. it was a checkboxes issue !!! soluation is : go to pos profile and check on ( Display Items In Stock) and POS Settings i checked Use POS in Offline Mode and it works like a charm