from odoo import models, fields, api
from datetime import timedelta, timeimport datetime
class kw_send_wish(models.Model):
_name = 'kw_send_wish'
_description = 'A model to manage send wishes'
birth_date = fields.Boolean(compute='show_birthday')
@api.one
def show_birthday(self):
record = self.env['hr.employee'].sudo().search([])
today = datetime.datetime.today()
for birthday in record:
print(birthday)
birth_date = record.birthday
if str(record.birth_date)==str(today):
record.birth_date = True
Above is my code and showing the error that :-
raise ValueError("Expected singleton: %s" % self) ValueError: Expected singleton: hr.employee(26, 23, 10, 7, 6, 27, 9, 8, 18, 16, 15, 14, 25, 11, 17, 21, 19, 24, 20, 22)
This code is absolutely difficult. Do in better logic. Why you are getting all employees always? and avoid loops ie, making system glitch. Search employees with birthdate today or within a date span. Use domain in search accordingly. Whats the need of a new model? just use the same employee kanban view by filtering employees.