diff --git a/yuthon_account_report/models/financial_sheet_collection.py b/yuthon_account_report/models/financial_sheet_collection.py index 4c9463398..0b63e8eb5 100644 --- a/yuthon_account_report/models/financial_sheet_collection.py +++ b/yuthon_account_report/models/financial_sheet_collection.py @@ -42,6 +42,7 @@ class FinancialSheetLine(models.Model): _name = 'financial.sheet.line' _description = '财务数据表行' + employee_ids = fields.Many2many('hr.employee', string='人员') sheet_id = fields.Many2one('financial.sheet.collection', string='关联财务数据表') collection_id = fields.Many2one('sheet.collection.setting', string='项目名称') this_issue_number = fields.Integer(string='本期数') diff --git a/yuthon_account_report/models/table_setting.py b/yuthon_account_report/models/table_setting.py index 297c8fde1..15ff6bb61 100644 --- a/yuthon_account_report/models/table_setting.py +++ b/yuthon_account_report/models/table_setting.py @@ -10,7 +10,8 @@ class SheetCollectionSetting(models.Model): sequence = fields.Integer(string='序号') name = fields.Char(string='名称') - user_role_id = fields.Many2one('soong.user.role', string="角色") + employee_ids = fields.Many2many('hr.employee', string='员工') + user_role_ids = fields.Many2many('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") @@ -26,6 +27,14 @@ class SheetCollectionSetting(models.Model): else: record.is_enable = record.start_date <= today <= record.end_date + @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 class SummaryTableSetting(models.Model): _name = 'summary.table.setting' @@ -34,7 +43,8 @@ class SummaryTableSetting(models.Model): sequence = fields.Integer(string='序号') name = fields.Char(string='名称') - company_id = fields.Many2one('res.company', string="公司") + employee_ids = fields.Many2many('hr.employee', string='员工') + user_role_ids = fields.Many2many('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") @@ -50,3 +60,11 @@ class SummaryTableSetting(models.Model): else: record.is_enable = record.start_date <= today <= record.end_date + @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 diff --git a/yuthon_account_report/views/financial_sheet_collection_views.xml b/yuthon_account_report/views/financial_sheet_collection_views.xml index 72dfad475..eeb1bb607 100644 --- a/yuthon_account_report/views/financial_sheet_collection_views.xml +++ b/yuthon_account_report/views/financial_sheet_collection_views.xml @@ -28,13 +28,13 @@ - - - + + + - - + + diff --git a/yuthon_account_report/views/information_summary_table_views.xml b/yuthon_account_report/views/information_summary_table_views.xml index 31da6cff8..7e29fa8dc 100644 --- a/yuthon_account_report/views/information_summary_table_views.xml +++ b/yuthon_account_report/views/information_summary_table_views.xml @@ -13,7 +13,7 @@ - +