From 06ffe2f685f7d5c09c78a1d45e92561960ed77e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= <9664676+pengyuthon@user.noreply.gitee.com> Date: Fri, 26 Dec 2025 10:26:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/inherit_purchase_order.py | 4 ++ .../views/inherit_purchase_order_views.xml | 3 ++ .../models/inherit_room_booking.py | 41 ++++++++++++++++++- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/yuthon_purchase/models/inherit_purchase_order.py b/yuthon_purchase/models/inherit_purchase_order.py index 202804b5a..d7ad50a38 100644 --- a/yuthon_purchase/models/inherit_purchase_order.py +++ b/yuthon_purchase/models/inherit_purchase_order.py @@ -14,6 +14,10 @@ class InheritPurchaseOrder(models.Model): compute='_compute_json_display', store=True ) + state = fields.Selection(selection_add=[('部门经理', '部门经理'), + ('协办', '协办'), + ('分管领导', '分管领导'), + ('总经理', '总经理')],) work_end = fields.Boolean(string="结束") document_ids = fields.Many2many('ir.attachment', string="附件") user_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user) diff --git a/yuthon_purchase/views/inherit_purchase_order_views.xml b/yuthon_purchase/views/inherit_purchase_order_views.xml index 4fdbf2e73..de81326e8 100644 --- a/yuthon_purchase/views/inherit_purchase_order_views.xml +++ b/yuthon_purchase/views/inherit_purchase_order_views.xml @@ -33,6 +33,9 @@ 1 + + 1 + diff --git a/yuthon_will_task/models/inherit_room_booking.py b/yuthon_will_task/models/inherit_room_booking.py index 8001a7fa5..ebbd1d6e4 100644 --- a/yuthon_will_task/models/inherit_room_booking.py +++ b/yuthon_will_task/models/inherit_room_booking.py @@ -1,15 +1,32 @@ from odoo import api, fields, models from datetime import datetime, timedelta, date +import logging +_logger = logging.getLogger(__name__) class InheritRoomBooking(models.Model): _inherit = 'room.booking' def get_no_read_count(self): - today = date.today()+ timedelta(hours=8) + # 1. 计算各类时间参数 + today = date.today() + timedelta(hours=8) today_start = datetime.combine(today, datetime.min.time()) today_end = datetime.combine(today, datetime.max.time()) current_datetime = datetime.now() + timedelta(hours=8) + + # 2. 输出核心时间参数日志(INFO级别,便于查看过滤条件) + _logger.info( + "【会议室未过期记录统计】时间参数详情:" + "\n 调整后当天日期:%s" + "\n 当天开始时间(筛选起始):%s" + "\n 当天结束时间(筛选结束):%s" + "\n 调整后当前时间(过期判断):%s", + today, + today_start.strftime('%Y-%m-%d %H:%M:%S'), + today_end.strftime('%Y-%m-%d %H:%M:%S'), + current_datetime.strftime('%Y-%m-%d %H:%M:%S') + ) + # 3. 构建过滤域 domain = [ ('start_datetime', '>=', today_start), ('start_datetime', '<=', today_end), @@ -17,7 +34,27 @@ class InheritRoomBooking(models.Model): ('stop_datetime', '=', False), ('stop_datetime', '>', current_datetime) ] - return self.search_count(domain) + # 4. 查询符合条件的记录(先获取记录集,再统计数量,便于输出会议时间) + matching_records = self.search(domain) + count = len(matching_records) + + # 5. 输出符合条件的会议记录时间详情(DEBUG级别,便于排障) + if matching_records: + meeting_info = [] + for rec in matching_records: + meeting_info.append( + f"会议ID:{rec.id} | 开始时间:{rec.start_datetime.strftime('%Y-%m-%d %H:%M:%S') if rec.start_datetime else '无'} | 结束时间:{rec.stop_datetime.strftime('%Y-%m-%d %H:%M:%S') if rec.stop_datetime else '无'}" + ) + _logger.debug( + "【会议室未过期记录统计】符合条件的会议共 %d 条,详情:\n%s", + count, + "\n ".join(meeting_info) + ) + else: + _logger.info("【会议室未过期记录统计】未查询到符合条件的会议记录") + + # 6. 返回统计数量 + return count @api.model def create(self, vals): From 145c84f5ae1512caf7afd86d67bf27de15de13de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= <9664676+pengyuthon@user.noreply.gitee.com> Date: Fri, 26 Dec 2025 10:49:13 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_purchase/models/inherit_purchase_order.py | 13 ++++++++++--- .../views/inherit_purchase_order_views.xml | 3 +++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/yuthon_purchase/models/inherit_purchase_order.py b/yuthon_purchase/models/inherit_purchase_order.py index d7ad50a38..671ce681a 100644 --- a/yuthon_purchase/models/inherit_purchase_order.py +++ b/yuthon_purchase/models/inherit_purchase_order.py @@ -14,13 +14,17 @@ class InheritPurchaseOrder(models.Model): compute='_compute_json_display', store=True ) - state = fields.Selection(selection_add=[('部门经理', '部门经理'), + code = fields.Char(string="流水号", default=lambda self: self.env['ir.sequence'].next_by_code('purchase_workflow_approval_code')) + state = fields.Selection(selection_add=[('申请人', '申请人'), + ('部门经理', '部门经理'), ('协办', '协办'), ('分管领导', '分管领导'), - ('总经理', '总经理')],) + ('总经理', '总经理')] ,default='申请人') work_end = fields.Boolean(string="结束") - document_ids = fields.Many2many('ir.attachment', string="附件") user_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user) + company_id = fields.Many2one(related='user_id.employee_ids.company_id', string="公司") + department_id = fields.Many2one(related='user_id.employee_ids.department_id', string="部门") + document_ids = fields.Many2many('ir.attachment', string="附件") start_date = fields.Date(string="申请日期", default=fields.Date.today()) purchase_type = fields.Selection( [('fixed', '固定资产'), ('low', '低值易耗'), ('service', '服务'), ('day', '日常消耗品')], @@ -28,6 +32,9 @@ class InheritPurchaseOrder(models.Model): pay_way = fields.Selection([('onetime', '一次性'), ('installment', '分期')], string="付款方式", default='onetime') reason_text = fields.Text(string="申请事由") + def end_approval(self): + self.state = 'purchase' + self.write({'work_end': True}) @api.depends( 'order_line.product_id', diff --git a/yuthon_purchase/views/inherit_purchase_order_views.xml b/yuthon_purchase/views/inherit_purchase_order_views.xml index de81326e8..93a022f7c 100644 --- a/yuthon_purchase/views/inherit_purchase_order_views.xml +++ b/yuthon_purchase/views/inherit_purchase_order_views.xml @@ -37,6 +37,9 @@ 1 + + +