From 7795ee74af03ef550fc4372d22576089a9960e17 Mon Sep 17 00:00:00 2001
From: zhou <123@>
Date: Wed, 27 Aug 2025 14:44:37 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../models/property_lease_contract.py | 25 ++++---------------
.../views/property_lease_contract.xml | 7 ------
2 files changed, 5 insertions(+), 27 deletions(-)
diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py
index 675af9bc2..547e2fd74 100644
--- a/yuthon_property_approval/models/property_lease_contract.py
+++ b/yuthon_property_approval/models/property_lease_contract.py
@@ -52,7 +52,7 @@ class PropertyLeaseContract(models.Model):
property_name = fields.Char(string='物业信息')
code = fields.Char(string="流水号", default=lambda self: self.env['ir.sequence'].next_by_code('property_lease_contract_code'))
- admin_id = fields.Many2one('res.users', string="管理员", compute='_compute_admin_id', store=True)
+ admin_id = fields.Many2one('res.users', string="管理员", compute="_compute_lease_ids", store=True)
tenure_type = fields.Selection([('self', '自有'), ('agency', '代管')], string='权属类型')
contract_code = fields.Char(string="合同编号")
contract_date = fields.Date(string="合同签订日期")
@@ -68,8 +68,8 @@ class PropertyLeaseContract(models.Model):
lessor_id = fields.Many2one('yuthon.property.company', string="出租方公司")
rent_company = fields.Char(related='lessor_id.name', string="收租公司名称")
rent_account = fields.Char(related='lessor_id.rent_account', string="收租公司账号")
- users_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user.id)
- department_id = fields.Many2one('hr.department', string="部门", store=True, compute='_compute_department_id')
+ users_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user)
+ department_id = fields.Many2one('hr.department', string="部门", store=True, compute='_compute_lease_ids')
company_id = fields.Many2one(related='users_id.employee_id.company_id', string="公司")
# 承租方的个人信息
lessee_id = fields.Many2one('property.tenant.information', string='承租方')
@@ -220,11 +220,6 @@ class PropertyLeaseContract(models.Model):
reconciliation_count = fields.Integer(string="对账数量", compute='_compute_reconciliation_count')
process_count = fields.Integer(string="流程数量", compute='_compute_process_count')
- @api.depends('users_id')
- def _compute_department_id(self):
- for record in self:
- record.department_id = record.users_id.employee_ids.department_id.id
-
def _compute_contract_count(self):
for record in self:
record.contract_count = self.env['property.accounts.receivable'].search_count([('contract_id', '=', record.id)])
@@ -335,7 +330,8 @@ class PropertyLeaseContract(models.Model):
if electricity_fee_values:
rec.electricity_fee_ids = electricity_fee_values
rec.admin_id = rec.lease_ids[0].admin_line_id.id
- rec.users_id = rec.lease_ids[0].admin_line_id.id
+ # rec.users_id = rec.lease_ids[0].admin_line_id.id
+ rec.department_id = rec.lease_ids[0].admin_line_id.employee_ids.department_id.id
@api.depends(
@@ -1221,11 +1217,6 @@ class PropertyLeaseContract(models.Model):
'property_name': ','.join(lease_name) if lease_name else ''
})
- def action_update_contract(self):
- contract_ids = self.env["property.lease.contract"].browse(self._context.get('active_ids', self._context.get('active_id')))
- for record in contract_ids:
- record._compute_department_id()
-
@api.constrains("contract_code")
def _check_contract_code(self):
"""检查合同编号的唯一性(不区分中英文括号)"""
@@ -1452,12 +1443,6 @@ class PropertyLeaseContract(models.Model):
self.address_for_delivery = self.property_name
self.use_address = self.property_name
- @api.depends("lease_ids")
- def _compute_admin_id(self):
- for record in self:
- if record.lease_ids:
- record.admin_id = record.lease_ids[0].admin_line_id.id
-
@api.onchange("admin_id")
def _onchange_admin_id(self):
if self.admin_id:
diff --git a/yuthon_property_approval/views/property_lease_contract.xml b/yuthon_property_approval/views/property_lease_contract.xml
index 9530c13e3..199f6a0d5 100644
--- a/yuthon_property_approval/views/property_lease_contract.xml
+++ b/yuthon_property_approval/views/property_lease_contract.xml
@@ -925,13 +925,6 @@
code
action = model.disposable_button()
-
- 更新状态
-
-
- code
- action = model.action_update_contract()
-