diff --git a/yuthon_employee/__init__.py b/yuthon_employee/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/yuthon_employee/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/yuthon_employee/__manifest__.py b/yuthon_employee/__manifest__.py new file mode 100644 index 0000000..9b2097d --- /dev/null +++ b/yuthon_employee/__manifest__.py @@ -0,0 +1,33 @@ +{ + 'name': 'Yuthon 员工管理', + 'version': '18.0.1.0.0', + 'summary': '大学人事基础:教职工档案(工号/部门/岗位/基本工资)', + 'description': """ + 教学模块①(基础层):yuthon_employee + ====================================== + 定义教职工(员工)主数据模型 yuthon.employee,是整个「出勤-薪资」体系的 + 数据根(root)。后续 yuthon_attendance、yuthon_salary 都依赖本模块。 + + 教学要点: + - 模型定义:_name / _description + - 字段类型:Char / Selection / Float / Date / Boolean + - 唯一约束:_sql_constraints(工号不可重复) + - 模块组合:被其它模块通过 _inherit 追加反向关联(attendance_ids / payslip_ids) + - ACL:ir.model.access.csv 授权 + """, + 'author': 'Yuthon', + 'website': '', + 'category': 'Education', + 'depends': ['base', 'web'], + 'data': [ + 'security/ir.model.access.csv', + 'views/employee_views.xml', + ], + 'demo': [ + 'data/demo.xml', + ], + 'license': 'LGPL-3', + 'installable': True, + 'application': True, + 'auto_install': False, +} diff --git a/yuthon_employee/data/demo.xml b/yuthon_employee/data/demo.xml new file mode 100644 index 0000000..0ba1ade --- /dev/null +++ b/yuthon_employee/data/demo.xml @@ -0,0 +1,39 @@ + + + + + T2024001 + 张三 + male + teaching + 讲师 + 13800000001 + zhangsan@school.edu + 8000.0 + 2024-09-01 + + + + A2024002 + 李四 + female + admin + 教务员 + 13800000002 + lisi@school.edu + 6000.0 + 2024-09-01 + + + + T2024003 + 王五 + male + teaching + 副教授 + 13800000003 + wangwu@school.edu + 12000.0 + 2024-09-01 + + diff --git a/yuthon_employee/models/__init__.py b/yuthon_employee/models/__init__.py new file mode 100644 index 0000000..f7b5da3 --- /dev/null +++ b/yuthon_employee/models/__init__.py @@ -0,0 +1 @@ +from . import employee diff --git a/yuthon_employee/models/employee.py b/yuthon_employee/models/employee.py new file mode 100644 index 0000000..29c564b --- /dev/null +++ b/yuthon_employee/models/employee.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- +from odoo import fields, models, api + + +class Employee(models.Model): + """教职工(员工)主数据模型。 + + 这是「出勤-薪资」体系的**数据根**:出勤记录挂在员工下, + 工资条在月底把「员工基本工资 + 当月出勤聚合结果」join 在一起算出来。 + """ + _name = 'yuthon.employee' + _description = '教职工(员工)' + _order = 'employee_no' + + # ---- 基础信息 ---- + employee_no = fields.Char( + string='工号', + required=True, + index=True, + help='唯一工号,如 T2024001(教师)/ A2024002(行政)', + ) + name = fields.Char( + string='姓名', + required=True, + ) + gender = fields.Selection( + [('male', '男'), ('female', '女')], + string='性别', + ) + department = fields.Selection( + [ + ('teaching', '教学部'), + ('admin', '行政部'), + ('logistics', '后勤部'), + ('support', '教辅部'), + ], + string='部门', + required=True, + default='teaching', + ) + job_title = fields.Char( + string='岗位 / 职称', + help='如:讲师、副教授、教务员', + ) + phone = fields.Char(string='联系电话') + email = fields.Char(string='邮箱') + + # ---- 薪资相关(被 yuthon_salary 读取)---- + base_salary = fields.Float( + string='基本工资', + default=0.0, + help='教学演示用 Float;生产环境建议改用 Monetary + currency_id', + ) + hire_date = fields.Date(string='入职日期') + + active = fields.Boolean( + string='在职', + default=True, + ) + + # ---- 反向关联(由 yuthon_attendance / yuthon_salary 通过 _inherit 追加)---- + # attendance_ids / payslip_ids 不在此定义,避免基础模块反向依赖业务模块。 + # 这是「模块解耦」的核心:根模块不知道子模块的存在。 + + # ---- 约束 ---- + _sql_constraints = [ + ('uniq_employee_no', 'unique(employee_no)', '工号已存在,不可重复!'), + ] + + @api.constrains('base_salary') + def _check_base_salary(self): + for rec in self: + if rec.base_salary < 0: + raise models.ValidationError('基本工资不能为负数。') diff --git a/yuthon_employee/security/ir.model.access.csv b/yuthon_employee/security/ir.model.access.csv new file mode 100644 index 0000000..a7bf7eb --- /dev/null +++ b/yuthon_employee/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_yuthon_employee,yuthon.employee,yuthon_employee.model_yuthon_employee,base.group_user,1,1,1,1 diff --git a/yuthon_employee/static/description/icon.png b/yuthon_employee/static/description/icon.png new file mode 100644 index 0000000..2b2766a Binary files /dev/null and b/yuthon_employee/static/description/icon.png differ diff --git a/yuthon_employee/views/employee_views.xml b/yuthon_employee/views/employee_views.xml new file mode 100644 index 0000000..0018dbb --- /dev/null +++ b/yuthon_employee/views/employee_views.xml @@ -0,0 +1,88 @@ + + + + + + yuthon.employee.list + yuthon.employee + + + + + + + + + + + + + + + + yuthon.employee.form + yuthon.employee + +
+ + + + + + + + + + + + + + + + + + +
+
+
+ + + + yuthon.employee搜索 + yuthon.employee + + + + + + + + + + + + + + + + + + + 教职工 + yuthon.employee + list,form + + + + + + + +