frappe / erpnext

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

Unable to repost item valuation #36634

Closed maveezmh closed 10 months ago

maveezmh commented 1 year ago

Information about bug

the system is unable to repost valuation rate doctype. it stays in queue and gets timed out.

Module

stock

Version

ERPNext: v14.34.2 (HEAD)

Frappe Framework: v14.44.0 (HEAD)

Frappe HR: v14.10.0 (HEAD)

Payments: v0.0.1 (HEAD)

Installation method

FrappeCloud

Relevant log output / Stack trace / Full Error Message.

Traceback with variables (most recent call last):
  File "apps/erpnext/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py", line 239, in repost
    repost_sl_entries(doc)
      doc = <RepostItemValuation: ea09904863 docstatus=1>
      e = JobTimeoutException('Task exceeded maximum timeout value (1500 seconds)')
      traceback = 'Traceback (most recent call last):\n  File "apps/erpnext/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py", line 239, in repost\n    repost_sl_entries(doc)\n  File "apps/erpnext/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py", line 273, in repost_sl_entries\n    repost_future_sle(\n  File "apps/erpnext/erpnext/stock/stock_ledger.py", line 234, in repost_future_sle\n    obj = update_entries_after(\n  File "apps/erpnext/erpnext/stock/stock_ledger.py", line 395, in __init__\n    self.build()\n  File "apps/erpnext/erpnext/stock/stock_ledger.py", line 454, in build\n    self.process_sle(sle)\n  File "apps/erpnext/erpnext/stock/stock_ledger.py", line 634, in process_sle\n    self.update_outgoing_rate_on_transaction(sle)\n  File "apps/erpnext/erpnext/stock/stock_ledger.py", line 748, in update_outgoing_rate_on_transaction\n    self.update_rate_on_stock_entry(sle, outgoing_rate)\n  File "apps/erpnext/erpnext/stock/stock_ledger.py", line 763, in update...
  File "apps/erpnext/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py", line 273, in repost_sl_entries
    repost_future_sle(
      doc = <RepostItemValuation: ea09904863 docstatus=1>
  File "apps/erpnext/erpnext/stock/stock_ledger.py", line 234, in repost_future_sle
    obj = update_entries_after(
      args = [{'item_code': 'Garlic', 'warehouse': 'Stores - DPRCL', 'posting_date': datetime.date(2023, 3, 15), 'posting_time': datetime.timedelta(seconds=86399), 'creation': datetime.datetime(2023, 8, 12, 8, 57, 30, 40945)}, {'item_code': 'Chicken', 'warehouse': 'Stores - DPRCL', 'posting_date': datetime.date(2023, 3, 15), 'posting_time': datetime.timedelta(seconds=86399), 'creation': datetime.datetime(2023, 8, 12, 8, 57, 30, 100121)}, {'item_code': 'Green pepper', 'warehouse': 'Stores - DPRCL', 'posting_date': datetime.date(2023, 3, 15), 'posting_time': datetime.timedelta(seconds=86399), 'creation': datetime.datetime(2023, 8, 12, 8, 57, 30, 135821)}, {'item_code': 'Onions', 'warehouse': 'Stores - DPRCL', 'posting_date': datetime.date(2023, 3, 15), 'posting_time': datetime.timedelta(seconds=86399), 'creation': datetime.datetime(2023, 8, 12, 8, 57, 30, 162701)}, {'item_code': 'Parsley', 'warehouse': 'Stores - DPRCL', 'posting_date': datetime.date(2023, 3, 15), 'posting_time': datetime.timedelta(se...
      voucher_type = 'Stock Entry'
      voucher_no = 'MAT-STE-2023-00634'
      allow_negative_stock = 1
      via_landed_cost_voucher = 0
      doc = <RepostItemValuation: ea09904863 docstatus=1>
      items_to_be_repost = [{'item_code': 'Garlic', 'warehouse': 'Stores - DPRCL', 'posting_date': datetime.date(2023, 3, 15), 'posting_time': datetime.timedelta(seconds=86399), 'creation': datetime.datetime(2023, 8, 12, 8, 57, 30, 40945)}, {'item_code': 'Chicken', 'warehouse': 'Stores - DPRCL', 'posting_date': datetime.date(2023, 3, 15), 'posting_time': datetime.timedelta(seconds=86399), 'creation': datetime.datetime(2023, 8, 12, 8, 57, 30, 100121)}, {'item_code': 'Green pepper', 'warehouse': 'Stores - DPRCL', 'posting_date': datetime.date(2023, 3, 15), 'posting_time': datetime.timedelta(seconds=86399), 'creation': datetime.datetime(2023, 8, 12, 8, 57, 30, 135821)}, {'item_code': 'Onions', 'warehouse': 'Stores - DPRCL', 'posting_date': datetime.date(2023, 3, 15), 'posting_time': datetime.timedelta(seconds=86399), 'creation': datetime.datetime(2023, 8, 12, 8, 57, 30, 162701)}, {'item_code': 'Parsley', 'warehouse': 'Stores - DPRCL', 'posting_date': datetime.date(2023, 3, 15), 'posting_time': datetime.timedelta(se...
      distinct_item_warehouses = {('Garlic', 'Stores - DPRCL'): {'reposting_status': True, 'sle': {'item_code': 'Garlic', 'warehouse': 'Stores - DPRCL', 'posting_date': datetime.date(2023, 3, 15), 'posting_time': datetime.timedelta(seconds=86399), 'creation': datetime.datetime(2023, 8, 12, 8, 57, 30, 40945)}, 'args_idx': 0}, ('Chicken', 'Stores - DPRCL'): {'reposting_status': True, 'sle': {'item_code': 'Chicken', 'warehouse': 'Stores - DPRCL', 'posting_date': datetime.date(2023, 3, 15), 'posting_time': datetime.timedelta(seconds=86399), 'creation': datetime.datetime(2023, 8, 12, 8, 57, 30, 100121)}, 'args_idx': 1}, ('Green pepper', 'Stores - DPRCL'): {'reposting_status': True, 'sle': {'item_code': 'Green pepper', 'warehouse': 'Stores - DPRCL', 'posting_date': datetime.date(2023, 3, 15), 'posting_time': datetime.timedelta(seconds=86399), 'creation': datetime.datetime(2023, 8, 12, 8, 57, 30, 135821)}, 'args_idx': 2}, ('Onions', 'Stores - DPRCL'): {'reposting_status': True, 'sle': {'item_code': 'Onions', 'warehouse': 'St...
      affected_transactions = {('Stock Entry', 'MAT-STE-2023-01050'), ('Stock Entry', 'MAT-STE-2023-00934'), ('Stock Entry', 'MAT-STE-2023-01120'), ('Stock Entry', 'MAT-STE-2023-01124'), ('Stock Entry', 'MAT-STE-2023-01248'), ('Stock Entry', 'MAT-STE-2023-01316'), ('Stock Entry', 'MAT-STE-2023-00874'), ('Stock Entry', 'MAT-STE-2023-00807'), ('Stock Entry', 'MAT-STE-2023-00837'), ('Purchase Invoice', 'ACC-PINV-2023-00331'), ('Stock Entry', 'MAT-STE-2023-00812'), ('Stock Entry', 'MAT-STE-2023-01481'), ('Stock Entry', 'MAT-STE-2023-00897'), ('Stock Entry', 'MAT-STE-2023-01463'), ('Stock Entry', 'MAT-STE-2023-01314'), ('Stock Entry', 'MAT-STE-2023-00989'), ('Purchase Invoice', 'ACC-PINV-2023-00169'), ('Stock Entry', 'MAT-STE-2023-00906'), ('Purchase Invoice', 'ACC-PINV-2023-00290'), ('Stock Entry', 'MAT-STE-2023-01103'), ('Stock Entry', 'MAT-STE-2023-00650'), ('Purchase Invoice', 'ACC-PINV-2023-00224'), ('Stock Entry', 'MAT-STE-2023-01138'), ('Stock Entry', 'MAT-STE-2023-00942'), ('Stock Entry', 'MAT-STE-2023-00900'), ...
      i = 10
      obj = <erpnext.stock.stock_ledger.update_entries_after object at 0x7f81d2c16770>
  File "apps/erpnext/erpnext/stock/stock_ledger.py", line 395, in __init__
    self.build()
      self = <erpnext.stock.stock_ledger.update_entries_after object at 0x7f81d25bb280>
      args = {'item_code': 'Pepperoni', 'warehouse': 'Stores - DPRCL', 'posting_date': datetime.date(2023, 3, 15), 'posting_time': datetime.timedelta(seconds=86399), 'creation': datetime.datetime(2023, 8, 12, 8, 57, 30, 353054), 'distinct_item_warehouses': {('Garlic', 'Stores - DPRCL'): {'reposting_status': True, 'sle': {'item_code': 'Garlic', 'warehouse': 'Stores - DPRCL', 'posting_date': datetime.date(2023, 3, 15), 'posting_time': datetime.timedelta(seconds=86399), 'creation': datetime.datetime(2023, 8, 12, 8, 57, 30, 40945)}, 'args_idx': 0}, ('Chicken', 'Stores - DPRCL'): {'reposting_status': True, 'sle': {'item_code': 'Chicken', 'warehouse': 'Stores - DPRCL', 'posting_date': datetime.date(2023, 3, 15), 'posting_time': datetime.timedelta(seconds=86399), 'creation': datetime.datetime(2023, 8, 12, 8, 57, 30, 100121)}, 'args_idx': 1}, ('Green pepper', 'Stores - DPRCL'): {'reposting_status': True, 'sle': {'item_code': 'Green pepper', 'warehouse': 'Stores - DPRCL', 'posting_date': datetime.date(2023,...
      allow_zero_rate = False
      allow_negative_stock = 1
      via_landed_cost_voucher = 0
      verbose = 1
  File "apps/erpnext/erpnext/stock/stock_ledger.py", line 454, in build
    self.process_sle(sle)
      self = <erpnext.stock.stock_ledger.update_entries_after object at 0x7f81d25bb280>
      future_sle_exists = <function future_sle_exists at 0x7f81d31970a0>
      entries_to_fix = [{'name': 'MAT-SLE-2023-43972', 'creation': datetime.datetime(2023, 8, 12, 8, 57, 30, 353054), 'modified': datetime.datetime(2023, 8, 12, 8, 57, 30, 353054), 'modified_by': 'Administrator', 'owner': 'Administrator', 'docstatus': 1, 'idx': 0, 'item_code': 'Pepperoni', 'warehouse': 'Stores - DPRCL', 'posting_date': datetime.date(2023, 3, 15), 'posting_time': datetime.timedelta(seconds=86399), 'voucher_type': 'Stock Entry', 'voucher_no': 'MAT-STE-2023-00634', 'voucher_detail_no': '89973bfed1', 'dependant_sle_voucher_detail_no': None, 'recalculate_rate': 0, 'actual_qty': -0.016, 'qty_after_transaction': 19.94, 'incoming_rate': 0.0, 'outgoing_rate': 0.0, 'valuation_rate': 43.0, 'stock_value': 857.42, 'stock_value_difference': -0.6900000000000546, 'stock_queue': '[]', 'company': 'Dodo Pizza Restaurant Co. LLC', 'stock_uom': 'Kilogram', 'project': None, 'batch_no': '', 'fiscal_year': '2023', 'serial_no': None, 'is_cancelled': 0, 'to_rename': 0, '_user_tags': None, '_comments': None, '_assign'...
      i = 107
      sle = {'name': 'MAT-SLE-2023-48888', 'creation': datetime.datetime(2023, 8, 12, 9, 36, 25, 617643), 'modified': datetime.datetime(2023, 8, 12, 9, 36, 25, 617643), 'modified_by': 'Administrator', 'owner': 'Administrator', 'docstatus': 1, 'idx': 0, 'item_code': 'Pepperoni', 'warehouse': 'Stores - DPRCL', 'posting_date': datetime.date(2023, 4, 8), 'posting_time': datetime.timedelta(seconds=86399), 'voucher_type': 'Stock Entry', 'voucher_no': 'MAT-STE-2023-00858', 'voucher_detail_no': 'ff118745bc', 'dependant_sle_voucher_detail_no': None, 'recalculate_rate': 0, 'actual_qty': -2.088, 'qty_after_transaction': -3.429999999999977, 'incoming_rate': 0.0, 'outgoing_rate': 0.0, 'valuation_rate': 43.0, 'stock_value': -147.49, 'stock_value_difference': -89.78, 'stock_queue': '[]', 'company': 'Dodo Pizza Restaurant Co. LLC', 'stock_uom': 'Kilogram', 'project': None, 'batch_no': '', 'fiscal_year': '2023', 'serial_no': None, 'is_cancelled': 0, 'to_rename': 0, '_user_tags': None, '_comments': None, '_assign':...
  File "apps/erpnext/erpnext/stock/stock_ledger.py", line 634, in process_sle
    self.update_outgoing_rate_on_transaction(sle)
      self = <erpnext.stock.stock_ledger.update_entries_after object at 0x7f81d25bb280>
      sle = {'name': 'MAT-SLE-2023-48888', 'creation': datetime.datetime(2023, 8, 12, 9, 36, 25, 617643), 'modified': datetime.datetime(2023, 8, 12, 9, 36, 25, 617643), 'modified_by': 'Administrator', 'owner': 'Administrator', 'docstatus': 1, 'idx': 0, 'item_code': 'Pepperoni', 'warehouse': 'Stores - DPRCL', 'posting_date': datetime.date(2023, 4, 8), 'posting_time': datetime.timedelta(seconds=86399), 'voucher_type': 'Stock Entry', 'voucher_no': 'MAT-STE-2023-00858', 'voucher_detail_no': 'ff118745bc', 'dependant_sle_voucher_detail_no': None, 'recalculate_rate': 0, 'actual_qty': -2.088, 'qty_after_transaction': -3.429999999999977, 'incoming_rate': 0.0, 'outgoing_rate': 0.0, 'valuation_rate': 43.0, 'stock_value': -147.49, 'stock_value_difference': -89.78, 'stock_queue': '[]', 'company': 'Dodo Pizza Restaurant Co. LLC', 'stock_uom': 'Kilogram', 'project': None, 'batch_no': '', 'fiscal_year': '2023', 'serial_no': None, 'is_cancelled': 0, 'to_rename': 0, '_user_tags': None, '_comments': None, '_assign':...
      get_serial_nos = <function get_serial_nos at 0x7f81d31d2290>
      stock_value_difference = -89.78
  File "apps/erpnext/erpnext/stock/stock_ledger.py", line 748, in update_outgoing_rate_on_transaction
    self.update_rate_on_stock_entry(sle, outgoing_rate)
      self = <erpnext.stock.stock_ledger.update_entries_after object at 0x7f81d25bb280>
      sle = {'name': 'MAT-SLE-2023-48888', 'creation': datetime.datetime(2023, 8, 12, 9, 36, 25, 617643), 'modified': datetime.datetime(2023, 8, 12, 9, 36, 25, 617643), 'modified_by': 'Administrator', 'owner': 'Administrator', 'docstatus': 1, 'idx': 0, 'item_code': 'Pepperoni', 'warehouse': 'Stores - DPRCL', 'posting_date': datetime.date(2023, 4, 8), 'posting_time': datetime.timedelta(seconds=86399), 'voucher_type': 'Stock Entry', 'voucher_no': 'MAT-STE-2023-00858', 'voucher_detail_no': 'ff118745bc', 'dependant_sle_voucher_detail_no': None, 'recalculate_rate': 0, 'actual_qty': -2.088, 'qty_after_transaction': -3.429999999999977, 'incoming_rate': 0.0, 'outgoing_rate': 0.0, 'valuation_rate': 43.0, 'stock_value': -147.49, 'stock_value_difference': -89.78, 'stock_queue': '[]', 'company': 'Dodo Pizza Restaurant Co. LLC', 'stock_uom': 'Kilogram', 'project': None, 'batch_no': '', 'fiscal_year': '2023', 'serial_no': None, 'is_cancelled': 0, 'to_rename': 0, '_user_tags': None, '_comments': None, '_assign':...
      outgoing_rate = 42.99808429118774
  File "apps/erpnext/erpnext/stock/stock_ledger.py", line 763, in update_rate_on_stock_entry
    self.recalculate_amounts_in_stock_entry(sle.voucher_no)
      self = <erpnext.stock.stock_ledger.update_entries_after object at 0x7f81d25bb280>
      sle = {'name': 'MAT-SLE-2023-48888', 'creation': datetime.datetime(2023, 8, 12, 9, 36, 25, 617643), 'modified': datetime.datetime(2023, 8, 12, 9, 36, 25, 617643), 'modified_by': 'Administrator', 'owner': 'Administrator', 'docstatus': 1, 'idx': 0, 'item_code': 'Pepperoni', 'warehouse': 'Stores - DPRCL', 'posting_date': datetime.date(2023, 4, 8), 'posting_time': datetime.timedelta(seconds=86399), 'voucher_type': 'Stock Entry', 'voucher_no': 'MAT-STE-2023-00858', 'voucher_detail_no': 'ff118745bc', 'dependant_sle_voucher_detail_no': None, 'recalculate_rate': 0, 'actual_qty': -2.088, 'qty_after_transaction': -3.429999999999977, 'incoming_rate': 0.0, 'outgoing_rate': 0.0, 'valuation_rate': 43.0, 'stock_value': -147.49, 'stock_value_difference': -89.78, 'stock_queue': '[]', 'company': 'Dodo Pizza Restaurant Co. LLC', 'stock_uom': 'Kilogram', 'project': None, 'batch_no': '', 'fiscal_year': '2023', 'serial_no': None, 'is_cancelled': 0, 'to_rename': 0, '_user_tags': None, '_comments': None, '_assign':...
      outgoing_rate = 42.99808429118774
  File "apps/erpnext/erpnext/stock/stock_ledger.py", line 770, in recalculate_amounts_in_stock_entry
    d.db_update()
      self = <erpnext.stock.stock_ledger.update_entries_after object at 0x7f81d25bb280>
      voucher_no = 'MAT-STE-2023-00858'
      stock_entry = <StockEntry: MAT-STE-2023-00858 docstatus=1>
      d = <StockEntryDetail: a724174a27 docstatus=1 parent=MAT-STE-2023-00858>
  File "apps/frappe/frappe/model/base_document.py", line 547, in db_update
    d = self.get_valid_dict(
      self = <StockEntryDetail: a724174a27 docstatus=1 parent=MAT-STE-2023-00858>
  File "apps/frappe/frappe/model/base_document.py", line 301, in get_valid_dict
    permitted_fields = get_permitted_fields(
      self = <StockEntryDetail: a724174a27 docstatus=1 parent=MAT-STE-2023-00858>
      sanitize = True
      convert_dates_to_str = True
      ignore_nulls = False
      ignore_virtual = True
      d = {}
  File "apps/frappe/frappe/model/__init__.py", line 209, in get_permitted_fields
    permission_type = "select" if frappe.only_has_select_perm(doctype, user=user) else "read"
      doctype = 'Stock Entry Detail'
      parenttype = 'Stock Entry'
      user = None
      permission_type = None
      meta = <Meta: Stock Entry Detail>
      valid_columns = ['name', 'owner', 'creation', 'modified', 'modified_by', 'docstatus', 'idx', 'barcode', 'has_item_scanned', 's_warehouse', 't_warehouse', 'item_code', 'reason', 'item_name', 'is_finished_item', 'is_scrap_item', 'quality_inspection', 'subcontracted_item', 'description', 'item_group', 'image', 'qty', 'transfer_qty', 'retain_sample', 'uom', 'stock_uom', 'conversion_factor', 'sample_quantity', 'basic_rate', 'additional_cost', 'valuation_rate', 'allow_zero_valuation_rate', 'set_basic_rate_manually', 'basic_amount', 'amount', 'serial_no', 'batch_no', 'expense_account', 'cost_center', 'project', 'actual_qty', 'transferred_qty', 'bom_no', 'allow_alternative_item', 'material_request', 'material_request_item', 'original_item', 'against_stock_entry', 'ste_detail', 'po_detail', 'sco_rm_detail', 'putaway_rule', 'reference_purchase_receipt', 'job_card_item', 'parent', 'parentfield', 'parenttype']
  File "apps/frappe/frappe/__init__.py", line 926, in only_has_select_perm
    permissions = frappe.permissions.get_role_permissions(doctype, user=user)
      doctype = 'Stock Entry Detail'
      user = 'Administrator'
      ignore_permissions = False
      frappe = <module 'frappe' from 'apps/frappe/frappe/__init__.py'>
  File "apps/frappe/frappe/permissions.py", line 228, in get_role_permissions
    doctype_meta = frappe.get_meta(doctype_meta)  # assuming doctype name was passed
      doctype_meta = 'Stock Entry Detail'
      user = 'Administrator'
      is_owner = None
  File "apps/frappe/frappe/__init__.py", line 1224, in get_meta
    return frappe.model.meta.get_meta(doctype, cached=cached)
      doctype = 'Stock Entry Detail'
      cached = True
      frappe = <module 'frappe' from 'apps/frappe/frappe/__init__.py'>
  File "apps/frappe/frappe/model/meta.py", line 62, in get_meta
    if meta := frappe.cache().hget("doctype_meta", doctype):
      doctype = 'Stock Entry Detail'
      cached = True
  File "apps/frappe/frappe/utils/redis_wrapper.py", line 185, in hget
    _name = self.make_key(name, shared=shared)
      self = RedisWrapper<ConnectionPool<Connection<host=localhost,port=13000,db=0>>>
      name = 'doctype_meta'
      key = ********
      generator = None
      shared = False
      __class__ = <class 'frappe.utils.redis_wrapper.RedisWrapper'>
  File "apps/frappe/frappe/utils/redis_wrapper.py", line 31, in make_key
    return f"{frappe.conf.db_name}|{key}".encode()
      self = RedisWrapper<ConnectionPool<Connection<host=localhost,port=13000,db=0>>>
      key = ********
      user = None
      shared = False
  File "env/lib/python3.10/site-packages/werkzeug/local.py", line 316, in __get__
    obj = instance._get_current_object()
      self = proxy __getattr__
      instance = {'db_host': '10.5.3.101', 'dns_multitenant': True, 'frappe_user': 'frappe', 'http_timeout': 1500, 'monitor': True, 'redis_cache': 'redis://localhost:13000', 'redis_queue': 'redis://localhost:11000', 'redis_socketio': 'redis://localhost:13000', 'restart_supervisor_on_update': True, 'shallow_clone': True, 'socketio_port': 9000, 'webserver_port': 8000, 'db_name': '_2b886bcbe563495b', 'db_password': 'x1HdAjcMnuauhTC2', 'db_type': 'mariadb', 'encryption_key': 'r3kMihp-cHQXLT-3SdzyfAp9jNKhzwI2rBoe0P6yNUE=', 'host_name': 'https://dodopizza.frappe.cloud', 'maintenance_mode': 0, 'rate_limit': {'limit': 14400, 'window': 86400}, 'sk_erpnext': '6f617008bbe0077bcf2e411c4f171be395c90235', 'sk_hrms': '03d2428b6901b6687705914be5581ffd651775dd', 'user_type_doctype_limit': {'employee_self_service': 20}}
      owner = <class 'werkzeug.local.LocalProxy'>
  File "env/lib/python3.10/site-packages/werkzeug/local.py", line 493, in _get_current_object
    return get_name(local)  # type: ignore[return-value]
      get_name = operator.attrgetter('conf')
      local = <werkzeug.local.Local object at 0x7f81dbd8ca60>
      unbound_message = 'object is not bound'
  File "env/lib/python3.10/site-packages/rq/timeouts.py", line 61, in handle_death_penalty
    raise self._exception('Task exceeded maximum timeout value '
      self = <rq.timeouts.UnixSignalDeathPenalty object at 0x7f81da5091b0>
      signum = 14
      frame = <frame at 0x7f81da420ec0, file 'env/lib/python3.10/site-packages/werkzeug/local.py', line 494, code _get_current_object>
rq.timeouts.JobTimeoutException: Task exceeded maximum timeout value (1500 seconds)
maveezmh commented 1 year ago

image

Still the issue persists after update @rohitwaghchaure

rohitwaghchaure commented 10 months ago

@maveezmh We have already fixed this issue, kindly use the latest v14 version and check.