Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: if input manualy material request on WO the material_request_item is not set so validate WO give error #40180

Merged
merged 1 commit into from
Mar 12, 2024

Conversation

FHenry
Copy link
Contributor

@FHenry FHenry commented Feb 28, 2024

Please provide enough information so that others can review your pull request:

Create manually a MR
Create manually a WO and set in "More Info" tab the PR previously created
Validated the WO => error

As WO.material_request_item is never set in this process

Syntax error in query:
SELECT `material_request_item`,SUM(`qty`) FROM `tabWork Order` WHERE `material_request`=%(param1)s AND `material_request_item` IN () AND `docstatus`=1 GROUP BY `material_request_item` {'param1': 'MAT-MR-2024-00001-1'}
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 1697, 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 37, in savedocs
    doc.submit()
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1041, in submit
    return self._submit()
           ^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1024, in _submit
    return self.save()
           ^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 331, in save
    return self._save(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 384, in _save
    self.run_post_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1124, in run_post_save_methods
    self.run_method("on_submit")
  File "apps/frappe/frappe/model/document.py", line 955, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1315, in composer
    return composed(self, method, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 1297, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/document.py", line 952, in fn
    return method_object(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/manufacturing/doctype/work_order/work_order.py", line 442, in on_submit
    self.update_completed_qty_in_material_request()
  File "apps/erpnext/erpnext/manufacturing/doctype/work_order/work_order.py", line 788, in update_completed_qty_in_material_request
    frappe.get_doc("Material Request", self.material_request).update_completed_qty(
  File "apps/erpnext/erpnext/stock/doctype/material_request/material_request.py", line 270, in update_completed_qty
    mr_items_ordered_qty = self.get_mr_items_ordered_qty(mr_items)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/erpnext/erpnext/stock/doctype/material_request/material_request.py", line 259, in get_mr_items_ordered_qty
    mr_items_ordered_qty = frappe._dict(query.run())
                                        ^^^^^^^^^^^
  File "apps/frappe/frappe/query_builder/utils.py", line 87, in execute_query
    result = frappe.db.sql(query, params, *args, **kwargs)  # nosemgrep
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/database/database.py", line 234, in sql
    self._cursor.execute(query, values)
  File "env/lib/python3.11/site-packages/pymysql/cursors.py", line 153, in execute
    result = self._query(query)
             ^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pymysql/cursors.py", line 322, in _query
    conn.query(q)
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 558, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 822, in _read_query_result
    result.read()
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 1200, in read
    first_packet = self.connection._read_packet()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 772, in _read_packet
    packet.raise_for_error()
  File "env/lib/python3.11/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "env/lib/python3.11/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') AND `docstatus`=1 GROUP BY `material_request_item`' at line 1")

Backport suggestion :

If merged, please add "backport version-15-hotfix" label

@github-actions github-actions bot added the needs-tests This PR needs automated unit-tests. label Feb 28, 2024
@s-aga-r s-aga-r removed the backport version-14-hotfix backport to version 14 label Mar 12, 2024
@s-aga-r s-aga-r merged commit f24f51b into frappe:develop Mar 12, 2024
15 checks passed
mergify bot pushed a commit that referenced this pull request Mar 12, 2024
…m is not set so validate WO give error (#40180)

(cherry picked from commit f24f51b)
s-aga-r pushed a commit that referenced this pull request Mar 12, 2024
…m is not set so validate WO give error (backport #40180) (#40421)

fix: if input manualy material request on WO the material_request_item is not set so validate WO give error (#40180)

(cherry picked from commit f24f51b)

Co-authored-by: HENRY Florian <florian.henry@open-concept.pro>
@FHenry FHenry deleted the dev_fix_avoid_error_WO_validation branch March 12, 2024 16:36
frappe-pr-bot pushed a commit that referenced this pull request Mar 13, 2024
# [15.17.0](v15.16.2...v15.17.0) (2024-03-13)

### Bug Fixes

* **accounts:** Allow setting Number of new Cost Center (backport [#40212](#40212)) ([#40314](#40314)) ([7001e0a](7001e0a))
* advance paid amount and ledger entries against SO/PO ([6a5a941](6a5a941))
* barcode field on line item not working (backport [#40381](#40381)) ([#40384](#40384)) ([9ce68de](9ce68de))
* batch no not copied while making Material Consumption entry (backport [#40290](#40290)) ([#40300](#40300)) ([6d1c144](6d1c144))
* Blanket order rate getting changed on converting to order ([d8c6eb0](d8c6eb0))
* conditionally apply `is_group` filter in accounting dimension query (backport [#40414](#40414)) ([#40416](#40416)) ([40752c1](40752c1))
* decimal issue while making the stock entry (backport [#40394](#40394)) ([#40397](#40397)) ([91af7c0](91af7c0))
* error message wording ([#40403](#40403)) ([2a40808](2a40808))
* Filter for projects in Sales Cycle ([173b3b8](173b3b8))
* get_user_default_as_list args order ([44ff607](44ff607))
* if input manualy material request on WO the material_request_item is not set so validate WO give error (backport [#40180](#40180)) ([#40421](#40421)) ([a5e6763](a5e6763))
* incorrect advance paid in Sales/Purchase Order ([6832908](6832908))
* incorrect work order status (backport [#40407](#40407)) ([#40411](#40411)) ([605132a](605132a))
* load ignored doctype and include Mode of Payment Account ([#40334](#40334)) ([5fac500](5fac500))
* MR Default Supplier search query (backport [#40273](#40273)) ([#40351](#40351)) ([a195dd3](a195dd3))
* negative stock error for the batch (backport [#40389](#40389)) ([#40391](#40391)) ([478b988](478b988))
* not able to cancel purchase receipt for old subcontracting flow (backport [#40298](#40298)) ([#40302](#40302)) ([e0e80f7](e0e80f7))
* qc created for raw materials during manufacture entry (backport [#40408](#40408)) ([#40413](#40413)) ([f932265](f932265))
* recursion issue while submitting work order (backport [#40400](#40400)) ([#40402](#40402)) ([d6e87f3](d6e87f3))
* Sender email in process statements of accounts ([953f640](953f640))
* **Shipment Parcel:** make length, width and height non-mandatory ([1476196](1476196))
* stock ledger balance qty for the batch (backport [#40274](#40274)) ([#40301](#40301)) ([62aefce](62aefce))
* use serial batch fields for subcontracting receipt (backport [#40311](#40311)) ([#40315](#40315)) ([4b15c00](4b15c00))
* use serial/batch field for rejected items (backport [#40327](#40327)) ([#40329](#40329)) ([7ca7242](7ca7242))
* Use serial/batch fields for delivery note return (backport [#40374](#40374)) ([#40376](#40376)) ([32660ab](32660ab))

### Features

* add recursion qty field in promotional scheme ([5f4b23d](5f4b23d))
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport version-15-hotfix needs-tests This PR needs automated unit-tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants