diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py
index 8e344bcfa..b398fa5bd 100644
--- a/yuthon_property_approval/models/inherit_yuthon_property.py
+++ b/yuthon_property_approval/models/inherit_yuthon_property.py
@@ -660,7 +660,7 @@ class PropertyAccountsReceivable(models.Model):
admin_id = fields.Many2one(related='contract_id.admin_id', string="片区管理员", store=True)
tenure_type = fields.Selection([('self', '自有'), ('agency', '代管')], string='权属类型', compute="compute_tenure_type", store=True)
tenure_type_label = fields.Char(string='权属类型(文本)', compute='_compute_tenure_type_label', store=True)
- precinct_id = fields.Many2one(related='contract_id.precinct_id', string="所属片区", store=True)
+
is_refunded = fields.Boolean(string='是否已退款', compute='_compute_is_refunded', store=True)
penalty = fields.Float(string="违约金基数")
penalty_date = fields.Date(string="违约金日期")
@@ -679,6 +679,39 @@ class PropertyAccountsReceivable(models.Model):
actual_coping = fields.Float(string="实际应付", compute='_compute_actual_coping', store=True)
charging_range = fields.Text(string="收费区间")
+ precinct_id = fields.Many2one('yuthon.precinct.message', string="所属片区", compute='_compute_precinct_id', store=True)
+
+ @api.depends('contract_id', 'contract_id.lease_ids', 'contract_id.lease_ids.address_id',
+ 'contract_id.lease_ids.address_id.manage_information_ids', 'due_date')
+ def _compute_precinct_id(self):
+ """根据合同第一条物业明细的管理信息,按应收开始日期匹配对应管理明细行,取其所属片区"""
+ for rec in self:
+ rec.precinct_id = False
+ if not rec.contract_id or not rec.contract_id.lease_ids:
+ continue
+ address = rec.contract_id.lease_ids[0].address_id
+ if not address or not address.manage_information_ids:
+ continue
+ due_date = rec.due_date
+ if not due_date:
+ continue
+ matched = address.manage_information_ids.filtered(
+ lambda m: m.start_time and m.start_time <= due_date and (not m.end_date or m.end_date >= due_date)
+ )
+ if matched:
+ rec.precinct_id = matched[0].precinct_id
+ else:
+ past = address.manage_information_ids.filtered(lambda m: m.start_time and m.start_time <= due_date)
+ if past:
+ rec.precinct_id = past.sorted('start_time', reverse=True)[0].precinct_id
+
+ def action_precinct_id(self):
+ record_ids = self.env["property.accounts.receivable"].browse(
+ self._context.get("active_ids", self._context.get("active_id"))
+ )
+ for rec in record_ids:
+ rec._compute_precinct_id()
+
def action_fix(self):
record_ids = self.env["property.accounts.receivable"].browse(
self._context.get("active_ids", self._context.get("active_id"))
@@ -1407,6 +1440,7 @@ class PropertyRentList(models.Model):
'management_type_id': management_type.id,
})
rec.is_push = True
+ accounts_id._compute_precinct_id()
accounts_id._compute_lessee_id()
self.reconcile_with_bank_statements(rec)
diff --git a/yuthon_property_approval/views/inherit_yuthon_property_views.xml b/yuthon_property_approval/views/inherit_yuthon_property_views.xml
index 90046a3e8..60c99692b 100644
--- a/yuthon_property_approval/views/inherit_yuthon_property_views.xml
+++ b/yuthon_property_approval/views/inherit_yuthon_property_views.xml
@@ -656,19 +656,26 @@
code
action = model.update_is_liquidated_damages()
-
- 一次性更新
-
-
- code
- action = model.update_damages()
-
+
+
+
+
+
+
+
同步出租方和承租方
code
action = model.update_compute_lessee_id()
+
+
+ 同步片区管理员
+
+
+ code
+ action = model.action_precinct_id()
批量退回
@@ -677,13 +684,13 @@
code
action = model.action_refuse_all()
-
- 批量修复押金旧数据
-
-
- code
- action = model.action_batch_fix_deposit()
-
+
+
+
+
+
+
+
property.bank.statements.tree