Files
gzth/yuthon_catering/models/yuthon_catering_setting.py
T
2026-03-06 15:01:16 +08:00

45 lines
1.4 KiB
Python

# -*- coding: utf-8 -*-
from odoo import api, fields, models
class YuthonMenuSetting(models.Model):
_name = 'yuthon.menu.setting'
_description = '菜单配置'
_rec_name = 'id'
breakfast_ids = fields.Many2many(
'yuthon.dishes.setting',
'yuthon_menu_breakfast_rel',
'menu_id',
'dish_id',
string='早餐'
)
lunch_ids = fields.Many2many(
'yuthon.dishes.setting',
'yuthon_menu_lunch_rel',
'menu_id',
'dish_id',
string='午餐'
)
menu_date = fields.Date(string='日期')
remake = fields.Text(string='备注')
week_day = fields.Char(string='星期', compute='_compute_week_day', store=True)
@api.depends('menu_date')
def _compute_week_day(self):
week_map = {'0': '周一', '1': '周二', '2': '周三', '3': '周四', '4': '周五', '5': '周六', '6': '周日'}
for record in self:
if record.menu_date:
record.week_day = week_map[str(record.menu_date.weekday())]
else:
record.week_day = ''
class YuthonDishesSetting(models.Model):
_name = 'yuthon.dishes.setting'
_description = '菜品配置'
name = fields.Char(string='菜品名称')
dishes_class = fields.Selection([('hun', '荤'), ('su', '素'), ('tang', '汤')], string='类别')
dishes_type = fields.Selection([('breakfast', '早餐'), ('lunch', '午餐')], string='菜品类型', default='lunch')