添加功能

This commit is contained in:
zhou
2025-02-18 20:59:16 +08:00
parent 4d9bc1932a
commit 4000bff316
12 changed files with 204 additions and 5 deletions
@@ -2,7 +2,6 @@
from odoo import api, fields, models, _
from odoo.exceptions import UserError, ValidationError
from datetime import datetime
import re
class YuthonMedicalManage(models.Model):
@@ -19,3 +18,22 @@ class YuthonMedicalManage(models.Model):
prev_last_year_balance = fields.Float(string="前年结余")
prev_last_year_used = fields.Float(string="前年使用")
prev_last_year_remaining = fields.Float(string="前年剩余")
medical_line_ids = fields.One2many('yuthon.medical.line', 'medical_manage_id', string="体检费明细")
def button_details(self):
form_id = self.env.ref('yuthon_hr_employee.view_yuthon_medical_manage_form').id
return {
"type": "ir.actions.act_window",
"name": "修正申请",
"res_model": "yuthon.medical.manage",
"views": [[form_id, "form"]],
"res_id": self.id,
}
class YuthonMedicalLine(models.Model):
_name = 'yuthon.medical.line'
_description = '体检费明细'
medical_manage_id = fields.Many2one('yuthon.medical.manage', string="关联体检费管理")
medical_date = fields.Date(string="体检日期")
medical_fee = fields.Float(string="费用")
@@ -11,6 +11,8 @@ class YuthonMedicalRule(models.Model):
base_amount = fields.Float(string='基数金额')
starting_age = fields.Integer(string='起始年龄')
department_id = fields.Many2one("hr.department", string="部门")
extension_years = fields.Selection(selection=[(str(i), str(i)) for i in range(1, 13)], string='延续年限')
increase_interval_years = fields.Integer(string='递增间隔(年)')
increment_amount = fields.Float(string='递增金额')
cap = fields.Float(string='封顶金额')
@@ -17,4 +17,5 @@ access_yuthon_hr_employee_time_wizard,yuthon_hr_employee_time_wizard,model_yutho
access_hr_job_add_wizard,hr_job_add_wizard,model_hr_job_add_wizard,base.group_user,1,1,1,1
access_yuthon_party_setting,yuthon_party_setting,model_yuthon_party_setting,base.group_user,1,1,1,1
access_yuthon_medical_rule,yuthon_medical_rule,model_yuthon_medical_rule,base.group_user,1,1,1,1
access_yuthon_medical_manage,yuthon_medical_manage,model_yuthon_medical_manage,base.group_user,1,1,1,1
access_yuthon_medical_manage,yuthon_medical_manage,model_yuthon_medical_manage,base.group_user,1,1,1,1
access_yuthon_medical_line,yuthon_medical_line,model_yuthon_medical_line,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
17 access_hr_job_add_wizard hr_job_add_wizard model_hr_job_add_wizard base.group_user 1 1 1 1
18 access_yuthon_party_setting yuthon_party_setting model_yuthon_party_setting base.group_user 1 1 1 1
19 access_yuthon_medical_rule yuthon_medical_rule model_yuthon_medical_rule base.group_user 1 1 1 1
20 access_yuthon_medical_manage yuthon_medical_manage model_yuthon_medical_manage base.group_user 1 1 1 1
21 access_yuthon_medical_line yuthon_medical_line model_yuthon_medical_line base.group_user 1 1 1 1
@@ -15,9 +15,55 @@
<field name="prev_last_year_balance"/>
<field name="prev_last_year_used"/>
<field name="prev_last_year_remaining"/>
<button name="button_details" string="查看详情" type="object" class="oe_highlight"/>
</tree>
</field>
</record>
<record id="view_yuthon_medical_manage_form" model="ir.ui.view">
<field name="name">yuthon.medical.manage.form</field>
<field name="model">yuthon.medical.manage</field>
<field name="arch" type="xml">
<form string="体检费管理">
<sheet>
<div class="oe_title">
<label for="employee_id"/>
<h1>
<field name="employee_id"/>
</h1>
</div>
<group>
<field name="current_year_remaining"/>
</group>
<group col="2">
<group>
<field name="last_year_quota"/>
<field name="last_year_quota"/>
<field name="last_year_balance"/>
<field name="last_year_used"/>
<field name="last_year_remaining"/>
</group>
<group>
<field name="prev_last_year_quota"/>
<field name="prev_last_year_balance"/>
<field name="prev_last_year_used"/>
<field name="prev_last_year_remaining"/>
</group>
</group>
<notebook>
<page string="体检费">
<field name="medical_line_ids">
<tree editable="bottom">
<field name="medical_manage_id" column_invisible="1"/>
<field name="medical_date"/>
<field name="medical_fee"/>
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<record id="view_yuthon_medical_manage_action" model="ir.actions.act_window">
<field name="name">体检费管理</field>
<field name="res_model">yuthon.medical.manage</field>
@@ -12,6 +12,8 @@
<field name="cap"/>
<field name="allowance_unmarried_women"/>
<field name="allowance_married_women"/>
<field name="department_id"/>
<field name="extension_years"/>
<field name="start_date"/>
<field name="end_date"/>
<field name="is_enable"/>
+1
View File
@@ -63,6 +63,7 @@
'views/property_transaction_confirmed.xml',
'wizard/property_add_wizard_views.xml',
'wizard/property_contract_wizard.xml',
'wizard/property_physical_wizard_views.xml',
'wizard/choose_contract_wizard_views.xml',
'wizard/property_rental_wizard_views.xml',
'views/property_menu_all.xml',
@@ -21,7 +21,44 @@ class PropertyReimbursementForm(models.Model):
company_page = fields.Selection([('tz', '天河投资'), ('wg', '天河物管'), ('lc', '天河粮储')], string="公司")
account_id = fields.Many2one('property.account.setting', string="账户")
expense_line_ids = fields.One2many('property.expense.line', 'reimbursement_id', string="费用项目明细")
physical_line_ids = fields.One2many('property.physical.line', 'reimbursement_id', string="体检费明细")
def put_physical_in(self): # 导入按钮
return {
"type": "ir.actions.act_window",
"name": "导入体检费明细",
"res_model": "property.physical.wizard",
"view_mode": "form",
"target": "new",
}
# 体检费计算方法
def compute_reimbursement(self):
for record in self:
for rec in record.physical_line_ids:
rule_id = self.env['yuthon.medical.rule'].search([('department_id', '=', rec.employee_id.department_id.id)])
employee_id = self.env['yuthon.medical.manage'].search([('employee_id', '=', rec.employee_id.id)])
if not employee_id:
years_passed = rec.employee_id.old - rule_id.starting_age
decades_passed = years_passed // rule_id.increase_interval_years
increased_amount = decades_passed * rule_id.increment_amount
total_amount = rule_id.base_amount + increased_amount - rec.fees
final_amount = min(total_amount, rule_id.cap)
if rec.employee_id.user_sex == 'girl':
if rec.employee_id.marital == 'single':
final_amount = final_amount + rule_id.allowance_unmarried_women - rec.fees
else:
final_amount = final_amount + rule_id.allowance_married_women - rec.fees
employee_id = self.env['yuthon.medical.manage'].create({
'employee_id': rec.employee_id.id,
'current_year_remaining': final_amount})
else:
final_amount = employee_id.current_year_remaining - rec.fees
employee_id.write({'current_year_remaining': final_amount})
self.env['yuthon.medical.line'].create({
'medical_manage_id': employee_id.id,
'medical_date': rec.reimbursement_date,
'medical_fee': rec.fees})
class PropertyExpenseLine(models.Model):
_name = 'property.expense.line'
@@ -29,11 +66,22 @@ class PropertyExpenseLine(models.Model):
reimbursement_id = fields.Many2one('property.reimbursement.form', string='关联报销单')
expense_id = fields.Many2one('property.project.setting', string='费用项目')
invoice_type = fields.Char(string='发票类型')
invoice_type = fields.Selection([('ordinary_invoice', '普通发票'), ('vat_invoice', '增值税发票'), ('air_ticket', '机票'),
('train_ticket', '火车票'), ('other_transport_ticket', '其他运输票'), ('other', '其他')], string='发票类型', default='ordinary_invoice')
expense_amount = fields.Float(string='费用金额')
applied_reimbursement_amount = fields.Float(string='申请报销金额')
expense_department_id = fields.Many2one('hr.department', string='费用承担部门')
invoice_receipt_number = fields.Char(string='收票单号')
applied_payment_amount = fields.Float(string='申请付款金额')
approved_reimbursement_amount = fields.Float(string='核定报销金额')
approved_payment_amount = fields.Float(string='核定付款金额')
approved_payment_amount = fields.Float(string='核定付款金额')
class PropertyPhysicalLine(models.Model):
_name = 'property.physical.line'
_description = '体检费明细'
reimbursement_id = fields.Many2one('property.reimbursement.form', string='关联报销单')
employee_id = fields.Many2one('hr.employee', string='姓名')
reimbursement_date = fields.Date(string='报销日期')
fees = fields.Float(string='费用')
@@ -82,4 +82,6 @@ access_choose_property_wizard,choose_property_wizard,model_choose_property_wizar
access_property_rental_wizard,property_rental_wizard,model_property_rental_wizard,base.group_user,1,1,1,1
access_property_reimbursement_form,property_reimbursement_form,model_property_reimbursement_form,base.group_user,1,1,1,1
access_property_expense_line,property_expense_line,model_property_expense_line,base.group_user,1,1,1,1
access_property_physical_line,property_physical_line,model_property_physical_line,base.group_user,1,1,1,1
access_property_physical_wizard,property_physical_wizard,model_property_physical_wizard,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
82 access_property_reimbursement_form property_reimbursement_form model_property_reimbursement_form base.group_user 1 1 1 1
83 access_property_expense_line property_expense_line model_property_expense_line base.group_user 1 1 1 1
84 access_property_physical_line property_physical_line model_property_physical_line base.group_user 1 1 1 1
85 access_property_physical_wizard property_physical_wizard model_property_physical_wizard base.group_user 1 1 1 1
86
87
@@ -21,6 +21,7 @@
<field name="code" readonly="1" string="流水号:"/>
</group>
<sheet>
<button name="compute_reimbursement" string="提交" type="object" class="oe_highlight"/>
<group string="审批事项">
<field name="name"/>
<field name="users_id"/>
@@ -47,6 +48,19 @@
</field>
</page>
</notebook>
<notebook>
<page string="体检费明细">
<button name="put_physical_in" string="导入" type="object" class="oe_highlight"/>
<field name="physical_line_ids">
<tree editable="bottom">
<field name="reimbursement_id" column_invisible="1"/>
<field name="employee_id"/>
<field name="reimbursement_date"/>
<field name="fees"/>
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
+2 -1
View File
@@ -1,4 +1,5 @@
from . import property_contract_wizard
from . import choose_property_wizard
from . import property_rental_wizard
from . import property_add_wizard
from . import property_add_wizard
from . import property_physical_wizard
@@ -0,0 +1,29 @@
from odoo import models, fields, api, _, SUPERUSER_ID
from odoo.exceptions import ValidationError, UserError
import xlrd
import base64
import datetime
from datetime import datetime
import pandas as pd
class PropertyPhysicalWizard(models.Model):
_name = 'property.physical.wizard'
excel_file = fields.Binary(string="上传Excel表")
excel_name = fields.Char(string="文件名")
def confirm(self):
"""
导入excel文件,按行读取数据并处理
"""
if not self.excel_file:
raise ValidationError('请上传文件。')
book = xlrd.open_workbook(file_contents=base64.decodebytes(self.excel_file))
sh = book.sheet_by_index(0)
for rx in range(1, sh.nrows):
row = sh.row(rx)
self.yuthon_physical_update(row)
def yuthon_physical_update(self, row):
pass
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="property_physical_template_downloads_he_action" model="ir.actions.act_url">
<field name="name">体检费模板</field>
<field name="target">self</field>
<field name="url">...</field>
</record>
<record id="property_physical_wizard_form" model="ir.ui.view">
<field name="name">体检费导入弹窗</field>
<field name="model">property.physical.wizard</field>
<field name="arch" type="xml">
<form>
<sheet>
<header>
<button name="%(property_physical_template_downloads_he_action)d" string="模板下载" type="action"
class="btn btn-primary"/>
</header>
<group>
<group>
<field name="excel_file" filename="excel_name"/>
<field name="excel_name" invisible="1"/>
</group>
<group>
</group>
</group>
</sheet>
<footer>
<button name="confirm" string="确认" type="object" class="oe_highlight"/>
<button string="返回" class="btn-secondary" special="cancel"/>
</footer>
</form>
</field>
</record>
</odoo>