19 lines
641 B
Python
19 lines
641 B
Python
from odoo import api, fields, models
|
|
|
|
|
|
class YuthonTaskTime(models.Model):
|
|
_name = 'yuthon.task.time'
|
|
_description = '提醒时间配置'
|
|
_rec_name = 'name'
|
|
|
|
name = fields.Char(string='名称')
|
|
number = fields.Integer(string="数值")
|
|
task_unit = fields.Selection([('min', '分钟'), ('hour', '小时'), ('day', '天')], string="单位")
|
|
|
|
@api.onchange('number', 'task_unit')
|
|
def onchange_name(self):
|
|
task_unit_dict = {'min': '分钟', 'hour': '小时', 'day': '天'}
|
|
for n in self:
|
|
if n.number and n.task_unit:
|
|
n.name = str(n.number) + task_unit_dict[n.task_unit]
|