Technical mailing list archives

technical@mail.odoo.com

Avatar

Re: Error expected singleton

by
Musinguzi Christian
- 01/25/2018 02:42:10

Thanks guys fixed this. Was in the referencing model.


On Jan 25, 2018 05:15, "Ahmed Magdy" <ahmed.magdy40@gmail.com> wrote:
Can you provide the log above this error?
starting from the line above line that contains something like "POST /web/dataset/call_kw/{{ Model name }}/onchange"
and ending with some http 500 status code after the traceback, kindly include the traceback

Regards,


On Wed, 24 Jan 2018 at 16:45 Musinguzi Christian <erlang.ug@gmail.com> wrote:
Yes I need search to return more than 1 value. A list of records under the equipment model but filtered by the resource.

On Wed, Jan 24, 2018 at 5:30 PM, Aksana Ivanova <aksanaivanova@hotmail.com> wrote:

I was right

Open equipment resourse id 2 and 4

They will be the same or similar

Your search return 2 values instead of one

 

Enviado do Correio para Windows 10

 


De: Musinguzi Christian <erlang.ug@gmail.com>
Enviado: Wednesday, January 24, 2018 2:25:23 PM
Para: Technical
Assunto: Re: Error expected singleton
 
Thats the error I get

File "/usr/lib/python2.7/dist-packa
ges/odoo/models.py", line 1596, in name_search return self._name_search(name, args, operator, limit=limit) File "/usr/lib/python2.7/dist-packages/odoo/models.py", line 1611, in _name_search return recs.sudo(access_rights_uid).name_get() File "/home/webcode/shares/mymodules/oehealth/oeh_medical/jil_insurance.py", line 48, in name_get name = self.name File "/usr/lib/python2.7/dist-packages/odoo/fields.py", line 904, in __get__ record.ensure_one() File "/usr/lib/python2.7/dist-packages/odoo/models.py", line 4820, in ensure_one raise ValueError("Expected singleton: %s" % self) ValueError: Expected singleton: equipment.resource(2, 4)

--> --> --> --> --> --> -->
Thats the error
On Wed, Jan 24, 2018 at 5:03 PM, Musinguzi Christian <erlang.ug@gmail.com> wrote:
Hi Guys,

I have tried everyones code here and nothing seems to work. Still get the same singleton error.

@Maysam, yes the definition is correct.

The code only works if affected field i.e 'equipment_id' has only one record.
On Wed, Jan 24, 2018 at 4:15 PM, Maysam Al-Haddan <alh.maysam@gmail.com> wrote:
Hi, 

Do you have the right definition of the Class :
from odoo import api, fields, models

class MyClassName(models.Model):
???
On Wed, Jan 24, 2018 at 11:55 AM, Musinguzi Christian <erlang.ug@gmail.com> wrote:
Hi Community,

I have a small issue, Hope you anyone help.

 I have written a simple model that is responsible to pick specific records depending on change of another. all fields are Many2one. am getting ' Error expected singleton '. however it works when the affected field has only one record.

class CallModel(Model.model)
    _name = resources.call
    resource_id = fields.Many2one('resource.resource', help ='our resources')
-->
    equipment_id = fields.Many2one('equipment.resource', help='resource equipment')

    @api.multi
    @api.onchange('resource_id')
    def _resource_onchange(self):
        res = {}
        for rec in self:
            res['domain']={'equipment_id':[('resource_id', '=', self.resource_id.id)]}
        return res

do you know how i could avoid that error --> -->

_______________________________________________
Mailing-List: https://www.odoo.com/groups/technical-62 -->
Post to: mailto:technical@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe -->
-->


_______________________________________________
Mailing-List: https://www.odoo.com/groups/technical-62 -->

_______________________________________________
Mailing-List: https://www.odoo.com/groups/technical-62
Post to: mailto:technical@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

_______________________________________________
Mailing-List: https://www.odoo.com/groups/technical-62
Post to: mailto:technical@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

_______________________________________________
Mailing-List: https://www.odoo.com/groups/technical-62
Post to: mailto:technical@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

--
Best regards,

Ahmed Magdy 
Python developer
Mob: 00201140529523

_______________________________________________
Mailing-List: https://www.odoo.com/groups/technical-62
Post to: mailto:technical@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

Reference