diff --git a/soong_workflow/models/soong_workflow_record.py b/soong_workflow/models/soong_workflow_record.py
index 776cfca8a..817574ae2 100644
--- a/soong_workflow/models/soong_workflow_record.py
+++ b/soong_workflow/models/soong_workflow_record.py
@@ -512,13 +512,16 @@ class SoongWorkflowRecord(models.Model):
)
current_datetime = fields.Datetime.now()
for workflow in workflow_ids:
- record_id = self.env[workflow.res_model].search([('id', '=', workflow.res_id)])
+ record_id = self.env[workflow.res_model].browse(workflow.res_id)
+ user_id = False
if hasattr(record_id, 'user_id') and record_id.user_id:
user_id = record_id.user_id
elif hasattr(record_id, 'users_id') and record_id.users_id:
user_id = record_id.users_id
+
if not record_id:
continue
+
# 触发模型对应的结束方法
record_id.work_end = True
end_node = self.env["soong.workflow.node"].search(
@@ -526,8 +529,7 @@ class SoongWorkflowRecord(models.Model):
limit=1
)
end_btn = self.env["soong.workflow.node.button"].search(
- [('node_id', '=', end_node.id),
- ('name', '=', '结束')],
+ [('node_id', '=', end_node.id), ('name', '=', '结束')],
limit=1
)
if end_btn:
@@ -536,21 +538,17 @@ class SoongWorkflowRecord(models.Model):
[('workflow_id', '=', workflow.workflow_id.id),
('name', '=', record_id.state)],
limit=1
- )
- # 修改日志
- log_records = None
- if record_id.log_ids:
- log_records = record_id.log_ids
-
+ )
+ log_records = record_id.log_ids if hasattr(record_id, 'log_ids') else None
log_model = "soong.workflow.log"
if log_records:
- log_records[-1].write({
- 'approval_state': '3',
- 'lase_click_date': current_datetime,
- })
+ log_records.write({'approval_state': '3'})
+ if len(log_records) > 0:
+ last_log = log_records[-1]
+ last_log.write({'lase_click_date': current_datetime})
else:
self.env[log_model].create({
- 'done_by': user_id.id,
+ 'done_by': user_id.id if user_id else False,
'node_id': node_id.id if node_id else False,
'workflow_id': workflow.workflow_id.id,
'model': workflow.res_model,
@@ -559,6 +557,7 @@ class SoongWorkflowRecord(models.Model):
'lase_click_date': current_datetime,
'sequence': 99,
})
+
workflow.approve_state = 'end'
workflow.soong_state = 'done'
workflow.employee_ids = [(6, 0, [])]
diff --git a/yuthon_property_approval/models/property_lease_renewal.py b/yuthon_property_approval/models/property_lease_renewal.py
index bdbd93066..1879c752a 100644
--- a/yuthon_property_approval/models/property_lease_renewal.py
+++ b/yuthon_property_approval/models/property_lease_renewal.py
@@ -64,7 +64,7 @@ class PropertyLeaseRenewal(models.Model):
refund_remake = fields.Char(string="备注")
total_receivables = fields.Float(string="应收金额", compute="_compute_total_receivables")
total_remake = fields.Char(string="备注")
- balance = fields.Float(string="余额")
+ balance = fields.Float(string="金额")
balance_remake = fields.Char(string="备注")
receivables_ids = fields.One2many('early.receivables.line', 'renewal_id', string='应收明细')
@@ -87,11 +87,6 @@ class PropertyLeaseRenewal(models.Model):
report = self.env.ref('yuthon_property_approval.action_property_lease_renewal_report')
return report.report_action(self)
- @api.onchange('refund_amount')
- def _onchange_refund_amount(self):
- for rec in self:
- rec.balance = rec.deposit - rec.refund_amount
-
def end_approval(self):
for rec in self:
if rec.renewal_type == 'extend':
@@ -181,17 +176,25 @@ class PropertyLeaseRenewal(models.Model):
rec.contract_id.write({
'actual_end_time': rec.early_quitting_date
})
- if rec.balance > rec.total_receivables:
+ penalty_amount = rec.balance - rec.total_receivables
+ if rec.balance > rec.total_receivables and penalty_amount > 0:
management_type_id = self.env['yuthon.management.type'].search([
('name', '=', '违约金')
- ])
- self.env['property.accounts.receivable'].create({
- 'contract_id': rec.contract_id.id,
- 'management_type_id': management_type_id.id,
- 'due_date': rec.early_quitting_date,
- 'original_amount': rec.balance - rec.total_receivables,
- 'remark': rec.total_remake,
- })
+ ], limit=1)
+ exist_receivable = self.env['property.accounts.receivable'].search([
+ ('contract_id', '=', rec.contract_id.id),
+ ('management_type_id', '=', management_type_id.id),
+ ('due_date', '=', rec.early_quitting_date),
+ ('original_amount', '=', penalty_amount),
+ ], limit=1)
+ if not exist_receivable:
+ self.env['property.accounts.receivable'].create({
+ 'contract_id': rec.contract_id.id,
+ 'management_type_id': management_type_id.id,
+ 'due_date': rec.early_quitting_date,
+ 'original_amount': penalty_amount,
+ 'remark': rec.total_remake,
+ })
if rec.receivables_ids:
refund_lines = rec.receivables_ids.filtered(lambda l: l.refund_amount > 0 and l.management_type_id.name != '押金')
bills_line_list = []
@@ -287,6 +290,7 @@ class PropertyLeaseRenewal(models.Model):
}])
self.receivables_ids = receivable_list
+
@api.onchange('contract_id', 'renewal_type')
def _onchange_name(self):
if self.contract_id and self.renewal_type:
@@ -310,8 +314,13 @@ class EarlyReceivablesLine(models.Model):
management_type_id = fields.Many2one(related='receivable_id.management_type_id', string='类型')
is_reconciliation = fields.Boolean(related='receivable_id.is_reconciliation', string='对账')
due_date = fields.Date(related='receivable_id.due_date', string='应收日期')
- original_amount = fields.Float(related='receivable_id.original_amount', string='金额')
+ original_amount = fields.Float(string='金额', compute='_compute_original_amount')
reduction_amount = fields.Float(string='减免金额')
refund_amount = fields.Float(string='退款金额')
void = fields.Boolean(string='作废', default=False)
+ @api.depends('receivable_id')
+ def _compute_original_amount(self):
+ for line in self:
+ line.original_amount = line.receivable_id.original_amount - line.receivable_id.discount_amount
+
diff --git a/yuthon_property_approval/views/property_lease_renewal.xml b/yuthon_property_approval/views/property_lease_renewal.xml
index 2c33eaf23..cfb0477e6 100644
--- a/yuthon_property_approval/views/property_lease_renewal.xml
+++ b/yuthon_property_approval/views/property_lease_renewal.xml
@@ -109,16 +109,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -128,6 +118,16 @@
+
+
+
+
+
+
+
+
+
+