添加功能

This commit is contained in:
zhou
2025-06-11 10:33:48 +08:00
parent 448a9dc74d
commit 3feaf50f0e
9 changed files with 50 additions and 66 deletions
@@ -47,6 +47,7 @@ class SoongWorkflowRecord(models.Model):
department_id = fields.Many2one("hr.department", string="部门", required=True)
done_by = fields.Many2one(comodel_name="res.users", string="发起人")
active = fields.Boolean(string="归档", default=True)
soong_state = fields.Selection([('to_do', '待办'), ('done', '已办')], string="流程状态", default="done")
member_of_department = fields.Boolean("是否是本部门数据", compute='_compute_part_of_department', search='_search_part_of_department')
@api.depends_context('uid', 'company')
@@ -100,6 +101,23 @@ class SoongWorkflowRecord(models.Model):
"view_mode": "form",
}
@api.model
def get_view(self, view_id=None, view_type='form', **options):
"""在视图加载时检查当前用户是否在经办人列表中,并更新状态"""
# 检查是否通过特定动作触发(替换为你的视图ID)
if options.get('action_id') == 538: # 替换为实际的视图ID
current_employee = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
if current_employee:
# 更新所有当前用户是经办人的记录状态为"待办"
records = self.search([
('employee_ids', 'in', current_employee.ids),
('soong_state', '=', 'done')
])
if records:
records.write({'soong_state': 'to_do'})
return super(SoongWorkflowRecord, self).get_view(view_id, view_type, **options)
# def get_department_employees(self, department_id):
# valid_user_ids = set()
# employee_ids = self.sudo().env['hr.employee'].search([('department_id', '=', department_id.id)])
@@ -24,7 +24,7 @@
<field name="model">soong.workflow.record</field>
<field name="arch" type="xml">
<tree string="流程查询" action="open_record" type="object"
decoration-muted="approve_state == 'end'"
decoration-danger="approve_state == 'end'"
create="false" default_order="write_date2 desc">
<field name="code"/>
<field name="name"/>
@@ -40,6 +40,7 @@
<field name="company_id" optional="hide"/>
<field name="text" optional="hide"/>
<field name="documents_ids" widget="preview_many2many"/>
<field name="soong_state"/>
<field name="reclaim_state" column_invisible="1"/>
<field name="member_of_department" optional="hide"/>
<button name="delete_record" type="object" string="删除" class="btn-primary" confirm="你确定要删除吗?"/>
@@ -118,6 +119,7 @@
<field name="type">ir.actions.act_window</field>
<field name="res_model">soong.workflow.record</field>
<field name="view_mode">tree,kanban,search</field>
<field name="context">{'check_employee': 1}</field>
<field name="domain">[('employee_ids.user_id', '=', uid), ('reclaim_state', '=', False)]</field>
<field name="search_view_id" ref="soong_workflow_record_search"/>
</record>
@@ -63,7 +63,7 @@
<record id="view_yuthon_vacation_reports_action" model="ir.actions.act_window">
<field name="name">假期报表</field>
<field name="res_model">yuthon.vacation.reports</field>
<field name="view_mode">tree</field>
<field name="view_mode">tree,form</field>
</record>
<record id="all_update_employee" model="ir.actions.server">
<field name="name">更新报表</field>
+11 -30
View File
@@ -509,36 +509,17 @@ class YuthonHrEmployee(models.Model):
domain = expression.AND([search_domain, domain])
return self._search(domain, limit=limit, order=order)
def put_overtime_return(self):
uid = self.user_id.id
action = {
'name': '加班详情',
'type': 'ir.actions.act_window',
'res_model': 'overtime.approval',
'view_mode': 'tree',
'domain': [('users_id', '=', uid)],
}
return action
def put_batch_return(self):
uid = self.user_id.id
action = {
'type': 'ir.actions.act_window',
'res_model': 'hr.leave.batch',
'view_mode': 'tree',
'domain': [('users_id', '=', uid)],
}
return action
def put_holiday_return(self):
employee_id = self.user_id.employee_id.id
action = {
'name': '请假详情',
'type': 'ir.actions.act_window',
'res_model': 'hr.leave',
'view_mode': 'tree',
'domain': [('employee_id', '=', employee_id)],
}
return action
def employee_log(self):
vacation_id = self.env['yuthon.vacation.reports'].search([('employee_id', '=', self.id)])
if vacation_id:
return {
'name': '休假记录',
'type': 'ir.actions.act_window',
'res_model': 'yuthon.vacation.reports',
'view_mode': 'form',
'res_id': vacation_id.id,
'target': 'new'
}
@@ -9,6 +9,9 @@
<xpath expr="//form" position="attributes">
<attribute name="create">0</attribute>
</xpath>
<xpath expr="//button[@name='487']" position="after">
<button name="employee_log" string="余额扣减日志" type="object" class="oe_highlight"/>
</xpath>
<xpath expr="//field[@name='parent_id']" position="attributes">
<attribute name="string">上级领导</attribute>
<attribute name="options">"{'no_create': True}"</attribute>
@@ -165,9 +168,6 @@
<field name="is_salary"/>
<field name="last_attendance"/>
</group>
<group>
<button name="put_holiday_return" string="详情" type="object" class="oe_highlight"/>
</group>
</group>
<group name="overtime" string="加班" col="3">
<group>
@@ -184,9 +184,6 @@
<field name="result_overtime" readonly="1"/>
<field name="overtime_last_month" readonly="1"/>
</group>
<group>
<button name="put_overtime_return" string="详情" type="object" class="oe_highlight"/>
</group>
</group>
<group>
<field name="holiday_hours"/>
@@ -205,9 +202,6 @@
<field name="cumulative_hours"/>
<field name="all_year"/>
</group>
<group>
<button name="put_batch_return" type="object" string="详情" class="oe_highlight"/>
</group>
</group>
</xpath>
<xpath expr="//page[@name='hr_settings']" position="before">
+2 -2
View File
@@ -114,12 +114,12 @@
sequence="10"
name="电表库"
parent="yuthon_property_archives_setting_meu"
action="action_property_meter_archives"/>
action="yuthon_property_approval.action_property_meter_archives"/>
<menuitem id="yuthon_property_archives_water_menu"
sequence="15"
name="水表库"
parent="yuthon_property_archives_setting_meu"
action="action_property_meter_water"/>
action="yuthon_property_approval.action_property_meter_water"/>
<menuitem id="yuthon_property_science_menu"
sequence="13"
@@ -91,7 +91,6 @@ class PropertyBankStatements(models.Model):
'rent': '租金',
'water_fee': '水费',
'electricity_fee': '电费',
'penalty': '违约',
'management_fee': '管理费',
'repair_fee': '维修费',
'other': '其他'
@@ -114,11 +113,6 @@ class PropertyBankStatements(models.Model):
due_date = False
if contract_id:
due_date = sub_record.contract_id.actual_start_time
management_type_id = self.env['yuthon.management.type'].search(
[('name', '=', collection_type_dict[collection_type_val])], limit=1)
accounts_id = self.env['property.accounts.receivable'].search(
[('lessee_id', '=', tenant_id.id), ('due_date', '=', due_date),
('management_type_id', '=', management_type_id.id)], limit=1)
# 构建对账行数据
vals = {
'property_id': property_id,
@@ -126,8 +120,7 @@ class PropertyBankStatements(models.Model):
'rent_month': original_amount,
'rent': original_amount,
'collection_type': collection_type_val,
'due_date': due_date, # 押金类型使用合同实际开始日期
'penalty': accounts_id.penalty if accounts_id else 0,
'due_date': due_date, # 押金类型使用合同实际开始日期
}
total_rent_month += original_amount # 累加总金额
vals_list.append((0, 0, vals))
@@ -141,11 +134,6 @@ class PropertyBankStatements(models.Model):
contract_id = sub_record.contract_id.id if sub_record.contract_id else False
original_amount = sub_record.original_amount if sub_record.original_amount else 0
due_date = sub_record.due_date if sub_record.due_date else False
management_type_id = self.env['yuthon.management.type'].search(
[('name', '=', collection_type_dict[collection_type_val])], limit=1)
accounts_id = self.env['property.accounts.receivable'].search(
[('lessee_id', '=', tenant_id.id), ('due_date', '=', due_date),
('management_type_id', '=', management_type_id.id)], limit=1)
vals = {
'property_id': property_id,
'contract_id': contract_id,
@@ -153,7 +141,6 @@ class PropertyBankStatements(models.Model):
'rent': original_amount,
'collection_type': collection_type_val,
'due_date': due_date,
'penalty': accounts_id.penalty if accounts_id else 0,
}
total_rent_month += original_amount # 累加总金额
vals_list.append((0, 0, vals))
@@ -178,6 +165,7 @@ class PropertyBankStatements(models.Model):
:return:
"""
context = {
"default_actual_date": fields.Date.to_date(self.start_time),
"default_bank_id": self.id,
"default_account": record.name,
"default_actual_total": record.original_amount,
@@ -500,12 +488,6 @@ class PropertyWaterList(models.Model):
})
rec.is_push = True
def push_water_message(self):
for rec in self:
rec.write({
'is_message': True,
})
def batch_push_water(self):
archives_ids = self.env["property.water.list"].browse(
self._context.get('active_ids', self._context.get('active_id')))
@@ -583,6 +565,12 @@ class PropertyWaterReading(models.Model):
reading_state = fields.Selection([
('wait' , '待抄'), ('finish', '已抄表')])
def push_water_message(self):
for rec in self:
rec.write({
'is_message': True,
})
def button_push_water(self):
for rec in self:
if rec.is_push:
@@ -600,6 +588,7 @@ class PropertyWaterReading(models.Model):
rec.write({
'is_push': True,
})
def batch_reading_water(self):
archives_ids = self.env["property.water.reading"].browse(
self._context.get('active_ids', self._context.get('active_id')))
@@ -10,6 +10,7 @@ class PropertyReconciliationWizard(models.Model):
bank_id = fields.Many2one('property.bank.statements', string='银行流水')
account = fields.Char(string='账号')
actual_total = fields.Float(string='实收金额')
actual_date = fields.Date(string='实收日期')
initial_total = fields.Float(string='初始金额', default=0.0)
reconciliation_line_ids = fields.One2many('property.reconciliation.line', 'reconciliation_id', string='对账明细')
@@ -51,7 +52,6 @@ class PropertyReconciliationLine(models.Model):
rent_month = fields.Float(string='当月租金')
due_date = fields.Date(string='应收日期')
rent = fields.Float(string='应收租金')
penalty = fields.Float(string='违约金')
amount = fields.Float(string='金额')
collection_type = fields.Selection([('deposit', '押金'), ('rent', '租金'), ('water_fee', '水费'),
('electricity_fee', '电费'), ('penalty', '违约'), ('management_fee', '管理费'), ('repair_fee', '维修费'),
@@ -10,19 +10,19 @@
<field name="account"/>
<field name="receivable_total"/>
<field name="actual_total"/>
<field name="actual_date"/>
<field name="initial_total" invisible="1"/>
</group>
<notebook>
<page name="对账明细">
<field name="reconciliation_line_ids">
<tree editable="bottom">
<tree editable="bottom" create="false" delete="false" edit="false">
<field name="reconciliation_id" column_invisible="1"/>
<field name="property_id"/>
<field name="contract_id"/>
<field name="due_date"/>
<field name="rent_month" sum = "Total"/>
<field name="rent" sum = "Total"/>
<field name="penalty" sum = "Total"/>
<field name="collection_type"/>
<field name="amount" sum = "Total"/>
<field name="remake"/>