diff --git a/yuthon_account_report/__init__.py b/yuthon_account_report/__init__.py
index 9a7e03ede..c536983e2 100644
--- a/yuthon_account_report/__init__.py
+++ b/yuthon_account_report/__init__.py
@@ -1 +1,2 @@
-from . import models
\ No newline at end of file
+from . import models
+from . import wizard
\ No newline at end of file
diff --git a/yuthon_account_report/__manifest__.py b/yuthon_account_report/__manifest__.py
index f2ad8b4f1..f35486379 100644
--- a/yuthon_account_report/__manifest__.py
+++ b/yuthon_account_report/__manifest__.py
@@ -12,8 +12,20 @@
'data/account_setting_data.xml',
'views/financial_sheet_collection_views.xml',
'views/information_summary_table_views.xml',
+ 'wizard/table_setting_wizard_viwes.xml',
+ 'wizard/collection_create_button_wizard_views.xml',
+ 'wizard/summary_create_button_wizard_views.xml',
'views/table_setting_views.xml',
],
+ 'assets': {
+ 'web.assets_backend': [
+ 'yuthon_account_report/static/src/js/collection_create_button.js',
+ 'yuthon_account_report/static/src/js/summary_create_button.js',
+ 'yuthon_account_report/static/src/xml/collection_create_button.xml',
+ 'yuthon_account_report/static/src/xml/summary_create_button.xml',
+ ]
+ },
+
'installable': True,
'application': True,
diff --git a/yuthon_account_report/models/financial_sheet_collection.py b/yuthon_account_report/models/financial_sheet_collection.py
index 0b63e8eb5..7823277ce 100644
--- a/yuthon_account_report/models/financial_sheet_collection.py
+++ b/yuthon_account_report/models/financial_sheet_collection.py
@@ -1,5 +1,5 @@
-from odoo import fields, models, api
-import json
+from datetime import datetime
+from odoo import models, fields, api
class FinancialSheetCollection(models.Model):
@@ -11,6 +11,7 @@ class FinancialSheetCollection(models.Model):
department_id = fields.Many2one(related='employee_id.department_id', string="部门")
user_role_id = fields.Many2one(related='employee_id.user_role_id', string="角色")
create_date = fields.Datetime(string='创建日期', default=fields.Datetime.now)
+ cycle = fields.Selection(selection=[(str(i), str(i)) for i in range(1, 54)], string='周期')
account_type = fields.Selection([('to', '待确认',), ('ok', '已确认')], string='状态', default='to')
sheet_line_ids = fields.One2many('financial.sheet.line', 'sheet_id', string='财务数据表行')
@@ -35,7 +36,47 @@ class FinancialSheetCollection(models.Model):
record.account_type = 'ok'
def account_task(self):
- pass
+ collection_settings = self.env['sheet.collection.setting'].search([('employee_ids', '!=', False)])
+ # 计算当前时间对应的本年第几周
+ today = datetime.now()
+ first_day_of_year = datetime(today.year, 1, 1)
+ days_since_year_start = (today - first_day_of_year).days
+ first_weekday = first_day_of_year.weekday() # 0=周一,6=周日
+ current_week = (days_since_year_start + first_weekday + 1) // 7
+ if first_weekday == 6:
+ current_week = (days_since_year_start + 1) // 7
+ cycle = str(min(max(current_week, 1), 53))
+
+ for setting in collection_settings:
+ employees = setting.employee_ids
+ for employee in employees:
+ sheet_collection = self.env['financial.sheet.collection'].search([
+ ('employee_id', '=', employee.id),
+ ('cycle', '=', cycle)
+ ], limit=1)
+
+ if not sheet_collection:
+ sheet_collection = self.env['financial.sheet.collection'].create({
+ 'employee_id': employee.id,
+ 'cycle': cycle,
+ 'account_type': 'to',
+ 'create_date': fields.Datetime.now()
+ })
+
+ existing_line = self.env['financial.sheet.line'].search([
+ ('sheet_id', '=', sheet_collection.id),
+ ('collection_id', '=', setting.id)
+ ], limit=1)
+
+ if not existing_line:
+ self.env['financial.sheet.line'].create({
+ 'sheet_id': sheet_collection.id,
+ 'collection_id': setting.id,
+ 'employee_ids': [(6, 0, [employee.id])],
+ 'this_issue_number': 0,
+ 'same_last_year': 0,
+ 'remake': ''
+ })
class FinancialSheetLine(models.Model):
diff --git a/yuthon_account_report/models/information_summary_table.py b/yuthon_account_report/models/information_summary_table.py
index a3a9faeba..cb8b9342c 100644
--- a/yuthon_account_report/models/information_summary_table.py
+++ b/yuthon_account_report/models/information_summary_table.py
@@ -1,6 +1,5 @@
-# -*- coding: utf-8 -*-
-from odoo import api, fields, models
-import json
+from datetime import datetime
+from odoo import models, fields, api
class InformationSummaryTable(models.Model):
@@ -13,6 +12,7 @@ class InformationSummaryTable(models.Model):
user_role_id = fields.Many2one(related='employee_id.user_role_id', string="角色")
account_type = fields.Selection([('to', '待确认', ), ('ok', '已确认')], string='状态', default='to')
summary_line = fields.One2many('information.summary.line', 'summary_id', string='汇总表')
+ month = fields.Selection(selection=[(str(i), str(i)) for i in range(1, 13)], string='月份')
create_date = fields.Datetime(string='创建日期', default=fields.Datetime.now)
def open_record(self):
@@ -33,7 +33,39 @@ class InformationSummaryTable(models.Model):
record.account_type = 'ok'
def account_task(self):
- pass
+ self.ensure_one()
+ summary_settings = self.env['summary.table.setting'].search([
+ ('employee_ids', '!=', False)
+ ])
+ current_month = str(datetime.now().month)
+ for setting in summary_settings:
+ employees = setting.employee_ids
+ for employee in employees:
+ summary_table = self.env['information.summary.table'].search([
+ ('employee_id', '=', employee.id),
+ ('month', '=', current_month)
+ ], limit=1) #
+
+ if not summary_table:
+ summary_table = self.env['information.summary.table'].create({
+ 'employee_id': employee.id,
+ 'month': current_month,
+ 'account_type': 'to',
+ 'create_date': fields.Datetime.now()
+ })
+
+ existing_line = self.env['information.summary.line'].search([
+ ('summary_id', '=', summary_table.id),
+ ('table_id', '=', setting.id)
+ ], limit=1)
+
+ if not existing_line:
+ self.env['information.summary.line'].create({
+ 'summary_id': summary_table.id,
+ 'table_id': setting.id,
+ 'this_year': 0.0,
+ 'remake': ''
+ })
class InformationSummaryLine(models.Model):
diff --git a/yuthon_account_report/models/table_setting.py b/yuthon_account_report/models/table_setting.py
index 15ff6bb61..07f8b9c62 100644
--- a/yuthon_account_report/models/table_setting.py
+++ b/yuthon_account_report/models/table_setting.py
@@ -36,6 +36,18 @@ class SheetCollectionSetting(models.Model):
all_employees = rec.employee_ids | new_employees
rec.employee_ids = all_employees
+ def table_setting_wizard(self):
+ collection_ids = self.env["sheet.collection.setting"].browse(
+ self._context.get('active_ids', self._context.get('active_id')))
+ return {
+ 'name': '批量添加弹窗',
+ 'type': 'ir.actions.act_window',
+ 'res_model': 'table.setting.wizard',
+ 'view_mode': 'form',
+ 'target': 'new',
+ 'context': {'default_financial_ids': collection_ids.ids}
+ }
+
class SummaryTableSetting(models.Model):
_name = 'summary.table.setting'
_description = '信息汇总表项目配置'
@@ -68,3 +80,15 @@ class SummaryTableSetting(models.Model):
new_employees = self.env['hr.employee'].search(domain)
all_employees = rec.employee_ids | new_employees
rec.employee_ids = all_employees
+
+ def table_setting_wizard(self):
+ table_ids = self.env["summary.table.setting"].browse(
+ self._context.get('active_ids', self._context.get('active_id')))
+ return {
+ 'name': 'Table Setting Wizard',
+ 'type': 'ir.actions.act_window',
+ 'res_model': 'table.setting.wizard',
+ 'view_mode': 'form',
+ 'target': 'new',
+ 'context': {'default_information_ids': table_ids.ids}
+ }
diff --git a/yuthon_account_report/security/ir.model.access.csv b/yuthon_account_report/security/ir.model.access.csv
index aba3fd29e..7ebbb0934 100644
--- a/yuthon_account_report/security/ir.model.access.csv
+++ b/yuthon_account_report/security/ir.model.access.csv
@@ -4,4 +4,7 @@ access_summary_table_setting,summary_table_setting,model_summary_table_setting,b
access_information_summary_table,information_summary_table,model_information_summary_table,base.group_system,1,1,1,1
access_sheet_collection_setting,sheet_collection_setting,model_sheet_collection_setting,base.group_system,1,1,1,1
access_financial_sheet_line,financial_sheet_line,model_financial_sheet_line,base.group_system,1,1,1,1
-access_information_summary_line,information_summary_line,model_information_summary_line,base.group_system,1,1,1,1
\ No newline at end of file
+access_information_summary_line,information_summary_line,model_information_summary_line,base.group_system,1,1,1,1
+access_table_setting_wizard,table_setting_wizard,model_table_setting_wizard,base.group_system,1,1,1,
+access_collection_create_button_wizard,collection_create_button_wizard,model_collection_create_button_wizard,base.group_system,1,1,1,
+access_summary_create_button_wizard,summary_create_button_wizard,model_summary_create_button_wizard,base.group_system,1,1,1,
\ No newline at end of file
diff --git a/yuthon_account_report/static/src/js/collection_create_button.js b/yuthon_account_report/static/src/js/collection_create_button.js
new file mode 100644
index 000000000..361074674
--- /dev/null
+++ b/yuthon_account_report/static/src/js/collection_create_button.js
@@ -0,0 +1,29 @@
+/** @odoo-module */
+import { ListController } from "@web/views/list/list_controller";
+import { registry } from '@web/core/registry';
+import { listView } from '@web/views/list/list_view';
+
+export class CustomCollectionController extends ListController {
+ setup() {
+ super.setup();
+ }
+
+ openCollectionWizard() {
+ this.actionService.doAction({
+ type: 'ir.actions.act_window',
+ res_model: 'collection.create.button.wizard',
+ name: '财务数据表项目配置弹窗',
+ view_mode: 'form',
+ view_type: 'form',
+ views: [[false, 'form']],
+ target: 'new', // 以弹窗形式打开
+ context: {},
+ });
+ }
+}
+
+registry.category("views").add("custom_collection_button", {
+ ...listView,
+ Controller: CustomCollectionController,
+ buttonTemplate: "collection_module.ListView.Buttons",
+});
\ No newline at end of file
diff --git a/yuthon_account_report/static/src/js/summary_create_button.js b/yuthon_account_report/static/src/js/summary_create_button.js
new file mode 100644
index 000000000..7021d682d
--- /dev/null
+++ b/yuthon_account_report/static/src/js/summary_create_button.js
@@ -0,0 +1,29 @@
+/** @odoo-module */
+import { ListController } from "@web/views/list/list_controller";
+import { registry } from '@web/core/registry';
+import { listView } from '@web/views/list/list_view';
+
+export class CustomSummaryController extends ListController {
+ setup() {
+ super.setup();
+ }
+
+ openSummaryWizard() {
+ this.actionService.doAction({
+ type: 'ir.actions.act_window',
+ res_model: 'summary.create.button.wizard',
+ name: '信息汇总表配置',
+ view_mode: 'form',
+ view_type: 'form',
+ views: [[false, 'form']],
+ target: 'new',
+ context: {},
+ });
+ }
+}
+
+registry.category("views").add("summary_button", {
+ ...listView,
+ Controller: CustomSummaryController,
+ buttonTemplate: "summary_module.ListView.Buttons",
+});
\ No newline at end of file
diff --git a/yuthon_account_report/static/src/xml/collection_create_button.xml b/yuthon_account_report/static/src/xml/collection_create_button.xml
new file mode 100644
index 000000000..8d5b13689
--- /dev/null
+++ b/yuthon_account_report/static/src/xml/collection_create_button.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
diff --git a/yuthon_account_report/static/src/xml/summary_create_button.xml b/yuthon_account_report/static/src/xml/summary_create_button.xml
new file mode 100644
index 000000000..92f1045ee
--- /dev/null
+++ b/yuthon_account_report/static/src/xml/summary_create_button.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
diff --git a/yuthon_account_report/views/financial_sheet_collection_views.xml b/yuthon_account_report/views/financial_sheet_collection_views.xml
index eeb1bb607..202bab80e 100644
--- a/yuthon_account_report/views/financial_sheet_collection_views.xml
+++ b/yuthon_account_report/views/financial_sheet_collection_views.xml
@@ -6,9 +6,10 @@
>
+
@@ -55,6 +56,18 @@
+
+ financial.sheet.collection.search
+ financial.sheet.collection
+
+
+
+
+
+
+
+
+
financial.sheet.line.kanban
financial.sheet.line
@@ -98,7 +111,8 @@
财务数据表收集
financial.sheet.collection
- tree,form
+ tree,form,search
+ {'search_default_group_by_cycle': 1}
diff --git a/yuthon_account_report/views/information_summary_table_views.xml b/yuthon_account_report/views/information_summary_table_views.xml
index 7e29fa8dc..fd039d505 100644
--- a/yuthon_account_report/views/information_summary_table_views.xml
+++ b/yuthon_account_report/views/information_summary_table_views.xml
@@ -6,9 +6,10 @@
>
+
@@ -54,6 +55,18 @@
+
+ information.summary.table.search
+ information.summary.table
+
+
+
+
+
+
+
+
+
information.summary.line.kanban
information.summary.line
@@ -91,6 +104,7 @@
信息汇总表
information.summary.table
- tree,form
+ tree,form,search
+ {'search_default_group_by_month': 1}
diff --git a/yuthon_account_report/views/table_setting_views.xml b/yuthon_account_report/views/table_setting_views.xml
index ab503dd9b..ae8932b60 100644
--- a/yuthon_account_report/views/table_setting_views.xml
+++ b/yuthon_account_report/views/table_setting_views.xml
@@ -4,7 +4,10 @@
sheet.collection.setting.tree
sheet.collection.setting
-
+
+
@@ -24,7 +27,10 @@
summary.table.setting.tree
summary.table.setting
-
+
+
diff --git a/yuthon_account_report/wizard/__init__.py b/yuthon_account_report/wizard/__init__.py
new file mode 100644
index 000000000..928466be2
--- /dev/null
+++ b/yuthon_account_report/wizard/__init__.py
@@ -0,0 +1,3 @@
+from . import table_setting_wizard
+from . import summary_create_button_wizard
+from . import collection_create_button_wizard
diff --git a/yuthon_account_report/wizard/collection_create_button_wizard.py b/yuthon_account_report/wizard/collection_create_button_wizard.py
new file mode 100644
index 000000000..9cfe5f12d
--- /dev/null
+++ b/yuthon_account_report/wizard/collection_create_button_wizard.py
@@ -0,0 +1,54 @@
+from datetime import datetime
+from odoo import models, fields, api
+
+
+class CollectionCreateButtonWizard(models.TransientModel):
+ _name = 'collection.create.button.wizard'
+ _description = '财务数据表项目配置弹窗'
+
+ def action_confirm(self):
+ self.ensure_one()
+ collection_settings = self.env['sheet.collection.setting'].search([('employee_ids', '!=', False)])
+ # 计算当前时间对应的本年第几周
+ today = datetime.now()
+ first_day_of_year = datetime(today.year, 1, 1)
+ days_since_year_start = (today - first_day_of_year).days
+ first_weekday = first_day_of_year.weekday() # 0=周一,6=周日
+ current_week = (days_since_year_start + first_weekday + 1) // 7
+ if first_weekday == 6:
+ current_week = (days_since_year_start + 1) // 7
+ cycle = str(min(max(current_week, 1), 53))
+
+ for setting in collection_settings:
+ employees = setting.employee_ids
+ for employee in employees:
+ sheet_collection = self.env['financial.sheet.collection'].search([
+ ('employee_id', '=', employee.id),
+ ('cycle', '=', cycle)
+ ], limit=1)
+
+ if not sheet_collection:
+ sheet_collection = self.env['financial.sheet.collection'].create({
+ 'employee_id': employee.id,
+ 'cycle': cycle,
+ 'account_type': 'to',
+ 'create_date': fields.Datetime.now()
+ })
+
+ existing_line = self.env['financial.sheet.line'].search([
+ ('sheet_id', '=', sheet_collection.id),
+ ('collection_id', '=', setting.id)
+ ], limit=1)
+
+ if not existing_line:
+ self.env['financial.sheet.line'].create({
+ 'sheet_id': sheet_collection.id,
+ 'collection_id': setting.id,
+ 'employee_ids': [(6, 0, [employee.id])],
+ 'this_issue_number': 0,
+ 'same_last_year': 0,
+ 'remake': ''
+ })
+
+
+
diff --git a/yuthon_account_report/wizard/collection_create_button_wizard_views.xml b/yuthon_account_report/wizard/collection_create_button_wizard_views.xml
new file mode 100644
index 000000000..b49ad5d38
--- /dev/null
+++ b/yuthon_account_report/wizard/collection_create_button_wizard_views.xml
@@ -0,0 +1,18 @@
+
+
+
+ collection.create.button.wizard.form
+ collection.create.button.wizard
+
+
+
+
+
diff --git a/yuthon_account_report/wizard/summary_create_button_wizard.py b/yuthon_account_report/wizard/summary_create_button_wizard.py
new file mode 100644
index 000000000..46d69da76
--- /dev/null
+++ b/yuthon_account_report/wizard/summary_create_button_wizard.py
@@ -0,0 +1,46 @@
+from datetime import datetime
+from odoo import models, fields, api
+
+
+class SummaryCreateButtonWizard(models.TransientModel):
+ _name = 'summary.create.button.wizard'
+ _description = '初始化周期任务'
+
+ def action_confirm(self):
+ self.ensure_one()
+ summary_settings = self.env['summary.table.setting'].search([
+ ('employee_ids', '!=', False)
+ ])
+ if not summary_settings:
+ return self._show_notification('无有效项目配置(需关联人员)', 'warning')
+
+ current_month = str(datetime.now().month)
+ for setting in summary_settings:
+ employees = setting.employee_ids
+ for employee in employees:
+ summary_table = self.env['information.summary.table'].search([
+ ('employee_id', '=', employee.id),
+ ('month', '=', current_month)
+ ], limit=1) #
+
+ if not summary_table:
+ summary_table = self.env['information.summary.table'].create({
+ 'employee_id': employee.id,
+ 'month': current_month,
+ 'account_type': 'to',
+ 'create_date': fields.Datetime.now()
+ })
+
+ existing_line = self.env['information.summary.line'].search([
+ ('summary_id', '=', summary_table.id),
+ ('table_id', '=', setting.id)
+ ], limit=1)
+
+ if not existing_line:
+ self.env['information.summary.line'].create({
+ 'summary_id': summary_table.id,
+ 'table_id': setting.id,
+ 'this_year': 0.0,
+ 'remake': ''
+ })
+
diff --git a/yuthon_account_report/wizard/summary_create_button_wizard_views.xml b/yuthon_account_report/wizard/summary_create_button_wizard_views.xml
new file mode 100644
index 000000000..4780e40ab
--- /dev/null
+++ b/yuthon_account_report/wizard/summary_create_button_wizard_views.xml
@@ -0,0 +1,20 @@
+
+
+
+ summary.create.button.wizard.form
+ summary.create.button.wizard
+
+
+
+
+
+
+
diff --git a/yuthon_account_report/wizard/table_setting_wizard.py b/yuthon_account_report/wizard/table_setting_wizard.py
new file mode 100644
index 000000000..2c422f31d
--- /dev/null
+++ b/yuthon_account_report/wizard/table_setting_wizard.py
@@ -0,0 +1,31 @@
+from odoo import models, fields, api, _, SUPERUSER_ID
+from odoo.exceptions import UserError, ValidationError
+
+
+class TableSettingWizard(models.TransientModel):
+ _name = 'table.setting.wizard'
+ _description = ''
+
+ financial_ids = fields.Many2many('sheet.collection.setting', string='财务数据表行')
+ information_ids = fields.Many2many('summary.table.setting', string='信息汇总表行')
+ employee_ids = fields.Many2many('hr.employee', string='员工')
+ user_role_ids = fields.Many2many('soong.user.role', string="角色")
+
+ @api.onchange('user_role_ids')
+ def _onchange_user_role_ids(self):
+ for rec in self:
+ domain = ['|', ('user_role_id', 'in', rec.user_role_ids.ids),
+ ('user_role_ids', 'in', rec.user_role_ids.ids)]
+ new_employees = self.env['hr.employee'].search(domain)
+ all_employees = rec.employee_ids | new_employees
+ rec.employee_ids = all_employees
+
+ def action_confirm(self):
+ if self.financial_ids:
+ for rec in self.financial_ids:
+ rec.write({'employee_ids': [(6, 0, self.employee_ids.ids)]})
+ if self.information_ids:
+ for rec in self.information_ids:
+ rec.write({'employee_ids': [(6, 0, self.employee_ids.ids)]})
+
+
diff --git a/yuthon_account_report/wizard/table_setting_wizard_viwes.xml b/yuthon_account_report/wizard/table_setting_wizard_viwes.xml
new file mode 100644
index 000000000..0bcf498e4
--- /dev/null
+++ b/yuthon_account_report/wizard/table_setting_wizard_viwes.xml
@@ -0,0 +1,22 @@
+
+
+
+ table_setting_wizard
+ table.setting.wizard
+
+
+
+
+
+
diff --git a/yuthon_work_brand/views/hr_menus.xml b/yuthon_work_brand/views/hr_menus.xml
index 7bbdda15f..e7a48e8d4 100644
--- a/yuthon_work_brand/views/hr_menus.xml
+++ b/yuthon_work_brand/views/hr_menus.xml
@@ -164,11 +164,11 @@
parent="hr_attendance_root_board_menu"
action="yuthon_hr_attendance.view_yuthon_vacation_reports_action"
sequence="14"/>
-
+
+
+
+
+