Help

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

how i can fix ValueError: Expected singleton:

Avatar
odoo
Avatar
Discard
2 Answers
0
Avatar
odoo
Best Answer

Hi,
This error is caused because of multiple values/null values in an instance(Units_ids), thus here we need to loop this field and then we can check the condition; 

Please try this.

@api.onchange('date', 'Units_ids')
def _get_day_of_date(self):
for r in self:
if r.date:
    selected = fields.Datetime.from_string(r.date)
    r.date_day = calendar.day_name[selected.weekday()].lower()
    dayoff = r.Units_ids.mapped('dayoff')
    for record in dayoff:
    if record ==calendar.day_name[selected.weekday()].lower():
    raise UserError(
    _(F'This Day( {calendar.day_name[selected.weekday()]} ) Is Day Off For This Unit , Please Choose Another Unit!'))

Regards

Avatar
Discard
0
Avatar
odoo
Best Answer

thank you its working and i will study it 

Avatar
Discard