添加功能

This commit is contained in:
李鹏宇
2025-11-18 17:11:13 +08:00
parent 7ede66394d
commit 4750a7dbf0
6 changed files with 63 additions and 6 deletions
@@ -1062,6 +1062,7 @@ class AttendanceMessageLog(models.Model):
employee_id = fields.Many2one('hr.employee', string='员工')
department_id = fields.Many2one(related='employee_id.department_id', string="部门", index=True)
company_id = fields.Many2one(related='employee_id.company_id', string="公司")
service_address = fields.Char(string='服务地址')
update_date = fields.Datetime(string='提醒时间')
shift_id = fields.Many2one('planning.slot', string="班次", compute="_compute_shift_id", store=True)
content = fields.Text(string='内容')
@@ -10,6 +10,7 @@
<field name="department_id"/>
<field name="update_date"/>
<field name="content"/>
<field name="service_address"/>
<field name="message_url"/>
<field name="company_id"/>
</tree>
@@ -337,6 +337,17 @@ class PropertyBankStatements(models.Model):
def _get_reconciliation_vals(self, record):
if record.name:
collection_type_map = {
'rent': '租金',
'deposit': '押金',
'management_fee': '管理费',
'lightbox': '灯箱',
'guanzijian': '管子间',
'water_fee': '水费',
'electricity_fee': '电费',
'fee': '人工费/日光灯款/代垫用料费',
}
used_type_names = set()
total_rent_month = 0
# 应收租金
rent_ids = self.env['property.accounts.receivable'].search([
@@ -415,6 +426,7 @@ class PropertyBankStatements(models.Model):
nonlocal total_rent_month
vals_list = []
current_sequence = sequence_val
type_name = collection_type_map.get(collection_type_val, '')
# 特殊处理:押金类型需要去重相同合同的记录
if collection_type_val == 'deposit':
# 使用字典来跟踪已处理的合同ID
@@ -466,6 +478,9 @@ class PropertyBankStatements(models.Model):
current_sequence += 10
if vals_list and type_name:
used_type_names.add(type_name)
return vals_list, current_sequence
all_vals = []
@@ -487,10 +502,10 @@ class PropertyBankStatements(models.Model):
all_vals.extend(electricity_vals)
all_vals.extend(fee_vals)
return all_vals, total_rent_month
return all_vals, total_rent_month, used_type_names
return [], 0
def _get_context_and_action(self, record, all_vals, total_rent_month):
def _get_context_and_action(self, record, all_vals, total_rent_month, used_type_names):
"""
:param record: 银行收款记录
:param all_vals: 应收费用列表
@@ -498,6 +513,10 @@ class PropertyBankStatements(models.Model):
:return:
"""
start_time = self.start_time + relativedelta(hours=8)
management_types = self.env['yuthon.management.type'].search([
('name', 'in', list(used_type_names))
])
context = {
"default_actual_date": fields.Date.to_date(start_time),
"default_bank_id": self.id,
@@ -510,6 +529,7 @@ class PropertyBankStatements(models.Model):
"default_receivable_total": total_rent_month,
"dialog_size": "extra-large",
"default_order": "due_date desc",
"default_receivables_type_ids": [(6, 0, management_types.ids)] if management_types else [],
}
self._check_unreconciled_statements(start_time)
@@ -554,8 +574,8 @@ class PropertyBankStatements(models.Model):
def button_reconciliation(self):
for record in self:
all_vals, total_rent_month = self._get_reconciliation_vals(record)
return self._get_context_and_action(record, all_vals, total_rent_month)
all_vals, total_rent_month, used_type_names = self._get_reconciliation_vals(record)
return self._get_context_and_action(record, all_vals, total_rent_month, used_type_names)
def put_button(self):
form_id = self.env.ref('yuthon_property_approval.view_property_accounts_approval_form').id
@@ -16,6 +16,7 @@ class PropertyReconciliationWizard(models.Model):
bank_id = fields.Many2one('property.bank.statements', string='银行流水')
lessee_ids = fields.Many2many('property.tenant.information', string='承租方')
receivables_type_ids = fields.Many2many('yuthon.management.type', string="应收类型")
name_account = fields.Char( string='对方户名')
account = fields.Char(string='账号')
contract_ids = fields.Many2many('property.lease.contract', string='合同')
@@ -40,14 +41,12 @@ class PropertyReconciliationWizard(models.Model):
rec.amount_water_been = rec.bank_id.yes_amount
rec.amount_water = rec.bank_id.no_amount
@api.depends('reconciliation_line_ids')
def _compute_receivable_total(self):
for rec in self:
rec.receivable_total = sum(line.rent for line in rec.reconciliation_line_ids)
rec.amount_reconciled = rec.bank_id.no_amount - sum(line.amount for line in self.reconciliation_line_ids)
@api.depends('reconciliation_line_ids.collection_type', 'reconciliation_line_ids.rent')
def _compute_rent_total(self):
"""计算所有类型为租金的明细行的未收总额"""
@@ -85,6 +84,39 @@ class PropertyReconciliationWizard(models.Model):
to_delete.append((2, line.id, 0))
rec.reconciliation_line_ids = to_delete
@api.onchange('receivables_type_ids')
def onchange_receivables_type_ids(self):
for rec in self:
selected_type_names = rec.receivables_type_ids.mapped('name')
if not selected_type_names:
rec.reconciliation_line_ids = [(5, 0, 0)]
continue
# 收款类型与名称的映射(包含违约金,但后续会排除)
type_name_map = {
'deposit': '押金',
'rent': '租金',
'water_fee': '水费',
'lightbox': '灯箱',
'guanzijian': '管子间',
'electricity_fee': '电费',
'penalty': '违约金', # 存在但会被排除
'management_fee': '管理费',
'repair_fee': '维修费',
'fee': '人工费/日光灯款/代垫用料费',
}
allowed_by_selection = [
coll_type for coll_type, name in type_name_map.items()
if name in selected_type_names
]
allowed_collection_types = allowed_by_selection + ['penalty']
to_delete = []
for line in rec.reconciliation_line_ids:
if line.collection_type not in allowed_collection_types:
to_delete.append((2, line.id, 0))
if to_delete:
rec.reconciliation_line_ids = to_delete
@api.onchange('actual_total')
def compute_reconciliation_line_ids(self):
new_lines = []
@@ -49,6 +49,7 @@
</group>
</group>
<group>
<field name="receivables_type_ids" widget="many2many_tags" options="{'no_create': True}"/>
<field name="contract_ids" widget="many2many_tags" options="{'no_create': True}"/>
<field name="remake" readonly="1"/>
</group>
+2
View File
@@ -173,10 +173,12 @@ class WeComApps(models.Model):
result_data = self.sync_function_api("message_send", "MESSAGE_SEND", data, category)
employee_id = self.env["res.users"].search([("login", "=", user_id)], limit=1).employee_id
notice_type = 'attendance' if '记得打卡' in description else 'process'
service_address = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
self.env["attendance.message.log"].create({
"employee_id": employee_id.id,
"content": description,
"notice_type": notice_type,
"service_address":service_address,
'update_date': fields.Datetime.now(),
"message_url": url,
})