Odooers论坛

欢迎!

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


0

how i can fix ValueError: Expected singleton:

形象
odoo
形象
丢弃
2 答案
0
形象
odoo
最佳答案

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

形象
丢弃
0
形象
odoo
最佳答案

thank you its working and i will study it 

形象
丢弃