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: Ambiguous column error while submitting stock entry #36209

Merged
merged 1 commit into from
Jul 20, 2023

Conversation

mohsinalimat
Copy link
Contributor

Stock Entry Type=Manufacture

request.js:457 Traceback (most recent call last):
File "apps/frappe/frappe/app.py", line 94, in application
response = frappe.api.handle()
File "apps/frappe/frappe/api.py", line 54, in handle
return frappe.handler.handle()
File "apps/frappe/frappe/handler.py", line 47, 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 1610, in call
return fn(*args, **newargs)
File "apps/frappe/frappe/desk/form/save.py", line 28, in savedocs
doc.save()
File "apps/frappe/frappe/model/document.py", line 305, in save
return self._save(*args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 327, in _save
return self.insert()
File "apps/frappe/frappe/model/document.py", line 259, in insert
self.run_before_save_methods()
File "apps/frappe/frappe/model/document.py", line 1045, in run_before_save_methods
self.run_method("validate")
File "apps/frappe/frappe/model/document.py", line 914, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 1264, in composer
return composed(self, method, *args, **kwargs)
File "apps/frappe/frappe/model/document.py", line 1246, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
File "apps/frappe/frappe/model/document.py", line 911, in fn
return method_object(*args, **kwargs)
File "apps/erpnext/erpnext/stock/doctype/stock_entry/stock_entry.py", line 122, in validate
self.validate_qty()
File "apps/erpnext/erpnext/stock/doctype/stock_entry/stock_entry.py", line 433, in validate_qty
transferred_materials = frappe.db.sql(
File "apps/frappe/frappe/database/database.py", line 220, in sql
self._cursor.execute(query, values)
File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 158, in execute
result = self._query(query)
File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 325, in _query
conn.query(q)
File "env/lib/python3.10/site-packages/pymysql/connections.py", line 549, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "env/lib/python3.10/site-packages/pymysql/connections.py", line 779, in _read_query_result
result.read()
File "env/lib/python3.10/site-packages/pymysql/connections.py", line 1157, in read
first_packet = self.connection._read_packet()
File "env/lib/python3.10/site-packages/pymysql/connections.py", line 729, in _read_packet
packet.raise_for_error()
File "env/lib/python3.10/site-packages/pymysql/protocol.py", line 221, in raise_for_error
err.raise_mysql_exception(self._data)
File "env/lib/python3.10/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.OperationalError: (1052, "Column 'qty' in field list is ambiguous")

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

Explain the details for making this change. What existing problem does the pull request solve?

Screenshots/GIFs

Stock Entry Type=Manufacture

request.js:457 Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 94, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 54, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 47, 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 1610, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/desk/form/save.py", line 28, in savedocs
    doc.save()
  File "apps/frappe/frappe/model/document.py", line 305, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 327, in _save
    return self.insert()
  File "apps/frappe/frappe/model/document.py", line 259, in insert
    self.run_before_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1045, in run_before_save_methods
    self.run_method("validate")
  File "apps/frappe/frappe/model/document.py", line 914, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1264, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1246, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 911, in fn
    return method_object(*args, **kwargs)
  File "apps/erpnext/erpnext/stock/doctype/stock_entry/stock_entry.py", line 122, in validate
    self.validate_qty()
  File "apps/erpnext/erpnext/stock/doctype/stock_entry/stock_entry.py", line 433, in validate_qty
    transferred_materials = frappe.db.sql(
  File "apps/frappe/frappe/database/database.py", line 220, in sql
    self._cursor.execute(query, values)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 158, in execute
    result = self._query(query)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 325, in _query
    conn.query(q)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 549, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 779, in _read_query_result
    result.read()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 1157, in read
    first_packet = self.connection._read_packet()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 729, in _read_packet
    packet.raise_for_error()
  File "env/lib/python3.10/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "env/lib/python3.10/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1052, "Column 'qty' in field list is ambiguous")
@github-actions github-actions bot added the needs-tests This PR needs automated unit-tests. label Jul 20, 2023
@codecov
Copy link

codecov bot commented Jul 20, 2023

Codecov Report

Merging #36209 (c21fd45) into develop (781e57f) will increase coverage by 0.05%.
The diff coverage is 98.61%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #36209      +/-   ##
===========================================
+ Coverage    64.09%   64.14%   +0.05%     
===========================================
  Files          783      784       +1     
  Lines        60702    60708       +6     
===========================================
+ Hits         38906    38943      +37     
+ Misses       21796    21765      -31     
Impacted Files Coverage Δ
erpnext/hooks.py 100.00% <ø> (ø)
erpnext/stock/doctype/stock_entry/stock_entry.py 82.17% <ø> (ø)
erpnext/accounts/doctype/dunning/dunning.py 95.71% <98.07%> (+13.89%) ⬆️
...next/accounts/doctype/dunning_type/dunning_type.py 100.00% <100.00%> (ø)
...ccounts/doctype/overdue_payment/overdue_payment.py 100.00% <100.00%> (ø)
...xt/accounts/doctype/payment_entry/payment_entry.py 83.34% <100.00%> (-0.08%) ⬇️
...xt/accounts/doctype/sales_invoice/sales_invoice.py 83.79% <100.00%> (+1.91%) ⬆️

@rohitwaghchaure rohitwaghchaure merged commit 1084f0d into frappe:develop Jul 20, 2023
@mohsinalimat
Copy link
Contributor Author

@rohitwaghchaure Please make it for version-14

@s-aga-r s-aga-r added the backport version-14-hotfix backport to version 14 label Jul 20, 2023
s-aga-r pushed a commit that referenced this pull request Jul 20, 2023
…6209) (#36222)

fix: Ambiguous column error while submitting stock entry

Stock Entry Type=Manufacture

request.js:457 Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 94, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 54, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 47, 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 1610, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/desk/form/save.py", line 28, in savedocs
    doc.save()
  File "apps/frappe/frappe/model/document.py", line 305, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 327, in _save
    return self.insert()
  File "apps/frappe/frappe/model/document.py", line 259, in insert
    self.run_before_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1045, in run_before_save_methods
    self.run_method("validate")
  File "apps/frappe/frappe/model/document.py", line 914, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1264, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1246, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 911, in fn
    return method_object(*args, **kwargs)
  File "apps/erpnext/erpnext/stock/doctype/stock_entry/stock_entry.py", line 122, in validate
    self.validate_qty()
  File "apps/erpnext/erpnext/stock/doctype/stock_entry/stock_entry.py", line 433, in validate_qty
    transferred_materials = frappe.db.sql(
  File "apps/frappe/frappe/database/database.py", line 220, in sql
    self._cursor.execute(query, values)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 158, in execute
    result = self._query(query)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 325, in _query
    conn.query(q)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 549, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 779, in _read_query_result
    result.read()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 1157, in read
    first_packet = self.connection._read_packet()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 729, in _read_packet
    packet.raise_for_error()
  File "env/lib/python3.10/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "env/lib/python3.10/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1052, "Column 'qty' in field list is ambiguous")

(cherry picked from commit c21fd45)

Co-authored-by: MohsinAli <mmatiyailol@gmail.com>
deepeshgarg007 added a commit that referenced this pull request Jul 21, 2023
* fix: broken overallocation validation in payment entry

In a multi term payment schedule, overallocation logic broke. Fixing
it using individual term outstanding amount in references. this should
work for the simple, one term payment schedule as well

(cherry picked from commit f8d4b19)

* refactor: payment term outstanding in party account currency

(cherry picked from commit ee83f94)

* fix: Default fiscal year in accounting, buying and sellingcharts

(cherry picked from commit 3759a41)

* fix: Trial Balance report considering cancelled entries

(cherry picked from commit fd58bbf)

* fix: made item or warehouse filter mandatory (backport #36208) (#36215)

fix: made item or warehouse filter mandatory

(cherry picked from commit 1649862)

Co-authored-by: Rohit Waghchaure <rohitw1991@gmail.com>

* fix: Ambiguous column error while submitting stock entry (backport #36209) (#36222)

fix: Ambiguous column error while submitting stock entry

Stock Entry Type=Manufacture

request.js:457 Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 94, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/api.py", line 54, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 47, 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 1610, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/desk/form/save.py", line 28, in savedocs
    doc.save()
  File "apps/frappe/frappe/model/document.py", line 305, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 327, in _save
    return self.insert()
  File "apps/frappe/frappe/model/document.py", line 259, in insert
    self.run_before_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1045, in run_before_save_methods
    self.run_method("validate")
  File "apps/frappe/frappe/model/document.py", line 914, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1264, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1246, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 911, in fn
    return method_object(*args, **kwargs)
  File "apps/erpnext/erpnext/stock/doctype/stock_entry/stock_entry.py", line 122, in validate
    self.validate_qty()
  File "apps/erpnext/erpnext/stock/doctype/stock_entry/stock_entry.py", line 433, in validate_qty
    transferred_materials = frappe.db.sql(
  File "apps/frappe/frappe/database/database.py", line 220, in sql
    self._cursor.execute(query, values)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 158, in execute
    result = self._query(query)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 325, in _query
    conn.query(q)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 549, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 779, in _read_query_result
    result.read()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 1157, in read
    first_packet = self.connection._read_packet()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 729, in _read_packet
    packet.raise_for_error()
  File "env/lib/python3.10/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "env/lib/python3.10/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1052, "Column 'qty' in field list is ambiguous")

(cherry picked from commit c21fd45)

Co-authored-by: MohsinAli <mmatiyailol@gmail.com>

* fix: Ignore permissions while submitting account closing balance record (#35536)

(cherry picked from commit f11d9b0)

* fix: FY in naming series variable for orders

(cherry picked from commit 7a7d32d)

---------

Co-authored-by: ruthra kumar <ruthra@erpnext.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Rohit Waghchaure <rohitw1991@gmail.com>
Co-authored-by: MohsinAli <mmatiyailol@gmail.com>
Co-authored-by: Nabin Hait <nabinhait@gmail.com>
frappe-pr-bot pushed a commit that referenced this pull request Jul 26, 2023
# [14.32.0](v14.31.3...v14.32.0) (2023-07-26)

### Bug Fixes

* added missing option Partially Received in the status dropdown field ([4fa93b0](4fa93b0))
* allocation logic on 'Get Outstanding Invoices' btn in PE ([14600fa](14600fa))
* allow both custodian and location while creating asset ([#36263](#36263)) ([2b47f58](2b47f58))
* Ambiguous column error while submitting stock entry (backport [#36209](#36209)) ([#36222](#36222)) ([844ec58](844ec58))
* apply discount on item after applying price list ([#36316](#36316)) ([cff6e72](cff6e72))
* apply terms validaton only in Sales/Purchase documents ([8f24292](8f24292))
* broken overallocation validation in payment entry ([e1d31aa](e1d31aa))
* clear accounting dimension value when based on field changes ([1fe6d4e](1fe6d4e))
* customer filter in process soa ([5938af9](5938af9))
* Default fiscal year in accounting, buying and sellingcharts ([8ca3d6b](8ca3d6b))
* fetch acc dimension fieldname ([542c804](542c804))
* FY in naming series variable for orders ([6a6a3ae](6a6a3ae))
* group by in fixed asset register ([#36310](#36310)) ([6cca18e](6cca18e))
* Ignore permissions while submitting account closing balance record ([#35536](#35536)) ([c2976ef](c2976ef))
* itemised tax breakup ([6f2e639](6f2e639))
* made item or warehouse filter mandatory (backport [#36208](#36208)) ([#36215](#36215)) ([57cf3c2](57cf3c2))
* no default email account causing reposting issue ([026f9f5](026f9f5))
* **regional:** set `frappe.flags.company` temporarily, where required ([73e9b38](73e9b38))
* set new purchase_receipt_amount on asset split ([#36272](#36272)) ([e867fe7](e867fe7))
* timeout error while cancelling the Purchase Receipt ([0575005](0575005))
* Trial Balance report considering cancelled entries ([ca4f86d](ca4f86d))

### Features

* filter based on accounting dimension in profitability analysis ([ba95df2](ba95df2))
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport version-14-hotfix backport to version 14 needs-tests This PR needs automated unit-tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants