python - 插入几个小时的条件
问题描述
晚上好,你能帮我看看如何设置一个条件,以便出现一条消息说你不能花一个小时,因为它已经很忙了吗?,我目前有这个:
class reserva (models.Model):
_name='gimnasio.reserva'
tipo_reserva=fields.Selection([('clase','Clase'),('evaluacion','Evaluacion')])
fecha_reserva=fields.Date()
start_time=fields.Float()
end_time=fields.Float()
def fecha(self):
if self.star_time==self.star_time:
raise validationError('the hour is busy')
解决方案
I have another question for you. you know how to configure Datetime only for hour and minutes because I only need hour and minutes but not the date.
仅将日期时间配置为小时和分钟。
time = fields.Datetime("time")
custom_time = fields.Char('my_custome_time')
@api.onchange('time')
def _get_time(self):
if self.time:
for rec in self:
# datetime value is a string like 'YYYY-mm-dd HH:MM:SS'
# so just extract string from position 11 to 16
_time = self.time[11:16]
self.custom_time = _time
rec.custom_time = self.custom_time
推荐阅读
- reactjs - 从 SVGator 导出的文件无法在 React 中编译
- c++ - 将文件数据读入结构,然后对所述数据进行排序
- python - python的csv解析器中带有双双引号和逗号的正确参数?
- arrays - 绘制二维数组的列
- python - 当我在 Python 中进行循环时,只剩下最后一个键/值对添加到字典中
- hp-nonstop - TACL 过滤历史命令的结果
- python - ValueError:无法解释 seaborn 中的输入
- docker-compose - 如何在 Ansible 的 docker_compose 任务中查找目录并迭代使用?
- reactjs - 做出反应。子组件正在改变父组件
- python - 如何使用 numpy 数组值在 Keras 模型中输入张量?