0
這裏是我試過的代碼:如何只接受將來的日期的形式odoo
@api.onchange('date_pub')
def get_right_date(self):
if self.date_pub:
if datetime.strptime(self.date_pub, DEFAULT_SERVER_DATE_FORMAT).date() < datetime.now().date():
raise Warning(_("impossible d'insérer une date passée"))
self.date_pub=datetime.now().date()
我收到錯誤消息(「不可能D'insérerUNE日期passée」),但是場date_pub沒有更新,用戶拾取的同一日期被插入到數據庫中!
幫助!!
沒有,警告後我想插入當前日期或清除插入的值,並要求用戶重新插入一個valide日期,你看? – Mraimou