diff --git a/yuthon_catering/models/yuthon_catering.py b/yuthon_catering/models/yuthon_catering.py index d3f41f131..88b4eada7 100644 --- a/yuthon_catering/models/yuthon_catering.py +++ b/yuthon_catering/models/yuthon_catering.py @@ -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: diff --git a/yuthon_catering/views/yuthon_catering.xml b/yuthon_catering/views/yuthon_catering.xml index 0cb6ffe8f..edd8168c8 100644 --- a/yuthon_catering/views/yuthon_catering.xml +++ b/yuthon_catering/views/yuthon_catering.xml @@ -15,7 +15,8 @@