Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

ValueError: Expected singleton (odoo 14)

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
expectedvalueerrorsingletonv14
1 Răspunde
15323 Vizualizări
Imagine profil
Fahimul Islam

Hello odoo experts, 

I just want to generate exam results according to the selected subjects. And my code is also ready for this. But when I execute this unfortunately the system response the error "ValueError: expected singleton: exam.subject(101, 102)".

I don't know what I'm missing here. Except your assist.

Thanks in Advance.


Here is my code:

# Method to Generate Result

def generate_result(self):
"""Method to generate result"""
result_obj = self.env["exam.result"]
student_obj = self.env["student.student"]
result_list = []
for rec in self:
for exam_schedule in rec.exam_schedule_ids:
string = [
("standard_id", "=", exam_schedule.standard_id.id),
("year", "=", rec.academic_year.id),
("state", "=", "done"),
("school_id", "=", exam_schedule.standard_id.school_id.id),
]
students_rec = student_obj.search(string)
for student in students_rec:
string = [
("standard_id", "=", student.standard_id.id),
("student_id", "=", student.id),
("s_exam_ids", "=", rec.id),
]
exam_result_rec = result_obj.search(string)
if exam_result_rec:
[result_list.append(res.id) for res in exam_result_rec]
else:
rs_dict = {
"s_exam_ids": rec.id,
"student_id": student.id,
"standard_id": student.standard_id.id,
"roll_no_id": student.roll_no,
"grade_system": rec.grade_system.id,
}
exam_line = []
timetable = exam_schedule.sudo().timetable_id
for line in timetable.sudo().timetable_ids:
min_mrks = line.subject_id.minimum_marks
max_mrks = line.subject_id.maximum_marks
sub_vals = {
"subject_id": line.subject_id.id,
"minimum_marks": min_mrks,
"maximum_marks": max_mrks,
}
exam_line.append((0, 0, sub_vals))
rs_dict.update({"result_ids": exam_line})
result_rec = result_obj.create(rs_dict)
result_list.append(result_rec.id)
return {
"name": _("Result Info"),
"view_mode": "tree,form",
"res_model": "exam.result",
"type": "ir.actions.act_window",
"string": [("id", "in", result_list)],
}

#Model 

class ExamResult(models.Model):

    """Defining Exam Result."""
    _name = "exam.result"
    _inherit = ["mail.thread", "resource.mixin"]
    _rec_name = "roll_no_id"
    _description = "exam result Information"
    
  standard_id = fields.Many2one(
    "school.standard", "Standard", help="Select Standard")
  result_ids = fields.One2many(
    "exam.subject", "exam_id", "Exam Subjects", help="Select exam subjects",
  )
  #.... other attributes

  @api.model
def create(self, vals):
"""Inherited the create method to assign the roll no and std"""
if vals.get("student_id"):

student_rec = self.env["student.student"].browse(
vals.get("student_id")
)
vals.update(
{
"roll_no_id": student_rec.roll_no,
"standard_id": student_rec.standard_id.id,
}
)
return super(ExamResult, self).create(vals)
  

0
Imagine profil
Abandonează
Deerom Technologies Pvt.Ltd

Can u please add the full error log

Fahimul Islam
Autor

@Deerom Technologies Pvt.Ltd, Thanks for your response. This is the full error log-

Odoo Server Error

Traceback (most recent call last):

File "F:\odoo-14.0\odoo\odoo\addons\base\models\ir_http.py", line 237, in _dispatch

result = request.dispatch()

File "F:\odoo-14.0\odoo\odoo\http.py", line 682, in dispatch

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

File "F:\odoo-14.0\odoo\odoo\http.py", line 358, in _call_function

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

File "F:\odoo-14.0\odoo\odoo\service\model.py", line 94, in wrapper

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

File "F:\odoo-14.0\odoo\odoo\http.py", line 346, in checked_call

result = self.endpoint(*a, **kw)

File "F:\odoo-14.0\odoo\odoo\http.py", line 911, in __call__

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

File "F:\odoo-14.0\odoo\odoo\http.py", line 530, in response_wrap

response = f(*args, **kw)

File "f:\odoo-14.0\odoo\addons\web\controllers\main.py", line 1363, in call_button

action = self._call_kw(model, method, args, kwargs)

File "f:\odoo-14.0\odoo\addons\web\controllers\main.py", line 1351, in _call_kw

return call_kw(request.env[model], method, args, kwargs)

File "F:\odoo-14.0\odoo\odoo\api.py", line 396, in call_kw

result = _call_kw_multi(method, model, args, kwargs)

File "F:\odoo-14.0\odoo\odoo\api.py", line 383, in _call_kw_multi

result = method(recs, *args, **kwargs)

File "f:\odoo-14.0\odoo\custom-addons\odooeduerp-14.0\exam\models\exam.py", line 414, in generate_result

result_rec = result_obj.create(rs_dict)

File "<decorator-gen-202>", line 2, in create

File "F:\odoo-14.0\odoo\odoo\api.py", line 323, in _model_create_single

return create(self, arg)

File "f:\odoo-14.0\odoo\custom-addons\odooeduerp-14.0\exam\models\exam.py", line 686, in create

return super(ExamResult, self).create(vals)

File "<decorator-gen-130>", line 2, in create

File "F:\odoo-14.0\odoo\odoo\api.py", line 344, in _model_create_multi

return create(self, [arg])

File "f:\odoo-14.0\odoo\addons\mail\models\mail_thread.py", line 262, in create

threads = super(MailThread, self).create(vals_list)

File "<decorator-gen-117>", line 2, in create

File "F:\odoo-14.0\odoo\odoo\api.py", line 326, in _model_create_single

return self.browse().concat(*(create(self, vals) for vals in arg))

File "F:\odoo-14.0\odoo\odoo\api.py", line 326, in <genexpr>

return self.browse().concat(*(create(self, vals) for vals in arg))

File "f:\odoo-14.0\odoo\addons\resource\models\resource_mixin.py", line 46, in create

return super(ResourceMixin, self).create(values)

File "<decorator-gen-65>", line 2, in create

File "F:\odoo-14.0\odoo\odoo\api.py", line 344, in _model_create_multi

return create(self, [arg])

File "F:\odoo-14.0\odoo\odoo\addons\base\models\ir_fields.py", line 508, in create

recs = super().create(vals_list)

File "<decorator-gen-13>", line 2, in create

File "F:\odoo-14.0\odoo\odoo\api.py", line 345, in _model_create_multi

return create(self, arg)

File "F:\odoo-14.0\odoo\odoo\models.py", line 3827, in create

records = self._create(data_list)

File "F:\odoo-14.0\odoo\odoo\models.py", line 3987, in _create

for other, data in zip(others, data_list)

File "F:\odoo-14.0\odoo\odoo\fields.py", line 2970, in create

self.write_batch(record_values, True)

File "F:\odoo-14.0\odoo\odoo\fields.py", line 2996, in write_batch

return self.write_real(records_commands_list, create)

File "F:\odoo-14.0\odoo\odoo\fields.py", line 3168, in write_real

flush()

File "F:\odoo-14.0\odoo\odoo\fields.py", line 3132, in flush

comodel.create(to_create)

File "<decorator-gen-65>", line 2, in create

File "F:\odoo-14.0\odoo\odoo\api.py", line 345, in _model_create_multi

return create(self, arg)

File "F:\odoo-14.0\odoo\odoo\addons\base\models\ir_fields.py", line 508, in create

recs = super().create(vals_list)

File "<decorator-gen-13>", line 2, in create

File "F:\odoo-14.0\odoo\odoo\api.py", line 345, in _model_create_multi

return create(self, arg)

File "F:\odoo-14.0\odoo\odoo\models.py", line 3827, in create

records = self._create(data_list)

File "F:\odoo-14.0\odoo\odoo\models.py", line 4000, in _create

records._validate_fields(name for data in data_list for name in data['stored'])

File "F:\odoo-14.0\odoo\odoo\models.py", line 1249, in _validate_fields

check(self)

File "f:\odoo-14.0\odoo\custom-addons\odooeduerp-14.0\exam\models\exam.py", line 824, in _validate_marks

maximum_marks = self.maximum_marks if self.maximum_marks else self.subject_id.maximum_marks

File "F:\odoo-14.0\odoo\odoo\fields.py", line 926, in __get__

record.ensure_one()

File "F:\odoo-14.0\odoo\odoo\models.py", line 4950, in ensure_one

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

Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "F:\odoo-14.0\odoo\odoo\http.py", line 638, in _handle_exception

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

File "F:\odoo-14.0\odoo\odoo\http.py", line 314, in _handle_exception

raise exception.with_traceback(None) from new_cause

ValueError: Expected singleton: exam.subject(117, 118)

Deerom Technologies Pvt.Ltd

can u please check the method that you defined under exam\models\exam.py", line 824, in _validate_mark

can u please check this mehtod "_validate_mark".Not sure but think the error is coming from this method.

Deerom Technologies Pvt.Ltd

In this method it Expected singleton but self contains multiple recordset.

Fahimul Islam
Autor

@Deerom Technologies Pvt.Ltd, Thanks again. But When I select a single subject it works perfectly. The error is occurred in case of multiple subject is selected.

Deerom Technologies Pvt.Ltd

Hi,

can u please add the method code here.

Fahimul Islam
Autor

@Deerom Technologies Pvt.Ltd, Thank you so much. You are saved my time. I wasted 2 days for this. Now the problem is solved just using a loop on the "_validate_marks" method.

Imagine profil
Deerom Technologies Pvt.Ltd
Cel mai bun răspuns

if self.test_field: #face ValueError Expected singleton because self contains multiple recordset.

Need to change with following:

for record in self:

    if record.test_field:

use decorators @api.multi with self.ensure_one() or use api.one and make changes accordingly

2
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
Error with singleton value
valueerror singleton
Imagine profil
Imagine profil
Imagine profil
Imagine profil
4
mar. 24
2509
Singleton error Rezolvat
singleton v14
Imagine profil
Imagine profil
Imagine profil
2
sept. 22
3103
ValueError: ValueError singleton Rezolvat
valueerror singleton
Imagine profil
Imagine profil
Imagine profil
4
feb. 19
4235
Odoo 14: editable tree "Add a line" shows ValueError: Invalid field 'same_vat_partner_id' on model 'tests.users'
inherit valueerror v14
Imagine profil
Imagine profil
Imagine profil
Imagine profil
3
iun. 22
6282
Odoo 11.0 ValueError: Expected singleton on create operation Rezolvat
create valueerror singleton
Imagine profil
Imagine profil
Imagine profil
4
dec. 19
6098
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now