星期
This commit is contained in:
@@ -7,6 +7,7 @@ class YuthonCatering(models.Model):
|
||||
_name = 'yuthon.catering'
|
||||
|
||||
date = fields.Date(string='日期', required=True)
|
||||
week_day = fields.Char(string='星期', compute='_compute_week_day', store=True)
|
||||
dept_id = fields.Many2one(string='部门', comodel_name='hr.department', related='employee_id.department_id', store=True)
|
||||
employee_id = fields.Many2one(string='员工', comodel_name='hr.employee', required=True)
|
||||
breakfast = fields.Boolean(string='早餐', default=False)
|
||||
@@ -14,6 +15,15 @@ class YuthonCatering(models.Model):
|
||||
menu_day_id = fields.Many2one('yuthon.menu.setting', string='菜单')
|
||||
amount = fields.Float(string='结算费用', compute='_compute_amount', store=True)
|
||||
|
||||
@api.depends('date')
|
||||
def _compute_week_day(self):
|
||||
week_map = {'0': '周一', '1': '周二', '2': '周三', '3': '周四', '4': '周五', '5': '周六', '6': '周日'}
|
||||
for record in self:
|
||||
if record.date:
|
||||
record.week_day = week_map[str(record.date.weekday())]
|
||||
else:
|
||||
record.week_day = ''
|
||||
|
||||
@api.depends('breakfast', 'lunch')
|
||||
def _compute_amount(self):
|
||||
for record in self:
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
<button name="batch_generate_catering" string="批量生成12/1/2月餐饮数据" type="object" class="btn btn-primary"/>
|
||||
<button name="fill_march6_missing_catering" string="表3月6日缺失数据" type="object" class="btn btn-primary"/>
|
||||
</header>
|
||||
<field name="date"/>
|
||||
<field name="date"/>
|
||||
<field name="week_day" readonly="1"/>
|
||||
<field name="breakfast"/>
|
||||
<field name="lunch"/>
|
||||
<field name="amount" readonly="1"/>
|
||||
|
||||
Reference in New Issue
Block a user