diff --git a/yuthon_catering/models/yuthon_catering.py b/yuthon_catering/models/yuthon_catering.py index a4860cdf2..61bda71cb 100644 --- a/yuthon_catering/models/yuthon_catering.py +++ b/yuthon_catering/models/yuthon_catering.py @@ -14,9 +14,17 @@ class YuthonCatering(models.Model): entry_date = fields.Date(related='employee_id.entry_date', string="入职时间", store=True) breakfast = fields.Boolean(string='早餐', default=False, group_operator='count_true') lunch = fields.Boolean(string='午餐', default=False, group_operator='count_true') + breakfast_count = fields.Integer(string='早餐人数', compute='_compute_meal_count', store=True) + lunch_count = fields.Integer(string='午餐人数', compute='_compute_meal_count', store=True) menu_day_id = fields.Many2one('yuthon.menu.setting', string='菜单') amount = fields.Float(string='结算费用', compute='_compute_amount', store=True) + @api.depends('breakfast', 'lunch') + def _compute_meal_count(self): + for rec in self: + rec.breakfast_count = 1 if rec.breakfast else 0 + rec.lunch_count = 1 if rec.lunch else 0 + @api.depends('date') def _compute_week_day(self): week_map = {'0': '周一', '1': '周二', '2': '周三', '3': '周四', '4': '周五', '5': '周六', '6': '周日'}