Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

ProgrammingError: column reference "product_id" is ambiguous - [solved]

By
Dr Obx
on 1/28/16, 4:25 AM 765 views

Guys, Today I get this error and don't really know what to do with it

: Programming error: column reference "product_id" is ambiguous

LINE 2: ... SELECT 0 FROM stock_quant, stock_location WHERE product_id...

^

, in query

SELECT 0 FROM stock_quant, stock_location WHERE product_id = %s AND stock_location.id = stock_quant.location_id AND

((stock_location.parent_left >= %s AND stock_location.parent_left < %s) OR stock_location.id = %s) AND qty < 0.0 LIMIT 1

2016-01-28 10:40:36,036 5529 ERROR NewClean openerp.http: Exception during JSON request handling.

Traceback (most recent call last):

File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 530, in _handle_exception

return super(JsonRequest, self)._handle_exception(exception)

File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 567, in dispatch

result = self._call_function(**self.params)

File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 303, in _call_function

return checked_call(self.db, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 113, in wrapper

return f(dbname, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 300, in checked_call

return self.endpoint(*a, **kw)

File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 796, in __call__

return self.method(*args, **kw)

File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 396, in response_wrap

response = f(*args, **kw)

File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 948, in call_button

action = self._call_kw(model, method, args, {})

File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 936, in _call_kw

return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper

return old_api(self, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/openerp/addons/iProdLoc/iprodloc.py", line 1014, in action_done

quant_obj.quants_move(cr, uid, quants, move, move.location_dest_id, lot_id=move.restrict_lot_id.id, owner_id=move.restrict_partner_id.id, context=context)

File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper

return old_api(self, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/openerp/addons/stock/stock.py", line 424, in quants_move

""", (move.product_id.id, location_to.parent_left, location_to.parent_right, location_to.id))

File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 158, in wrapper

return f(self, *args, **kwargs)

File "/usr/lib/python2.7/dist-packages/openerp/sql_db.py", line 234, in execute

res = self._obj.execute(query, params)

ProgrammingError: column reference "product_id" is ambiguous

LINE 2: ... SELECT 0 FROM stock_quant, stock_location WHERE product_id...

^

     Any ideas ?

"Help urgently required" is not a question. Please review the guidelines for this site at https://www.odoo.com/forum/help-1/faq - also posting your solution may help others.

Bista Solutions US, Ray Carnes
on 1/28/16, 8:50 AM

Next time ......

Dr Obx
on 1/28/16, 9:02 AM
1
Dr Obx
On 1/28/16, 7:06 AM

Problem solved.

In my case problem was caused by:

product_id (product.product and product.template), apparently because of that while updating table Odoo was unable to write changes into both. So query in stock.py (class stock_quant, def quants.move) must be changed:

before:

cr.execute("""                SELECT 0 FROM stock_quant, stock_location WHERE product_id = %s AND stock_location.id = stock_quant.location_id AND                ((stock_location.parent_left >= %s AND stock_location.parent_left < %s) OR stock_location.id = %s) AND qty < 0.0 LIMIT 1            """

after:

cr.execute("""                SELECT 0 FROM stock_quant, stock_location WHERE stock_quant.product_id = %s AND stock_location.id = stock_quant.location_id AND                ((stock_location.parent_left >= %s AND stock_location.parent_left < %s) OR stock_location.id = %s) AND qty < 0.0 LIMIT 1            """

Since then all problems gone.


If anyone has the same issue .... 

Greetings to:

Pawan M.


HI Dr Box, Please I have the same problem can you tell me how you resolve this problem Thanks

Achref Mhadhbi
on 2/3/16, 6:31 AM

If you still have this problem or any other, please contact me or Pawan.

Dr Obx
on 2/3/16, 6:54 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/28/16, 4:25 AM
Seen: 765 times
Last updated: 2/3/16, 6:37 AM