From 38283cd480ec064874c9b88c1d38ffd8779f35ef 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: Sat, 29 Nov 2025 16:59:57 +0800 Subject: [PATCH] =?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/financial_sheet_collection.py | 1 + yuthon_account_report/models/table_setting.py | 24 +++++++++ .../financial_sheet_collection_views.xml | 50 +++++++++++++++++-- .../views/information_summary_table_views.xml | 39 ++++++++++++++- .../views/table_setting_views.xml | 2 + 5 files changed, 110 insertions(+), 6 deletions(-) diff --git a/yuthon_account_report/models/financial_sheet_collection.py b/yuthon_account_report/models/financial_sheet_collection.py index b8a68a295..4529cd519 100644 --- a/yuthon_account_report/models/financial_sheet_collection.py +++ b/yuthon_account_report/models/financial_sheet_collection.py @@ -1,4 +1,5 @@ from odoo import fields, models, api +import json class FinancialSheetCollection(models.Model): diff --git a/yuthon_account_report/models/table_setting.py b/yuthon_account_report/models/table_setting.py index 8a8c5fe51..297c8fde1 100644 --- a/yuthon_account_report/models/table_setting.py +++ b/yuthon_account_report/models/table_setting.py @@ -13,6 +13,18 @@ class SheetCollectionSetting(models.Model): user_role_id = fields.Many2one('soong.user.role', string="角色") start_date = fields.Date(string="生效日期", default=fields.Datetime.today()) end_date = fields.Date(string="失效日期") + is_enable = fields.Boolean(string="是否启用", compute="compute_is_enable") + + @api.depends('start_date', 'end_date') + def compute_is_enable(self): + today = fields.Date.today() + for record in self: + if not record.start_date: + record.is_enable = False + elif not record.end_date: + record.is_enable = record.start_date <= today + else: + record.is_enable = record.start_date <= today <= record.end_date class SummaryTableSetting(models.Model): @@ -25,4 +37,16 @@ class SummaryTableSetting(models.Model): company_id = fields.Many2one('res.company', string="公司") start_date = fields.Date(string="生效日期", default=fields.Datetime.today()) end_date = fields.Date(string="失效日期") + is_enable = fields.Boolean(string="是否启用", compute="compute_is_enable") + + @api.depends('start_date', 'end_date') + def compute_is_enable(self): + today = fields.Date.today() + for record in self: + if not record.start_date: + record.is_enable = False + elif not record.end_date: + record.is_enable = record.start_date <= today + else: + record.is_enable = record.start_date <= today <= record.end_date diff --git a/yuthon_account_report/views/financial_sheet_collection_views.xml b/yuthon_account_report/views/financial_sheet_collection_views.xml index 8574f6259..897f18c42 100644 --- a/yuthon_account_report/views/financial_sheet_collection_views.xml +++ b/yuthon_account_report/views/financial_sheet_collection_views.xml @@ -13,9 +13,10 @@ -