diff --git a/soong_workflow/wizard/soong_workflow_comment_wizard_view.xml b/soong_workflow/wizard/soong_workflow_comment_wizard_view.xml
index fd279274f..a0cfadd70 100644
--- a/soong_workflow/wizard/soong_workflow_comment_wizard_view.xml
+++ b/soong_workflow/wizard/soong_workflow_comment_wizard_view.xml
@@ -110,7 +110,7 @@
+ options="{'no_open': True, 'fg_color': 'red'}" widget="radio" force_save="1"/>
diff --git a/yuthon_property/models/property_accounts_receivable.py b/yuthon_property/models/property_accounts_receivable.py
index 2a3106143..1823d0daa 100644
--- a/yuthon_property/models/property_accounts_receivable.py
+++ b/yuthon_property/models/property_accounts_receivable.py
@@ -65,7 +65,12 @@ class PropertyAccountsReceivable(models.Model):
def _onchange_contract_id(self):
"""选择合同时自动填充税率"""
if self.contract_id and self.contract_id.tax_rate:
- self.tax = float(self.contract_id.tax_rate.name)
+ tax_str = self.contract_id.tax_rate.name.strip()
+ tax_str_clean = tax_str.replace('%', '')
+ if tax_str_clean.replace('.', '', 1).isdigit():
+ self.tax = float(tax_str_clean)
+ else:
+ self.tax = 0.0
def action_update_tax_from_contract(self):
"""批量更新税率:从合同获取正确税率"""
diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py
index 9c4d9477b..623052989 100644
--- a/yuthon_property_approval/models/inherit_yuthon_property.py
+++ b/yuthon_property_approval/models/inherit_yuthon_property.py
@@ -589,8 +589,8 @@ class PropertyAccountsReceivable(models.Model):
is_penalty = fields.Boolean(string='是否违约金', default=True, compute = '_compute_is_penalty', store=True)
management_area = fields.Float(related='contract_id.total_area', string='面积')
title_deed = fields.Char(string="产权证号", compute='_compute_title_deed')
- lessee_id = fields.Many2one(related='contract_id.lessee_id', string='承租方', store=True)
- company_id = fields.Many2one(related='contract_id.lessor_id', string="出租方公司", store=True)
+ lessee_id = fields.Many2one('property.tenant.information', string='承租方', store=True, compute='_compute_lessee_id')
+ company_id = fields.Many2one('yuthon.property.company', string="出租方公司", store=True, compute='_compute_lessee_id')
# company_id1 = fields.Many2one(related='contract_id.admin_id.company_id', string="管理员公司", store=True)
company_id2 = fields.Many2one("res.company", string="公司", compute='_compute_company_id2', store=True)
contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批")
@@ -662,6 +662,42 @@ class PropertyAccountsReceivable(models.Model):
}
}
+ def update_compute_lessee_id(self):
+ rent_ids = self.env["property.accounts.receivable"].browse(
+ self._context.get('active_ids', self._context.get('active_id')))
+ for rent in rent_ids:
+ rent._compute_lessee_id()
+
+ @api.depends('contract_id', 'due_date')
+ def _compute_lessee_id(self):
+ for record in self:
+ record.lessee_id = False
+ record.company_id = False
+ if not record.contract_id:
+ continue
+ lessee_lines = record.contract_id.lessee_line
+ valid_lessee_lines = lessee_lines.filtered(
+ lambda line:
+ line.start_date and
+ line.start_date <= record.due_date and #
+ (not line.end_date or line.end_date >= record.due_date)
+ )
+ if valid_lessee_lines and len(valid_lessee_lines) > 0:
+ record.lessee_id = valid_lessee_lines[0].lessee_id
+ else:
+ record.lessee_id = record.contract_id.lessee_id or False
+
+ lessor_lines = record.contract_id.lessor_line
+ valid_lessor_lines = lessor_lines.filtered(
+ lambda line:
+ line.start_date and
+ line.start_date <= record.due_date and
+ (not line.end_date or line.end_date >= record.due_date)
+ )
+ if valid_lessor_lines and len(valid_lessor_lines) > 0:
+ record.company_id = valid_lessor_lines[0].lessor_id
+ else:
+ record.company_id = record.contract_id.lessor_id
@api.depends('contract_id', 'due_date')
def compute_tenure_type(self):
@@ -1069,7 +1105,7 @@ class PropertyRentList(models.Model):
due_date_end = fields.Date.to_string(theoretical_end)
# 创建应收记录
- self.env['property.accounts.receivable'].create({
+ accounts_id = self.env['property.accounts.receivable'].create({
'contract_id': contract.id if contract else False,
'lessee_id': contract.lessee_id.id if contract and contract.lessee_id else None,
'original_amount': rec.original_amount,
@@ -1082,6 +1118,7 @@ class PropertyRentList(models.Model):
'management_type_id': management_type.id,
})
rec.is_push = True
+ accounts_id._compute_lessee_id()
self.reconcile_with_bank_statements(rec)
def batch_push_rent(self):
@@ -1136,7 +1173,7 @@ class PropertyDepositList(models.Model):
management_type_id = self.env['yuthon.management.type'].search([('name', '=', '押金')], limit=1)
if not management_type_id:
management_type_id = self.env['yuthon.management.type'].create({'name': '押金'})
- self.env['property.accounts.receivable'].create({
+ accounts_id = self.env['property.accounts.receivable'].create({
'contract_id': rec.contract_id.id,
'due_date' :rec.due_date + relativedelta(months=1),
'due_date_end': None,
@@ -1146,6 +1183,7 @@ class PropertyDepositList(models.Model):
'management_type_id':management_type_id.id,
'charging_range': f"{rec.due_date.strftime('%Y-%m-%d')} 到 {(rec.due_date + relativedelta(months=1)).strftime('%Y-%m-%d')}",
})
+ accounts_id._compute_lessee_id()
rec.is_push = True
def batch_push_deposit(self):
@@ -1230,7 +1268,7 @@ class PropertyManagementList(models.Model):
else:
due_date_end = fields.Date.to_string(theoretical_end)
- self.env['property.accounts.receivable'].create({
+ accounts_id = self.env['property.accounts.receivable'].create({
'contract_id': rec.contract_id.id,
'lessee_id': rec.contract_id.lessee_id.id if rec.contract_id.lessee_id else None,
'original_amount': rec.original_amount,
@@ -1240,6 +1278,7 @@ class PropertyManagementList(models.Model):
'create_time': datetime.now(),
'management_type_id': management_type_id.id,
})
+ accounts_id._compute_lessee_id()
rec.is_push = True
def batch_push_management(self):
diff --git a/yuthon_property_approval/views/inherit_yuthon_property_views.xml b/yuthon_property_approval/views/inherit_yuthon_property_views.xml
index 2e49b7629..6cbf4bb89 100644
--- a/yuthon_property_approval/views/inherit_yuthon_property_views.xml
+++ b/yuthon_property_approval/views/inherit_yuthon_property_views.xml
@@ -653,6 +653,13 @@
code
action = model.update_is_liquidated_damages()
+
+ 同步出租方和承租方
+
+
+ code
+ action = model.update_compute_lessee_id()
+
批量退回