24 lines
802 B
Python
24 lines
802 B
Python
# -*- coding: utf-8 -*-
|
|
from odoo import api, fields, models
|
|
from datetime import datetime, timedelta, time
|
|
|
|
|
|
class CateringReinstatedWizard(models.TransientModel):
|
|
_name = 'catering.reinstated.wizard'
|
|
_description = '复用弹窗'
|
|
|
|
def confirm(self):
|
|
menu_ids = self.env['yuthon.menu.setting'].search([])
|
|
for menu in menu_ids:
|
|
new_date = menu.menu_date + timedelta(days=7)
|
|
existing = self.env['yuthon.menu.setting'].search([('menu_date', '=', new_date)], limit=1)
|
|
if existing:
|
|
continue
|
|
self.env['yuthon.menu.setting'].create({
|
|
'menu_date': new_date,
|
|
'breakfast_ids': [(6, 0, menu.breakfast_ids.ids)],
|
|
'lunch_ids': [(6, 0, menu.lunch_ids.ids)],
|
|
})
|
|
|
|
|