From 94013a5143cdbad4d9407b8e442eddd9c8a63118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Wed, 4 Mar 2026 11:05:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A4=90=E9=A5=AE=E6=94=B6=E9=9B=86=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_catering/models/yuthon_catering.py | 8 +++- yuthon_catering/views/yuthon_catering.xml | 2 +- .../report/property_confirm_template.xml | 41 ++++++++++++++++--- 3 files changed, 42 insertions(+), 9 deletions(-) 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 @@ - +