添加功能
This commit is contained in:
@@ -25,6 +25,7 @@ class HrAttendanceMonth(models.Model):
|
||||
|
||||
name = fields.Char(compute='_compute_name')
|
||||
attendance_year_id = fields.Many2one('hr.attendance.year', string="统计年份")
|
||||
company_id = fields.Many2one('res.company', string="公司", default=lambda self: self.env.user.company_id)
|
||||
current_year = fields.Char(string='统计年份', related="attendance_year_id.year")
|
||||
current_month = fields.Selection([
|
||||
('1', '1月份'),
|
||||
@@ -43,6 +44,12 @@ class HrAttendanceMonth(models.Model):
|
||||
is_statistics = fields.Boolean(string="是否已统计", store=True, default=False)
|
||||
statistics_time = fields.Datetime(string="统计时间")
|
||||
attendance_month_detail_ids = fields.One2many(string="出勤月度汇总明细", comodel_name='hr.attendance.month.detail', inverse_name='hr_attendance_month_id')
|
||||
is_state = fields.Boolean(string='是否已全部确认', compute='_compute_is_state', store=True)
|
||||
|
||||
@api.depends('attendance_month_detail_ids.state')
|
||||
def _compute_is_state(self):
|
||||
for record in self:
|
||||
record.is_state = all(detail.state == 'confirmed' for detail in record.attendance_month_detail_ids)
|
||||
|
||||
def _compute_name(self):
|
||||
for record in self:
|
||||
@@ -75,7 +82,6 @@ class HrAttendanceMonthDetail(models.Model):
|
||||
employee_id = fields.Many2one('hr.employee', string="员工", readonly=True)
|
||||
department_id = fields.Many2one('hr.department', string="部门", related="employee_id.department_id", readonly=True)
|
||||
# userid = fields.Char(string='userid')
|
||||
|
||||
attendance_year_id = fields.Many2one('hr.attendance.year', string="统计年份")
|
||||
current_year = fields.Char(string='统计年份', related="attendance_year_id.year")
|
||||
current_month = fields.Selection([
|
||||
|
||||
@@ -102,6 +102,10 @@
|
||||
(4, ref('group_he_attendance_security_manager'))]"/>
|
||||
<field name="users" eval="[(4, ref('base.user_admin'))]"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.rule" id="hr_attendance_month_rule">
|
||||
<field name="name">出勤统计多公司</field>
|
||||
<field name="model_id" ref="model_hr_attendance_month"/>
|
||||
<field name="domain_force">[('company_id', 'in', company_ids)]</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
<field name="current_month"/>
|
||||
<field name="is_statistics"/>
|
||||
<field name="statistics_time"/>
|
||||
<field name="company_id" column_invisible="1"/>
|
||||
<field name="is_state" column_invisible="1"/>
|
||||
<button name="action_show_details" string="汇总明细" type="object" title="Show Details" icon="fa-list"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
||||
@@ -3,6 +3,7 @@ import datetime
|
||||
import calendar
|
||||
from odoo import models, api, fields, _
|
||||
from odoo.tools.float_utils import float_round
|
||||
from odoo.exceptions import ValidationError, UserError
|
||||
from datetime import date
|
||||
|
||||
|
||||
@@ -11,6 +12,7 @@ class HrAttendanceMonthWizard(models.TransientModel):
|
||||
_description = "考勤统计向导"
|
||||
|
||||
attendance_year_id = fields.Many2one('hr.attendance.year', string="统计年份")
|
||||
company_id = fields.Many2one('res.company', string="公司", default=lambda self: self.env.user.company_id)
|
||||
current_year = fields.Char(string='统计年份', related="attendance_year_id.year")
|
||||
current_month = fields.Selection([
|
||||
('1', '1月份'),
|
||||
@@ -99,6 +101,16 @@ class HrAttendanceMonthWizard(models.TransientModel):
|
||||
# 1 生成出勤生成记录
|
||||
# 2 生成出勤月度明细
|
||||
# 获取出勤月度汇总记录结果表
|
||||
for record in self:
|
||||
year = record.current_year
|
||||
month = record.current_month
|
||||
existing_records = self.env["hr.attendance.month"].search([
|
||||
('current_year', '=', year),
|
||||
('current_month', '=', month),
|
||||
('company_id', '=', record.company_id.id)
|
||||
])
|
||||
if existing_records:
|
||||
raise ValidationError(f"{year}年{month}月分的记录已经存在,不能重复操作.")
|
||||
self.ensure_one()
|
||||
attendance_month_obj = self._get_attendance_month_obj()
|
||||
# 查询所有的当前员工? 是否需要判断当前员工是否关联企业微信??预留
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="考勤统计">
|
||||
<group>
|
||||
<field name="company_id" invisible="1"/>
|
||||
<field name="attendance_year_id"/>
|
||||
<field name="current_month" />
|
||||
</group>
|
||||
|
||||
@@ -8,6 +8,7 @@ class InheritHrSalaryRule(models.Model):
|
||||
|
||||
category_id = fields.Many2one('hr.salary.rule.category', required=False, string='类别')
|
||||
amount_fix = fields.Float(string='固定金额', group_operator=None)
|
||||
company_id = fields.Many2one(related='struct_id.company_id', store=True, string='公司')
|
||||
|
||||
def action_yuthon_salary_wizard(self):
|
||||
return {
|
||||
|
||||
@@ -73,6 +73,9 @@
|
||||
<xpath expr="//field[@name='partner_id']" position="attributes">
|
||||
<attribute name="column_invisible">1</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='partner_id']" position="after">
|
||||
<field name="company_id"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
<record id="hr_payroll_structure_search" model="ir.ui.view">
|
||||
|
||||
@@ -40,6 +40,16 @@ class SalaryComputeWizard(models.Model):
|
||||
self.employee_number = len(self.employee_ids)
|
||||
|
||||
def confirm(self):
|
||||
attendance_records = self.env['hr.attendance.month'].search([
|
||||
('current_year', '=', self.select_year),
|
||||
('current_month', '=', self.select_time),
|
||||
])
|
||||
if not attendance_records:
|
||||
raise ValidationError(
|
||||
f"在 {self.select_year} 年 {self.select_time} 月没有出勤月度汇总记录,请先完成考勤统计。")
|
||||
if not all(record.is_state for record in attendance_records):
|
||||
raise ValidationError(
|
||||
f"在 {self.select_year} 年 {self.select_time} 月的出勤月度汇总记录未全部确认,请先确认考勤。")
|
||||
for employee in self.employee_ids:
|
||||
contract_id = self.env['hr.contract'].search([('employee_id', '=', employee.id)], limit=1)
|
||||
year = int(self.select_year)
|
||||
|
||||
Reference in New Issue
Block a user