From 7dda0df0d641ddc59ae58d19f117b2b2cf605162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Fri, 6 Mar 2026 14:43:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=98=9F=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_catering/models/yuthon_catering.py | 10 ++++++++++ yuthon_catering/views/yuthon_catering.xml | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) 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 @@