8848digital / erpnext

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

Error while saving Sales Invoice #39

Closed aasif-patel closed 1 month ago

aasif-patel commented 1 month ago

Information about bug

image

App Versions

{
    "erpnext": "15.34.0",
    "frappe": "15.41.0",
    "payments": "0.0.1"
}

Route

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

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 1775, 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 194, in validate
    self.set_incoming_rate()
  File "apps/erpnext/erpnext/controllers/selling_controller.py", line 457, in set_incoming_rate
    d.incoming_rate = get_incoming_rate(
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
  File "apps/erpnext/erpnext/stock/utils.py", line 311, in get_incoming_rate
    in_rate = get_valuation_rate(
  File "apps/erpnext/erpnext/stock/stock_ledger.py", line 1747, in get_valuation_rate
    if last_valuation_rate := frappe.db.sql(
  File "apps/frappe/frappe/database/postgres/database.py", line 218, in sql
    return super().sql(modify_query(query), modify_values(values), *args, **kwargs)
  File "apps/frappe/frappe/database/database.py", line 227, in sql
    self._cursor.execute(query, values)
psycopg2.errors.SyntaxError: syntax error at or near "index"
LINE 2:   from "tabStock Ledger Entry" force index (item_warehouse)
                                             ^

Request Data

{
    "type": "POST",
    "args": {
        "doc": "{\"owner\":\"Administrator\",\"docstatus\":0,\"idx\":0,\"naming_series\":\"ACC-SINV-.YYYY.-\",\"customer\":\"Zudio\",\"customer_name\":\"Zudio\",\"company\":\"8848 Digital\",\"posting_date\":\"2024-09-25\",\"posting_time\":\"17:15:44.675970\",\"set_posting_time\":0,\"due_date\":\"2024-09-25\",\"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\":\"INR\",\"conversion_rate\":1,\"selling_price_list\":\"Standard Selling\",\"price_list_currency\":\"INR\",\"plc_conversion_rate\":1,\"ignore_pricing_rule\":0,\"update_stock\":0,\"set_warehouse\":\"Stores - 8D\",\"total_qty\":1,\"total_net_weight\":0,\"base_total\":20000,\"base_net_total\":20000,\"total\":20000,\"net_total\":20000,\"exempt_from_sales_tax\":0,\"tax_category\":\"\",\"base_total_taxes_and_charges\":0,\"total_taxes_and_charges\":0,\"base_grand_total\":20000,\"base_rounding_adjustment\":0,\"base_rounded_total\":20000,\"base_in_words\":\"\",\"grand_total\":20000,\"rounding_adjustment\":0,\"use_company_roundoff_cost_center\":0,\"rounded_total\":20000,\"in_words\":\"\",\"total_advance\":0,\"outstanding_amount\":20000,\"disable_rounded_total\":0,\"apply_discount_on\":\"Grand Total\",\"base_discount_amount\":0,\"is_cash_or_non_trade_discount\":0,\"additional_discount_percentage\":0,\"discount_amount\":0,\"total_billing_hours\":0,\"total_billing_amount\":0,\"base_paid_amount\":0,\"paid_amount\":0,\"base_change_amount\":0,\"change_amount\":0,\"allocate_advances_automatically\":0,\"only_include_allocated_payments\":0,\"write_off_amount\":0,\"base_write_off_amount\":0,\"write_off_outstanding_amount_automatically\":0,\"redeem_loyalty_points\":0,\"loyalty_points\":0,\"loyalty_amount\":0,\"customer_address\":\"Zudio-Billing\",\"address_display\":\"Rahate colony Nagpur<br>\\nRahate colony Nagpur<br>Nagpur<br>\\nMaharashtra<br>India<br>\\n<br>\\n\",\"territory\":\"All Territories\",\"ignore_default_payment_terms_template\":0,\"po_no\":\"\",\"debit_to\":\"Debtors - 8D\",\"party_account_currency\":\"INR\",\"is_opening\":\"No\",\"amount_eligible_for_commission\":20000,\"commission_rate\":0,\"total_commission\":0,\"group_same_items\":0,\"language\":\"en\",\"status\":\"Draft\",\"customer_group\":\"All Customer Groups\",\"is_internal_customer\":0,\"is_discounted\":0,\"doctype\":\"Sales Invoice\",\"payment_schedule\":[],\"pricing_rules\":[],\"sales_team\":[],\"items\":[{\"owner\":\"Administrator\",\"docstatus\":0,\"idx\":1,\"has_item_scanned\":0,\"item_code\":\"_Test Product Bundle Item\",\"item_name\":\"_Test Product Bundle Item\",\"description\":\"_Test Product Bundle Item 5\",\"item_group\":\"_Test Item Group Desktops\",\"image\":\"\",\"qty\":1,\"stock_uom\":\"_Test UOM\",\"uom\":\"_Test UOM\",\"conversion_factor\":1,\"stock_qty\":1,\"price_list_rate\":0,\"base_price_list_rate\":0,\"margin_type\":\"\",\"margin_rate_or_amount\":0,\"rate_with_margin\":0,\"discount_percentage\":0,\"discount_amount\":0,\"base_rate_with_margin\":0,\"rate\":20000,\"amount\":20000,\"base_rate\":20000,\"base_amount\":20000,\"stock_uom_rate\":0,\"is_free_item\":0,\"grant_commission\":1,\"net_rate\":20000,\"net_amount\":20000,\"base_net_rate\":20000,\"base_net_amount\":20000,\"delivered_by_supplier\":0,\"income_account\":\"Sales - 8D\",\"is_fixed_asset\":0,\"expense_account\":\"Cost of Goods Sold - 8D\",\"enable_deferred_revenue\":0,\"weight_per_unit\":0,\"total_weight\":0,\"warehouse\":\"Stores - 8D\",\"use_serial_batch_fields\":1,\"allow_zero_valuation_rate\":0,\"incoming_rate\":0,\"item_tax_rate\":\"{}\",\"actual_batch_qty\":0,\"actual_qty\":0,\"sales_order\":\"SAL-ORD-2024-00004\",\"so_detail\":\"faflke97ip\",\"delivered_qty\":0,\"cost_center\":\"Main - 8D\",\"page_break\":0,\"parentfield\":\"items\",\"parenttype\":\"Sales Invoice\",\"doctype\":\"Sales Invoice Item\",\"__islocal\":1,\"__unsaved\":1,\"parent\":\"new-sales-invoice-krnnetkwon\",\"name\":\"new-sales-invoice-item-wtlfpbjzdh\"}],\"packed_items\":[{\"owner\":\"Administrator\",\"docstatus\":0,\"idx\":1,\"parent_item\":\"_Test Product Bundle Item\",\"item_code\":\"_Test Item\",\"item_name\":\"_Test Item\",\"warehouse\":\"Stores - 8D\",\"conversion_factor\":1,\"qty\":5,\"rate\":100,\"uom\":\"_Test UOM\",\"use_serial_batch_fields\":1,\"actual_batch_qty\":0,\"actual_qty\":0,\"projected_qty\":0,\"ordered_qty\":0,\"packed_qty\":0,\"incoming_rate\":0,\"picked_qty\":0,\"page_break\":0,\"parentfield\":\"packed_items\",\"parenttype\":\"Sales Invoice\",\"doctype\":\"Packed Item\",\"__islocal\":1,\"__unsaved\":1,\"parent\":\"new-sales-invoice-krnnetkwon\",\"name\":\"new-packed-item-waolerpebn\"},{\"owner\":\"Administrator\",\"docstatus\":0,\"idx\":2,\"parent_item\":\"_Test Product Bundle Item\",\"item_code\":\"_Test Item Home Desktop 100\",\"item_name\":\"_Test Item Home Desktop 100\",\"warehouse\":\"Stores - 8D\",\"conversion_factor\":1,\"qty\":2,\"rate\":100,\"uom\":\"_Test UOM 1\",\"use_serial_batch_fields\":1,\"actual_batch_qty\":0,\"actual_qty\":0,\"projected_qty\":0,\"ordered_qty\":0,\"packed_qty\":0,\"incoming_rate\":0,\"picked_qty\":0,\"page_break\":0,\"parentfield\":\"packed_items\",\"parenttype\":\"Sales Invoice\",\"doctype\":\"Packed Item\",\"__islocal\":1,\"__unsaved\":1,\"parent\":\"new-sales-invoice-krnnetkwon\",\"name\":\"new-packed-item-ldjxhdvvhq\"}],\"advances\":[],\"taxes\":[],\"timesheets\":[],\"payments\":[],\"__islocal\":1,\"__onload\":{\"load_after_mapping\":true},\"__unsaved\":1,\"name\":\"new-sales-invoice-krnnetkwon\",\"__last_sync_on\":\"2024-09-25T11:45:44.870Z\",\"company_address\":\"\",\"company_address_display\":\"\"}",
        "action": "Save"
    },
    "btn": {
        "jQuery37005210542253980851": {
            "events": {
                "click": [
                    {
                        "type": "click",
                        "origType": "click",
                        "guid": 25228,
                        "namespace": ""
                    }
                ]
            }
        }
    },
    "freeze": true,
    "headers": {},
    "error_handlers": {},
    "url": "/api/method/frappe.desk.form.save.savedocs",
    "request_id": null
}

Response Data

{
    "exception": "",
    "exc_type": "SyntaxError",
    "_exc_source": "erpnext (app)",
    "_debug_messages": "[\"Syntax error in query:\\nselect valuation_rate\\n\\t\\tfrom \\\"tabStock Ledger Entry\\\" force index (item_warehouse)\\n\\t\\twhere\\n\\t\\t\\titem_code = %s\\n\\t\\t\\tAND warehouse = %s\\n\\t\\t\\tAND valuation_rate >= '0'\\n\\t\\t\\tAND is_cancelled = '0'\\n\\t\\t\\tAND NOT (voucher_no = %s AND voucher_type = %s)\\n\\t\\torder by posting_date desc, posting_time desc, name desc limit 1 ['_Test Item', 'Stores - 8D', 'ACC-SINV-2024-00001', 'Sales Invoice']\"]"
}

Module

accounts

Version

ERPNext v15 Frappe V15

Installation method

manual install

Relevant log output / Stack trace / Full Error Message.

No response

shubham-DT commented 1 month ago

Issue is resolved for submit and few more issues was appearing on cancelling the document ....fixed it too PR 84

aasif-patel commented 1 month ago

Resolved, Hence closing...