when i save the atttachment i get this error " can't compare datetime.date to bool " how can i solve thit issue this is the code
from datetime import datetime, date, timedelta
from odoo import models, fields, api, _
from odoo.exceptions import Warning
class HrEmployeeDocument(models.Model):
_name = 'hr.employee.document'
_description = 'HR Employee Documents'
@api.constrains('expiry_date')
def check_expr_date(self):
for each in self:
exp_date = each.expiry_date
if expiry_date < date.today():
raise Warning('Your Document Is Already Expired.')
expiry_date = fields.Date(string='Expiry Date', copy=False)
The issue is this line
expiry_date = fields.Date(string='Expiry Date', copy=False)
In the documentation of the odoo
-> field
, it requires a date string, what you provided string='Expiry Date'
, which is meanless, thus the expiry_date
will be assigned a bool which is False
, since it is not a valid data string.
You need to change to:
expiry_date = fields.Date(string='2014-06-15', copy=False)
And it should work.
Hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.