frappe / erpnext

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

Serial and Batch Bundle Issue in Subcontracting #43258

Open moizsami opened 1 month ago

moizsami commented 1 month ago

Information about bug

My customer was on v13 and was use to a particular scenario which is impossible to achieve after upgrading to v15.

The cycle goes as following:

  1. Purchase order is made, qty of finished goods entered.

    • Multiple service items inserted as multiple finished goods to be received. FG: RO1 -> 40 qty FG: RO2 -> 60 qty
  2. Subcontracting Order is created.

  3. Material is transferred

    • Note: raw material transferred is the same for all finished goods For example if finished goods are RO1 and RO2, both consume the same raw material RB01, so 100 qty of RB01 transferred
  4. During Subcontracting Receipt (facing issue)

    • the nature of process is that while creating PO it is not confirm how much FG I will receive of each item, the total will remain same, but the qty might differ, since the raw material is same, it doesnt matter in that aspect.
    • I want to be able to adjust the quantities during Subcontract receipt Ex: Suppose RO1 in PO had 40 qty and RO2 had 60. total is 100 during receipt I want RO1 to be 30 and RO2 to be 70.

When I try to do this the system doesnt let me do it stating error related to Serial Batch Bundle

image

This issue is really frustating to the client, as it is the new subcontracting and serial batch bundle scnearios are too much complicated than before, and now this makes using the system difficult.

I tried changing the setting to Backflush from Transfered for Subcontracting, that change now lets me to edit the consumed qty but still, the issue is there when consumed is more then required. (this should not be an issue as the raw material was the same)

I could only think of a workaround to ask the user to only receive the RO1 as 30 and RO2 as 60. then make stock return of 10 and then make a new PO for the remaining order, but this is too tedious.

I am not very good with coding. so if someone can guide me how to resolve this it would be a great help!

Module

buying

Version

ERPNext: v15.34.0 (version-15)

Frappe Framework: v15.39.2 (version-15)

Installation method

None

Relevant log output / Stack trace / Full Error Message.

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 1768, 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 373, in _save
    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/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py", line 127, in validate
    super().validate()
  File "apps/erpnext/erpnext/controllers/subcontracting_controller.py", line 54, in validate
    self.create_raw_materials_supplied()
  File "apps/erpnext/erpnext/controllers/subcontracting_controller.py", line 835, in create_raw_materials_supplied
    self.set_materials_for_subcontracted_items(raw_material_table)
  File "apps/erpnext/erpnext/controllers/subcontracting_controller.py", line 831, in set_materials_for_subcontracted_items
    self.__prepare_supplied_items()
  File "apps/erpnext/erpnext/controllers/subcontracting_controller.py", line 786, in __prepare_supplied_items
    self.__set_supplied_items()
  File "apps/erpnext/erpnext/controllers/subcontracting_controller.py", line 712, in __set_supplied_items
    self.__add_supplied_item(row, transfer_item.get("item_details"), qty)
  File "apps/erpnext/erpnext/controllers/subcontracting_controller.py", line 595, in __add_supplied_item
    rm_obj.serial_and_batch_bundle = self.__set_serial_and_batch_bundle(
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/controllers/subcontracting_controller.py", line 519, in __set_serial_and_batch_bundle
    ).make_serial_and_batch_bundle()
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/stock/serial_batch_bundle.py", line 949, in make_serial_and_batch_bundle
    self.validate_qty(doc)
  File "apps/erpnext/erpnext/stock/serial_batch_bundle.py", line 988, in validate_qty
    frappe.throw(msg, title=_("Insufficient Stock"))
  File "apps/frappe/frappe/__init__.py", line 645, in throw
    msgprint(
  File "apps/frappe/frappe/__init__.py", line 610, in msgprint
    _raise_exception()
  File "apps/frappe/frappe/__init__.py", line 561, in _raise_exception
    raise exc
frappe.exceptions.ValidationError: For the item <strong>RO28-100g</strong>, the Avaliable qty <strong>500.0</strong> is less than the Required Qty <strong>600.0</strong> in the warehouse <strong>Taha Slitting - GEM</strong>. Please add sufficient qty in the warehouse.
moizsami commented 1 month ago

@rohitwaghchaure brother tagging you, do let me know if there is any solution to this, it is really affecting the users.

moizsami commented 1 month ago

Regarding this, would really appreciate if Update Items functionality is implemented on the level of Subcontracting, as figures tend to change time to time for the subcontracting order..

similar to sales and purchase order, if receipt is not completed fully we should have option to update the items..