diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py
index 226418e8a..9ebf4a649 100644
--- a/yuthon_property_approval/models/inherit_yuthon_property.py
+++ b/yuthon_property_approval/models/inherit_yuthon_property.py
@@ -661,7 +661,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="违约金日期")
@@ -681,6 +681,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"))
@@ -1426,6 +1459,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 9ecd69079..b443d05d3 100644
--- a/yuthon_property_approval/views/inherit_yuthon_property_views.xml
+++ b/yuthon_property_approval/views/inherit_yuthon_property_views.xml
@@ -657,26 +657,26 @@
code
action = model.update_is_liquidated_damages()
-
- 一次性更新
-
-
- code
- action = model.update_damages()
-
-
- 批量写入违约金比例
-
-
- code
- action = model.fill_penalty_ratio_value()
-
+
+
+
+
+
+
+
同步出租方和承租方
code
action = model.update_compute_lessee_id()
+
+
+ 同步片区管理员
+
+
+ code
+ action = model.action_precinct_id()
批量退回
@@ -685,13 +685,13 @@
code
action = model.action_refuse_all()
-
- 批量修复押金旧数据
-
-
- code
- action = model.action_batch_fix_deposit()
-
+
+
+
+
+
+
+
property.bank.statements.tree