添加功能

This commit is contained in:
李鹏宇
2026-09-02 12:01:32 +08:00
parent 25e4563a22
commit 83791770f7
25 changed files with 54 additions and 60 deletions
+1 -1
View File
@@ -1046,7 +1046,7 @@ class HolidaysRequestBatch(models.Model):
raise ValidationError(_("添加了按天请假记录,必须选择'按天请假'选项!"))
if record.hour_leave_ids and not record.is_hour:
raise ValidationError(_("添加了按小时请假记录,必须选择'按小时请假'选项!"))
if record.hour_leave_ids and record.company_id.name == '天河物管':
if record.hour_leave_ids and record.company_id.id == 3:
for line in record.hour_leave_ids:
if not line.request_date_from or not line.request_hour_to:
continue
@@ -154,7 +154,7 @@ class HrLeaveAllocation(models.Model):
target_year = start_dt.year + 1
end_dt = date(target_year, 6, 30)
elif company_name == '天河物管':
elif leave.employee_id.company_id.id == 3:
target_year = start_dt.year + 1
feb_last_day = calendar.monthrange(target_year, 2)[1]
end_dt = date(target_year, 2, feb_last_day)
@@ -32,7 +32,7 @@ class LeaveAllocationWizard(models.Model):
employee_id = self.env['hr.employee'].search([('name', '=', row[0].value)], limit=1)
if not employee_id:
raise ValidationError(f'员工姓名{row[0].value}不存在,请检查。')
holiday_status_id = self.env['hr.leave.type'].search([('name', '=', '年假'), ('company_id', '=', '天河物管')], limit=1)
holiday_status_id = self.env['hr.leave.type'].search([('name', '=', '年假'), ('company_id', '=', 3)], limit=1)
holiday_status_id1 = self.env['hr.leave.type'].search([('name', '=', '补休')], limit=1)
accrual_plan_id = self.env['hr.leave.accrual.plan'].search([('name', '=', '年假(天河物管)')], limit=1)
if row[1].value and int(row[1].value) != 0:
@@ -602,7 +602,7 @@ class HrAttendanceDetail(models.Model):
if not self._process_shift_days(current_data):
return is_early_card, is_late_card, is_abnormal, is_warning, absenteeism_card, is_no_card
is_tianhe_property = employee.company_id.name == "天河物管"
is_tianhe_property = employee.company_id.id == 3
# 只要是旷工 就不算早退 或者迟到
# 迟到判断
@@ -58,8 +58,7 @@ class MessageReminderTasks(models.Model):
def _generate_reminder_tasks_by_date(self, current_date):
"""按指定日期生成提醒任务(每日/批量共用逻辑)"""
target_company_names = ['天河物管', '天河粮储', '集团本部']
target_companies = self.env['res.company'].search([('name', 'in', target_company_names)])
target_companies = self.env['res.company'].search(['|', ('name', 'in', ['天河粮储', '集团本部']), ('id', '=', 3)])
target_calendars = self.env['resource.calendar'].search([
('company_id', 'in', target_companies.ids)
])
@@ -114,7 +114,7 @@ class OvertimeApprovals(models.Model):
for employee in rec.employee_ids:
holiday_status_id = self.env['hr.leave.type'].search([('name', '=', '补休')])
start_year = rec.start_time.date().year
if rec.company_id.name == "天河物管":
if rec.company_id.id == 3:
start_date = datetime(start_year, 3, 1).date()
valid_date = datetime(start_year + 1, 3, 1).date() + relativedelta(months=1) - relativedelta(days=1)
elif rec.company_id.name == "天河粮储":
@@ -171,7 +171,7 @@ class OvertimeApprovals(models.Model):
def _compute_is_thwg(self):
for rec in self:
if rec.users_id:
rec.is_thwg = rec.users_id.company_id.name == '天河物管'
rec.is_thwg = rec.users_id.company_id.id == 3
@api.depends('users_id')
def _compute_is_lc(self):
@@ -387,7 +387,7 @@ class OvertimeApprovals(models.Model):
records = super(OvertimeApprovals, self).create(vals_list)
records._compute_duration()
for rec in records:
if rec.company_id.name == '天河物管':
if rec.company_id.id == 3:
duration = rec.duration
if duration < 1:
raise ValidationError(f"时长不能小于1!当前填写的是{duration}")
@@ -427,7 +427,7 @@ class OvertimeApprovals(models.Model):
for record in self:
for employee_id in record.employee_ids:
start_year = record.start_time.date().year
if record.company_id.name == "天河物管":
if record.company_id.id == 3:
start_date = datetime(start_year, 9, 1).date()
valid_date = datetime(start_year + 1, 9, 1).date() + relativedelta(months=1) - relativedelta(days=1)
elif record.company_id.name == "天河粮储":
@@ -253,7 +253,7 @@ class YuthonVacationReports(models.Model):
def _compute_late_allowed_fields(self):
for record in self:
# 每月发放:天河物管员工 3 次允许迟到次数,其余公司 0
if record.employee_id and record.employee_id.company_id.name == "天河物管":
if record.employee_id and record.employee_id.company_id.id == 3:
grant = 3
else:
grant = 0
@@ -613,7 +613,7 @@ class YuthonVacationReports(models.Model):
allocation_valid_date = None
# 2. 天河物管:默认2月底
elif "天河物管" in company_name:
elif rec.employee_id.company_id.id == 3:
# 主表有效期:当年2月底
vacation_valid_date = date(current_year, 2, 28)
overtime_valid_date = date(current_year, 2, 28)
@@ -649,7 +649,7 @@ class YuthonVacationReports(models.Model):
line_valid_date = None
if company_name == "集团本部":
line_valid_date = None
elif "天河物管" in company_name:
elif rec.employee_id.company_id.id == 3:
if leave_line.text == "上月额度继承":
line_valid_date = inherit_valid_date # 当年2月底
elif leave_line.text == "年假分配":
@@ -670,7 +670,7 @@ class YuthonVacationReports(models.Model):
line_valid_date = None
if company_name == "集团本部":
line_valid_date = None
elif "天河物管" in company_name: # 修正:从"物管"改为"天河物管"
elif rec.employee_id.company_id.id == 3: # 修正:从"物管"改为"天河物管"
if over_line.text == "上月额度继承":
line_valid_date = inherit_valid_date
elif over_line.update_type == "add":
@@ -1325,7 +1325,7 @@ class YuthonVacationReports(models.Model):
[('name', 'ilike', '天河物管')], limit=1
)
if leave_name == '年假':
leave_type = self.env['hr.leave.type'].search([('display_name', 'ilike', leave_name), ('company_id.name', '=', '天河物管')], limit=1)
leave_type = self.env['hr.leave.type'].search([('display_name', 'ilike', leave_name), ('company_id', '=', 3)], limit=1)
else:
leave_type = self.env['hr.leave.type'].search([('name', '=', leave_name)])
vals = {
@@ -1927,7 +1927,7 @@ class YuthonVacationReports(models.Model):
if company_name == "集团本部":
vacation_valid_date = None
overtime_valid_date = None
elif "天河物管" in company_name:
elif rec.employee_id.company_id.id == 3:
vacation_valid_date = date(valid_year, 2, 28)
overtime_valid_date = date(valid_year, 2, 28)
elif "天河粮储" in company_name:
@@ -295,10 +295,9 @@ class YuthonHrEmployee(models.Model):
today = fields.Date.today()
contract_employees = self.search([('end_comparison', 'in', ['red', 'yellow', 'blue'])])
menu_id = self.env['ir.ui.menu'].search([('name', '=', '合同')], limit=1)
target_companies = ['集团本部', '天河物管', '天河粮储']
hr_specialists = self.env['soong.user.role'].search([
('company_id.name', 'in', target_companies),
('name', '=', '人事专员')
('name', '=', '人事专员'),
'|', ('company_id.name', 'in', ['集团本部', '天河粮储']), ('company_id', '=', 3)
])
# 构建「公司名称: 人事专员wecom_userid」映射
company_hr_map = {}
@@ -640,7 +639,7 @@ class YuthonHrEmployee(models.Model):
}
def compute_late_allowed(self):
employee = self.env["hr.employee"].search([('company_id.name', '=', '天河物管')])
employee = self.env["hr.employee"].search([('company_id', '=', 3)])
for employee_id in employee:
employee_id.late_allowed = 3
@@ -894,7 +893,7 @@ class YuthonHrEmployee(models.Model):
def action_batch_fix_resource_calendar(self):
"""根据所属公司批量修复员工工作时间"""
company_calendar_map = {
'天河物管': '行政考勤-物管',
3: '行政考勤-物管',
'集团本部': '行政考勤-本部',
'天河粮储': '行政考勤-粮储',
}
@@ -909,11 +908,11 @@ class YuthonHrEmployee(models.Model):
for employee in self:
company_name = employee.company_id.name if employee.company_id else False
if not company_name or company_name not in company_calendar_map:
if not employee.company_id or (employee.company_id.id not in company_calendar_map and company_name not in company_calendar_map):
skipped_count += 1
continue
calendar_name = company_calendar_map[company_name]
calendar_name = company_calendar_map.get(company_name) or company_calendar_map.get(employee.company_id.id)
calendar = calendar_map.get(calendar_name)
if not calendar:
@@ -193,9 +193,9 @@ class YuthonFileProcessing(models.Model):
prefix_map = {
'集团本部': '穗天投',
'天河粮储': '天粮储司',
'天河物管': '穗天物'
3: '穗天物'
}
prefix = prefix_map.get(company_name)
prefix = prefix_map.get(company_name) or prefix_map.get(self.company_id1.id)
if not prefix:
return
# 构建查询条件:同公司 + 同一年份的文号
@@ -58,8 +58,7 @@ class YuthonOfficialIncomingParty(models.Model):
def _get_default_name_title(self):
company = self.env.user.company_id
special_companies = ['天河物管', '天河粮储']
if any(name in company.name for name in special_companies):
if company.id == 3 or any(name in company.name for name in ['天河粮储']):
return '党支部收文'
return self._description if self._description else self._name
+5 -5
View File
@@ -153,7 +153,7 @@ class YuthonOfficial(models.Model):
if self.company_id.name == '集团本部':
official_partner_id = self.env['official.partner'].search([('name', '=', '广州市天河投资集团有限公司')])
elif self.company_id.name == '天河物管':
elif self.company_id.id == 3:
official_partner_id = self.env['official.partner'].search([('name', '=', '广州市天河物业管理有限公司')])
else:
official_partner_id = self.env['official.partner'].search([('name', '=', '广州天河粮食储备管理有限公司')])
@@ -227,9 +227,9 @@ class YuthonOfficial(models.Model):
prefix_map = {
'集团本部': '穗天投',
'天河粮储': '天粮储司',
'天河物管': '穗天物'
3: '穗天物'
}
prefix = prefix_map.get(company_name)
prefix = prefix_map.get(company_name) or prefix_map.get(self.company_id1.id)
if not prefix:
return
@@ -486,9 +486,9 @@ class YuthonPropertyOfficial(models.Model):
prefix_map = {
'集团本部': '穗天投',
'天河粮储': '天粮储司',
'天河物管': '穗天物'
3: '穗天物'
}
prefix = prefix_map.get(company_name)
prefix = prefix_map.get(company_name) or prefix_map.get(self.company_id1.id)
if not prefix:
return
@@ -90,9 +90,9 @@ class YuthonOfficialBranchParty(models.Model):
prefix_map = {
'集团本部': '穗天投',
'天河粮储': '天粮储司',
'天河物管': '穗天物'
3: '穗天物'
}
prefix = prefix_map.get(company_name)
prefix = prefix_map.get(company_name) or prefix_map.get(self.company_id1.id)
if not prefix:
return
# 构建查询条件:同公司 + 同一年份的文号
@@ -90,9 +90,9 @@ class YuthonOfficialLabor(models.Model):
prefix_map = {
'集团本部': '穗天投',
'天河粮储': '天粮储司',
'天河物管': '穗天物'
3: '穗天物'
}
prefix = prefix_map.get(company_name)
prefix = prefix_map.get(company_name) or prefix_map.get(self.company_id1.id)
if not prefix:
return
year_str = f"〔{current_year}〕"
@@ -74,8 +74,7 @@ class YuthonOfficialParty(models.Model):
def _get_default_name_title(self):
company = self.env.user.company_id
special_companies = ['天河物管', '天河粮储']
if any(name in company.name for name in special_companies):
if company.id == 3 or any(name in company.name for name in ['天河粮储']):
return '党支部发文'
return self._description if self._description else self._name
@@ -98,9 +97,9 @@ class YuthonOfficialParty(models.Model):
prefix_map = {
'集团本部': '穗天投',
'天河粮储': '天粮储司',
'天河物管': '穗天物'
3: '穗天物'
}
prefix = prefix_map.get(company_name)
prefix = prefix_map.get(company_name) or prefix_map.get(self.company_id1.id)
if not prefix:
return
# 构建查询条件:同公司 + 同一年份的文号
@@ -70,7 +70,7 @@ class PropertyBankStatements(models.Model):
if record.your_own_unit in ['天河投资', '天投城建']:
record.company_id = self.env['res.company'].search([('name', '=', '集团本部')], limit=1)
elif record.your_own_unit in ['天河物管']:
record.company_id = self.env['res.company'].search([('name', '=', '天河物管')], limit=1)
record.company_id = self.env['res.company'].browse(3)
elif record.your_own_unit in ['天河粮储']:
record.company_id = self.env['res.company'].search([('name', '=', '天河粮储')], limit=1)
@@ -199,7 +199,7 @@ class PropertyStatementsWizard(models.Model):
purpose = row[6].value
extract = row[7].value
remake = row[8].value
company_id = self.env['res.company'].search([('name', '=', '天河物管')], limit=1)
company_id = self.env['res.company'].browse(3)
pass
def property_bank_statements_zc_data(self, row, your_own_account, bank_branch_own):
@@ -501,7 +501,7 @@ class PropertyStatementsWizard(models.Model):
def _get_company_by_unit(self, unit_name):
if unit_name == '天河物管':
return self.env['res.company'].sudo().search([('name', '=', '天河物管')], limit=1)
return self.env['res.company'].sudo().browse(3)
elif unit_name == '天河粮储':
return self.env['res.company'].sudo().search([('name', '=', '天河粮储')], limit=1)
else:
@@ -979,7 +979,7 @@ class PropertyAccountsReceivable(models.Model):
continue
if rec.company_id:
if rec.company_id.referred == '天河物管':
company = self.env['res.company'].search([('name', '=', '天河物管')], limit=1)
company = self.env['res.company'].browse(3)
rec.company_id2 = company.id if company else False
elif rec.company_id.referred in ('天河投资', '天投城建'):
company = self.env['res.company'].search([('name', '=', '集团本部')], limit=1)
@@ -971,7 +971,7 @@ class PropertyLeaseContract(models.Model):
if lessor_id.referred in ['天河投资', '天投城建']:
company_id = self.env['res.company'].search([('name', '=', '集团本部')], limit=1)
elif lessor_id.referred in ['天河物管']:
company_id = self.env['res.company'].search([('name', '=', '天河物管')], limit=1)
company_id = self.env['res.company'].browse(3)
elif lessor_id.referred in ['天河粮储']:
company_id = self.env['res.company'].search([('name', '=', '天河粮储')], limit=1)
bank_accounts = self.env['property.bank.line'].search([
@@ -209,7 +209,7 @@ class PropertyLeaseRenewal(models.Model):
if lessor_id.referred in ['天河投资', '天投城建']:
company_id = self.env['res.company'].search([('name', '=', '集团本部')], limit=1)
elif lessor_id.referred in ['天河物管']:
company_id = self.env['res.company'].search([('name', '=', '天河物管')], limit=1)
company_id = self.env['res.company'].browse(3)
elif lessor_id.referred in ['天河粮储']:
company_id = self.env['res.company'].search([('name', '=', '天河粮储')], limit=1)
@@ -41,7 +41,7 @@ class RefundWizard(models.TransientModel):
lessor_id = line.contract_id.lessor_id
company_id = self.env['res.company'].search([('name', '=', '集团本部')], limit=1)
if lessor_id.referred in ['天河物管']:
company_id = self.env['res.company'].search([('name', '=', '天河物管')], limit=1)
company_id = self.env['res.company'].browse(3)
elif lessor_id.referred in ['天河粮储']:
company_id = self.env['res.company'].search([('name', '=', '天河粮储')], limit=1)
@@ -61,7 +61,7 @@ class YuthonPayrollCommon(models.Model):
formula_salary = "result = (employee.last_month_commuting_deduction) * -1"
if ins.name == '扣发基本工资':
formula_salary = "result = (employee.last_month_base_salary_deduction) * -1"
if ins.name == '工龄工资' and ins.company_id.name == '天河物管':
if ins.name == '工龄工资' and ins.company_id.id == 3:
formula_salary = "result = employee.company_old_year * 10 if employee.company_old_year >= 1 and employee.department_id.name != '领导班子' else 0"
if ins.name == '工龄工资' and ins.company_id.name == '集团本部':
formula_salary = "result = 0 if (employee.is_annual_salary or '劳务' in (employee.contract_id.structure_type_id.name or '') or '工勤返聘' in (employee.contract_id.structure_type_id.name or '')) else (employee.company_old_year * 10)"
@@ -71,7 +71,7 @@ class YuthonPayrollCommon(models.Model):
formula_salary = "result = 0 if (employee.is_annual_salary or '劳务' in (employee.contract_id.structure_type_id.name or '') or '工勤返聘' in (employee.contract_id.structure_type_id.name or '')) else 300"
if ins.name == '全勤奖' and ins.company_id.name == '集团本部':
formula_salary = "result = 0 if (employee.is_annual_salary or '劳务' in (employee.contract_id.structure_type_id.name or '') or '工勤返聘' in (employee.contract_id.structure_type_id.name or '')) else (200 if employee.last_attendance else 0)"
if ins.name == '全勤奖' and ins.company_id.name == '天河物管':
if ins.name == '全勤奖' and ins.company_id.id == 3:
formula_salary = "result = 100 if employee.last_attendance else 0"
if ins.name == '加班费':
formula_salary = "result = 0 if (employee.is_annual_salary or employee.contract_id.structure_type_id.name == '工勤返聘') else (round(((employee.last_month_overtime - 40) * (payslip.base_salary / 21.75 / 8) * 1.5), 0) if employee.last_month_overtime > 40 else 0)"
@@ -79,7 +79,7 @@ class YuthonPayrollCommon(models.Model):
formula_salary = "result = 0"
if ins.name == '安全生产管理补贴':
formula_salary = "result = employee.security_amount "
if ins.name == '工龄补贴' and ins.company_id.name == '天河物管':
if ins.name == '工龄补贴' and ins.company_id.id == 3:
formula_salary = "result = min(400, max(0, ((employee.entry_date - employee.open_start_time).days // 30.4375 - employee.interrupt_work_month) // 12) * 10 + employee.salary_year * 20) if employee.department_id.name != '领导班子' else 0"
if ins.name == '岗位绩效':
formula_salary = "result = 0"
@@ -97,11 +97,11 @@ class YuthonPayrollCommon(models.Model):
formula_salary = "result = 0"
if ins.name == '儿童节慰问金':
formula_salary = "result = 0"
if ins.name == '春节福利' and ins.company_id.name == '天河物管':
if ins.name == '春节福利' and ins.company_id.id == 3:
formula_salary = "result = 680 if employee.salary_month == '1' and employee.department_id.name != '领导班子' else 0"
if ins.name == '质检员津贴':
formula_salary = "result = employee.quality_inspector_amount"
if ins.name == '工会会费' and ins.company_id.name in ['集团本部', '天河物管']:
if ins.name == '工会会费' and (ins.company_id.id == 3 or ins.company_id.name == '集团本部'):
formula_salary = "result = round(abs(payslip.base_salary * 0.005) * -1, 2)"
if ins.name == '工会会费' and ins.company_id.name == '天河粮储':
formula_salary = "result = abs(20 if employee.user_role_id.name in ['总经理', '副总经理'] else \
@@ -234,7 +234,7 @@ class YuthonPayrollInsurances (models.Model):
code = 'ZFGJJ'
formula_salary = "result = (round((employee.salary_housing_fund * " + str(number) + "), 0)) if employee.is_accum_salary else 0"
if ins.name == '企业(职业)年金':
if ins.company_id.name == '天河物管':
if ins.company_id.id == 3:
code = 'WGQYNJ'
formula_salary = "result = 0.0 if employee.total_coefficients == 0 else round(abs((employee.converted/employee.total_coefficients * employee.calculation_totals * 0.08 * 0.5)/12) * -1, 2)"
elif ins.company_id.name == '集团本部':
+2 -2
View File
@@ -64,7 +64,7 @@ class YuthonSalaryYear(models.Model):
'on_year_balance', 'former_year_balance',
'on_year_liquidation', 'former_year_liquidation'
],
'天河物管': [
3: [
'one_three_salary', 'job_salary', 'test_salary',
'software_salary', 'safe_salary', 'outstanding_salary',
'leadership_salary'
@@ -76,7 +76,7 @@ class YuthonSalaryYear(models.Model):
for record in self:
company_name = record.company_id.name
sum_value = Decimal('0.00') # 使用 Decimal 类型
fields_to_sum = company_rules.get(company_name, [])
fields_to_sum = company_rules.get(company_name) or company_rules.get(record.company_id.id) or []
for field_name in fields_to_sum:
# 获取字段值并转换为 Decimal
field_value = getattr(record, field_name, 0.0)
+1 -1
View File
@@ -27,7 +27,7 @@ class SalaryYearWizard(models.Model):
row = sh.row(rx)
if self.company_id.name == '集团本部':
self.salary_year_ttjt_data(row)
elif self.company_id.name == '天河物管':
elif self.company_id.id == 3:
self.salary_year_thwg_data(row)
else:
self.salary_year_thlc_data(row)
+1 -1
View File
@@ -29,7 +29,7 @@
<button name="%(salary_year_wizard_downloads_tianhetouzi_action)d" string="模板下载" type="action"
class="btn btn-primary" invisible="company_name != '集团本部'"/>
<button name="%(salary_year_wizard_downloads_tianhewuguan_action)d" string="模板下载" type="action"
class="btn btn-primary" invisible="company_name != '天河物管'"/>
class="btn btn-primary" invisible="company_id != 3"/>
<button name="%(salary_year_wizard_downloads_tianheliangchu_action)d" string="模板下载" type="action"
class="btn btn-primary" invisible="company_name != '天河粮储'"/>
</header>
@@ -8,10 +8,8 @@ class InheritStockPickingType(models.Model):
def update_type(self):
# 定义目标公司名称
target_companies = ['集团本部', '天河粮储', '天河物管']
excluded_depts = ['管理员','集团本部', '天河粮储', '天河物管']
# 查找对应的公司记录
companies = self.env['res.company'].search([('name', 'in', target_companies)])
companies = self.env['res.company'].search(['|', ('name', 'in', ['集团本部', '天河粮储']), ('id', '=', 3)])
if not companies:
return False