diff --git a/yuthon_catering/models/yuthon_catering.py b/yuthon_catering/models/yuthon_catering.py index 0c27b26bb..42640d663 100644 --- a/yuthon_catering/models/yuthon_catering.py +++ b/yuthon_catering/models/yuthon_catering.py @@ -12,7 +12,12 @@ class YuthonCatering(models.Model): breakfast = fields.Boolean(string='早餐', default=False) lunch = fields.Boolean(string='午餐', default=False) menu_day_id = fields.Many2one('yuthon.menu.setting', string='菜单') - amount = fields.Float(string='结算费用') + amount = fields.Float(string='结算费用', compute='_compute_amount', store=True) + + @api.depends('breakfast', 'lunch') + def _compute_amount(self): + for record in self: + record.amount = (1.0 if record.breakfast else 0.0) + (2.0 if record.lunch else 0.0) note = fields.Text(string='备注') state = fields.Selection([ ('unconfirmed', '未确认'), @@ -66,7 +71,6 @@ class YuthonCatering(models.Model): "breakfast": False, "lunch": False, "menu_day_id": False, - "amount": 0.0, "note": "", }) diff --git a/yuthon_catering/views/yuthon_catering.xml b/yuthon_catering/views/yuthon_catering.xml index e7459de78..0ae28bbc0 100644 --- a/yuthon_catering/views/yuthon_catering.xml +++ b/yuthon_catering/views/yuthon_catering.xml @@ -16,7 +16,7 @@ - +