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

Manufacture stock entry validation is incorrect for multi uom items #39358

Open TurkerTunali opened 10 months ago

TurkerTunali commented 10 months ago

Information about bug

The Total Qty is compared with the SE Qty and that's creates validation errors for multi uom materials. It should be compared against transfer_qty field.

https://github.com/frappe/erpnext/assets/710051/052c8d4f-293b-42e2-8b45-0f3278a46723

To reproduce

PS: It is related to this https://github.com/frappe/erpnext/pull/39335

Module

stock, manufacturing

Version

ERPNext: v15.10.0 (version-15) Frappe Framework: v15.9.0 (version-15)

Installation method

None

Relevant log output / Stack trace / Full Error Message.

File "apps/erpnext/erpnext/stock/doctype/stock_entry/stock_entry.py", line 545, in validate_fg_completed_qty generates the error.

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 110, 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 1682, 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 334, in save
    return self._save(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 356, in _save
    return self.insert()
           ^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 286, in insert
    self.run_before_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1083, in run_before_save_methods
    self.run_method("validate")
  File "apps/frappe/frappe/model/document.py", line 952, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1318, in composer
    return composed(self, method, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1300, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 949, in fn
    return method_object(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/stock/doctype/stock_entry/stock_entry.py", line 220, in validate
    self.validate_fg_completed_qty()
  File "apps/erpnext/erpnext/stock/doctype/stock_entry/stock_entry.py", line 545, in validate_fg_completed_qty
    frappe.throw(
  File "apps/frappe/frappe/__init__.py", line 578, in throw
    msgprint(
  File "apps/frappe/frappe/__init__.py", line 550, in msgprint
    _raise_exception()
  File "apps/frappe/frappe/__init__.py", line 501, in _raise_exception
    raise exc
frappe.exceptions.ValidationError: The finished product <strong>Fabric</strong> quantity <strong>20.0</strong> and For Quantity <strong>10</strong> cannot be different
3 request.js:473:14
    cleanup request.js:473
    cleanup request.js:471
    call request.js:325
    jQuery 4
s-aga-r commented 9 months ago

fixed: https://github.com/frappe/erpnext/pull/39335

TurkerTunali commented 9 months ago

fixed: #39335

Unfortunately, this one only solves the problem if Item's batch tracking is active. We also need to solve it if batch is not tracked like my example.