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

ValueError("Expected singleton: %s" % self)

By
odooPrac
on 7/13/16, 10:44 AM 1,447 views

Hello,

I'm having so much issues with this code now. Here is my function :

def get_available_view_value(self):

    print ("I am inside method")

     try:

         if self.unavailable: (line 89)

         print ("False commence")

         self.unavailable=False

         Print ("False value")

     else:

         self.unavailable=True

         print ("True Value")

         except Exception as e:

         print ("exception raised")

         error_message = _('Exception in getting available view value. Error Message is: ')+e.message

         _logger.exception(error_message+' error is %s ',e)


Here are my logs :


I am inside method

exception raised

2016-07-13 14:39:54,245 11135 ERROR odoo openerp.addons.wms_stock.models.stock_location: Exception in getting available view value. Error Message is: error is ('ValueError', 'Expected singleton: stock.location(17, 19)')

Traceback (most recent call last):

File "/home/xyz/git/odoo-210/odoo/staples-addons/wms_stock/models/stock_location.py", line 89, in get_available_view_value

if self.unavailable:

File "/home/xyz/git/odoo-210/odoo/openerp/fields.py", line 825, in __get__

record.ensure_one()

File "/home/xyz/git/odoo-210/odoo/openerp/models.py", line 5307, in ensure_one

raise except_orm("ValueError", "Expected singleton: %s" % self)

except_orm: ('ValueError', 'Expected singleton: stock.location(17, 19)')


I have no idea how to solve this. Can anyone help ? Thanks in advance

1

Grover Menacho

--Grover Menacho--
2523
| 5 7 8
La Paz, Bolivia
--Grover Menacho--

Systems Engineer + MBA

Grover Menacho
On 7/13/16, 3:58 PM

Your variable self is not a singleton, it has two. You have to do:


for location in self:
    if location.unavailable:
0
odooPrac
On 7/14/16, 4:54 PM

Hey guys, I found the answer myself. we can either do this by replacing self with record or we can use decorator @api.one. worked for me. Thanks :)

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: 7/13/16, 10:44 AM
Seen: 1447 times
Last updated: 7/14/16, 4:54 PM