添加功能

This commit is contained in:
zhou
2025-05-14 19:26:40 +08:00
parent 7880bf43cc
commit 7abb28adec
11 changed files with 165 additions and 4 deletions
+5 -3
View File
@@ -442,14 +442,16 @@ class HolidaysRequestBatch(models.Model):
@api.depends('users_id') @api.depends('users_id')
def _compute_holiday_allowance(self): def _compute_holiday_allowance(self):
number_of_days = 0
for record in self: for record in self:
holiday_status_id = self.env['hr.leave.type'].search([('name', '=', '年假')]) holiday_status_id = self.env['hr.leave.type'].search([('name', '=', '年假')])
leave_id = self.env['hr.leave.allocation'].search([('employee_id', '=', record.users_id.employee_id.id), leave_ids = self.env['hr.leave.allocation'].search([('employee_id', '=', record.users_id.employee_id.id),
('holiday_status_id', '=', holiday_status_id.id)]) ('holiday_status_id', '=', holiday_status_id.id)])
employee = self.env['hr.employee'].search([('id', '=', record.users_id.employee_id.id)]) employee = self.env['hr.employee'].search([('id', '=', record.users_id.employee_id.id)])
all_overtime_hours = round(employee.all_overtime_hours / 8, 1) all_overtime_hours = round(employee.all_overtime_hours / 8, 1)
if leave_id: if leave_ids:
number_of_days = int(leave_id.number_of_days) for leave_id in leave_ids:
number_of_days += leave_id.number_of_days
else: else:
number_of_days = 0 number_of_days = 0
record.holiday_allowance = (f"年假{number_of_days}天, 补休{all_overtime_hours}天") record.holiday_allowance = (f"年假{number_of_days}天, 补休{all_overtime_hours}天")
+32
View File
@@ -49,6 +49,38 @@ class IssueLibrary(models.Model):
urgency_level = fields.Selection([('normal', '普件'), ('urgent', '急件'), ('emergency', '特急件')], string='紧急度', urgency_level = fields.Selection([('normal', '普件'), ('urgent', '急件'), ('emergency', '特急件')], string='紧急度',
default='normal') default='normal')
work_end = fields.Boolean(string="结束") work_end = fields.Boolean(string="结束")
member_of_department = fields.Boolean("是否是本部门数据", compute='_compute_part_of_department',
search='_search_part_of_department')
@api.depends_context('uid', 'company')
@api.depends('department_id')
def _compute_part_of_department(self):
user_employee = self._get_valid_employee_for_user()
active_department = user_employee.department_id
for employee in self:
employee.member_of_department = employee.department_id == active_department
def _get_valid_employee_for_user(self):
user = self.env.user
employee = user.employee_ids
if not employee:
user_employees = user.employee_id.sudo().search([
('user_id', '=', user.id)
])
employee = user_employees.filtered(lambda r: r.company_id == user.company_id) or user_employees[:1]
return employee
#
def _search_part_of_department(self, operator, value):
if operator not in ('=', '!=') or not isinstance(value, bool):
raise UserError(_('Operation not supported'))
user_employee = self._get_valid_employee_for_user()
# Double negation
if not value:
operator = '!=' if operator == '=' else '='
if not user_employee.department_id:
return [('id', operator, user_employee.id)]
return (['!'] if operator == '!=' else []) + [('department_id', '=', user_employee.department_id.id)]
def _get_default_name_title(self): def _get_default_name_title(self):
return self._description if self._description else self._name return self._description if self._description else self._name
@@ -23,6 +23,7 @@
<field name="code" optional="hide"/> <field name="code" optional="hide"/>
<field name="company_id" optional="hide"/> <field name="company_id" optional="hide"/>
<field name="creart_datetime"/> <field name="creart_datetime"/>
<field name="member_of_department" optional="hide"/>
<button name="single_issue_pull" string="提交" type="object" class="oe_highlight"/> <button name="single_issue_pull" string="提交" type="object" class="oe_highlight"/>
<button name="issue_cancel" string="取消" type="object" class="oe_highlight"/> <button name="issue_cancel" string="取消" type="object" class="oe_highlight"/>
<button name="unlink" string="删除" type="object" class="oe_highlight"/> <button name="unlink" string="删除" type="object" class="oe_highlight"/>
@@ -152,6 +153,7 @@
<filter string="已上会" name="issue_state" domain="[('issue_state', '=', 'on_meet')]"/> <filter string="已上会" name="issue_state" domain="[('issue_state', '=', 'on_meet')]"/>
<group expand="0"> <group expand="0">
<filter name="group_manager" string="会议状态" domain="[]" context="{'group_by': 'issue_state'}"/> <filter name="group_manager" string="会议状态" domain="[]" context="{'group_by': 'issue_state'}"/>
<filter name="my_department_shifts" string="本部门" domain="[('member_of_department', '=', True)]"/>
</group> </group>
<header_search> <header_search>
<quick_filter string="状态"> <quick_filter string="状态">
+2
View File
@@ -20,6 +20,8 @@
'views/inherit_hr_payroll_structure_type_views.xml', 'views/inherit_hr_payroll_structure_type_views.xml',
'views/yuthon_payroll_project_views.xml', 'views/yuthon_payroll_project_views.xml',
'views/yuthon_payroll_type_setting_views.xml', 'views/yuthon_payroll_type_setting_views.xml',
'views/yuthon_salary_asset_views.xml',
'views/yuthon_salary_project_views.xml',
'views/yuthon_payroll_labor_views.xml', 'views/yuthon_payroll_labor_views.xml',
'views/yuthon_salary_documents_views.xml', 'views/yuthon_salary_documents_views.xml',
'views/yuthon_payroll_retired_views.xml', 'views/yuthon_payroll_retired_views.xml',
+2
View File
@@ -8,3 +8,5 @@ from . import yuthon_payroll_labor
from . import yuthon_payroll_retired from . import yuthon_payroll_retired
from . import yuthon_salary_documents from . import yuthon_salary_documents
from . import yuthon_salary_year from . import yuthon_salary_year
from . import yuthon_salary_project
from . import yuthon_salary_asset
@@ -0,0 +1,18 @@
from odoo import api, fields, models, _
import re
class YuthonSalaryAsset(models.Model):
_name = 'yuthon.salary.asset'
_description = '管理费用、财务费用表'
project_id = fields.Many2one('yuthon.salary.project', string='项目')
budgeted_number = fields.Float(string='2024年预算数')
actual_number = fields.Float(string='2025年预算合计')
investment_companies = fields.Float(string='投资公司')
ttjt_company = fields.Float(string='天投城建')
wtwh_company = fields.Float(string='伟天文化')
gmgc_company = fields.Float(string='国晟公司')
ly_company = fields.Float(string='粮油公司')
wg_company = fields.Float(string='物管公司')
remake = fields.Char(string='备注')
@@ -0,0 +1,38 @@
from odoo import api, fields, models
class YuthonSalaryProject(models.Model):
_name = 'yuthon.salary.project'
_description = '项目配置'
_order = 'ase_sequence asc'
_rec_name = 'name'
name = fields.Char(string="项目")
sequence = fields.Char(string='序号', store=True)
decision_type_id = fields.Many2one('issue.approval.decision.type', string='上级项目')
@api.onchange('sequence')
def onchange_name(self):
if self.sequence:
self.name = self.sequence + ' ' + str(self.name) if self.sequence else self.name
@api.onchange('sequence', 'decision_type_id')
def _onchange_department_code(self):
for code in self:
code.ase_sequence = int(code.sequence)
if code.sequence and code.decision_type_id:
code.sequence = code.decision_type_id.sequence + ('.' + code.sequence if code.sequence else '')
else:
code.sequence = code.sequence
code._update_child_sequences()
def _update_child_sequences(self):
def recursive_update(parent, parent_sequence):
for child in parent.child_ids:
new_sequence = parent_sequence + ('.' + child.sequence.split('.')[-1] if child.sequence else '')
self.env['issue.approval.decision.type'].search([('id', '=', child.id.origin)]).write(
{'sequence': new_sequence})
recursive_update(child, new_sequence)
recursive_update(self, self.sequence)
+3 -1
View File
@@ -25,4 +25,6 @@ access_payroll_labor_wizard,access_payroll_labor_wizard,model_payroll_labor_wiza
access_payroll_retired_wizard,access_payroll_retired_wizard,model_payroll_retired_wizard,base.group_user,1,1,1,1 access_payroll_retired_wizard,access_payroll_retired_wizard,model_payroll_retired_wizard,base.group_user,1,1,1,1
access_yuthon_salary_documents,access_yuthon_salary_documents,model_yuthon_salary_documents,base.group_user,1,1,1,1 access_yuthon_salary_documents,access_yuthon_salary_documents,model_yuthon_salary_documents,base.group_user,1,1,1,1
access_salary_print_wizard, access_salary_print_wizard,model_salary_print_wizard,base.group_user,1,1,1,1 access_salary_print_wizard, access_salary_print_wizard,model_salary_print_wizard,base.group_user,1,1,1,1
access_salary_year_wizard,access_salary_year_wizard,model_salary_year_wizard,base.group_user,1,1,1,1 access_salary_year_wizard,access_salary_year_wizard,model_salary_year_wizard,base.group_user,1,1,1,1
access_yuthon_salary_project, access_yuthon_salary_project,model_yuthon_salary_project,base.group_user,1,1,1,1
access_yuthon_salary_asset, access_yuthon_salary_asset,model_yuthon_salary_asset,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
25 access_salary_year_wizard access_salary_year_wizard model_salary_year_wizard base.group_user 1 1 1 1
26 access_yuthon_salary_project access_yuthon_salary_project model_yuthon_salary_project base.group_user 1 1 1 1
27 access_yuthon_salary_asset access_yuthon_salary_asset model_yuthon_salary_asset base.group_user 1 1 1 1
28
29
30
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_yuthon_salary_asset_tree" model="ir.ui.view">
<field name="name">yuthon.salary.asset.tree</field>
<field name="model">yuthon.salary.asset</field>
<field name="arch" type="xml">
<tree string="管理费用、财务费用表" editable="bottom">
<field name="project_id"/>
<field name="budgeted_number"/>
<field name="actual_number"/>
<field name="investment_companies"/>
<field name="ttjt_company"/>
<field name="wtwh_company"/>
<field name="gmgc_company"/>
<field name="ly_company"/>
<field name="wg_company"/>
<field name="remake"/>
</tree>
</field>
</record>
<record id="action_yuthon_salary_asset" model="ir.actions.act_window">
<field name="name">管理费用、财务费用表</field>
<field name="res_model">yuthon.salary.asset</field>
<field name="view_mode">tree</field>
</record>
</odoo>
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_yuthon_salary_project_tree" model="ir.ui.view">
<field name="name">yuthon.salary.project.tree</field>
<field name="model">yuthon.salary.project</field>
<field name="arch" type="xml">
<tree string="项目配置" edtitable="bottom">
<field name="sequence"/>
<field name="name"/>
<field name="decision_type_id"/>
</tree>
</field>
</record>
<record id="action_yuthon_salary_project" model="ir.actions.act_window">
<field name="name">项目配置</field>
<field name="res_model">yuthon.salary.project</field>
<field name="view_mode">tree</field>
</record>
</odoo>
+15
View File
@@ -477,6 +477,21 @@
parent="finance_manage_employee_root_board" parent="finance_manage_employee_root_board"
action="yuthon_salary.action_view_hr_payslip_salary_release" action="yuthon_salary.action_view_hr_payslip_salary_release"
sequence="30"/> sequence="30"/>
<menuitem id="yuthon_salary_asset_board"
name="管理费用、财务费用表"
parent="finance_manage_employee_root_board"
action="yuthon_salary.action_yuthon_salary_asset"
sequence="40"/>
<menuitem id="human_pay_slips_root_setting"
name="配置"
parent="finance_manage_employee_root_board"
sequence="99"/>
<menuitem id="yuthon_salary_project_menu"
name="项目"
parent="human_pay_slips_root_setting"
action="yuthon_salary.action_yuthon_salary_project"
/>
<menuitem id="yuthon_financial_management_menu" <menuitem id="yuthon_financial_management_menu"
name="物业财务管理" name="物业财务管理"
parent="finance_root_board" parent="finance_root_board"