From c8645364cc897a2504482fd2d66af59f33fe1da4 Mon Sep 17 00:00:00 2001
From: zhou <123@>
Date: Mon, 19 May 2025 21:59:55 +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
---
soong_workflow/models/soong_workflow_log.py | 10 ++++++
soong_workflow/models/soong_workflow_mixin.py | 25 ++++++++++++++-
.../models/soong_workflow_record.py | 18 +++++------
soong_workflow/security/ir.model.access.csv | 3 +-
.../templates/soong_workflow_templates.xml | 31 +++++++++++++++++--
.../models/property_accounts_receivable.py | 3 ++
.../property_accounts_receivable_views.xml | 3 +-
.../data/property_contract_time.xml | 13 ++++++++
.../models/inherit_yuthon_property.py | 22 +++++++++++--
9 files changed, 111 insertions(+), 17 deletions(-)
diff --git a/soong_workflow/models/soong_workflow_log.py b/soong_workflow/models/soong_workflow_log.py
index ff00056c3..2f20a827f 100644
--- a/soong_workflow/models/soong_workflow_log.py
+++ b/soong_workflow/models/soong_workflow_log.py
@@ -26,6 +26,7 @@ class SoongWorkflowLog(models.Model):
approval_state = fields.Selection([('0', '待办'), ('1', '办理中'), ('2', '已办结'), ('3', '结束')], string='状态', default='0')
comment = fields.Char(string="意见")
date_create = fields.Datetime(string="时间", default=lambda self: fields.Datetime.now())
+ document_ids = fields.Many2many('ir.attachment', string="附件")
active = fields.Boolean(string="归档", default=True)
@api.depends("workflow_id", "node_id", "node_btn_id")
@@ -47,6 +48,13 @@ class SoongWorkflowLog(models.Model):
logs_obj = self.sudo().search([("res_id", "=", record.res_id), ("model", "=", record.model), ("workflow_id", "=", record.workflow_id.id), ("date_create", "<", record.date_create)])
record.sequence = len(logs_obj) + 1
+ def open_record(self):
+ return {
+ "type": "ir.actions.act_window",
+ "res_model": 'soong.workflow.record',
+ "view_mode": "tree",
+ }
+
class SoongWorkflowLog2(models.Model):
_name = "soong.workflow.log2"
@@ -62,8 +70,10 @@ class SoongWorkflowLog2(models.Model):
done_by = fields.Many2one(comodel_name="res.users", string="审批人")
name = fields.Char(string="节点名称", compute="_compute_name", store=True)
approval_state = fields.Selection([('0', '未读'), ('1', '已读')], string='状态', default='0')
+ document_ids = fields.Many2many('ir.attachment', string="附件")
lase_click_date = fields.Datetime(string="操作时间")
+
@api.depends("workflow_id", "node_id", "node_btn_id")
def _compute_name(self):
for rec in self:
diff --git a/soong_workflow/models/soong_workflow_mixin.py b/soong_workflow/models/soong_workflow_mixin.py
index 58d250d28..fe07766fa 100644
--- a/soong_workflow/models/soong_workflow_mixin.py
+++ b/soong_workflow/models/soong_workflow_mixin.py
@@ -80,7 +80,6 @@ class SoongWorkflowMixin(models.AbstractModel):
string="Workflow Ref.",
compute="_compute_workflow_id",
)
-
approval_users_ids = fields.One2many("soong.approval.users", "res_id",
domain=lambda self: [('res_model', '=', self._name)], auto_join=True,
string="审批明细")
@@ -123,6 +122,7 @@ class SoongWorkflowMixin(models.AbstractModel):
domain=lambda self: [("model", "=", self._name)], auto_join=True)
log_ids2 = fields.One2many(comodel_name="soong.workflow.log2", inverse_name="res_id", string=" ",
domain=lambda self: [("model", "=", self._name)], auto_join=True)
+ soong_record_ids = fields.One2many(comodel_name="soong.workflow.line", inverse_name="res_id", string=" ",)
@api.model_create_multi
def create(self, vals_list):
@@ -965,3 +965,26 @@ class SoongWorkflowMixin(models.AbstractModel):
if not isinstance(msg, str):
msg = str(msg)
_logger.info(msg)
+
+class SoongWorkflowLine(models.Model):
+ _name = "soong.workflow.line"
+
+
+ model = fields.Char(string="Related Document Model", index=True)
+ res_id = fields.Integer(string="Related Document ID", index=True)
+ workflow_record_id = fields.Many2one("soong.workflow.record", string="名称")
+ code = fields.Char(related="workflow_record_id.code", string="流水号")
+ approvals_group_id = fields.Many2one(related="workflow_record_id.approvals_group_id", string="审批组")
+ create_uid = fields.Many2one(related="workflow_record_id.create_uid", string="创建人")
+ write_date2 = fields.Datetime(related="workflow_record_id.write_date2", string="最后更新日期")
+
+ def open_record(self):
+ return {
+ "type": "ir.actions.act_window",
+ "res_model": self.workflow_record_id.res_model,
+ "res_id": self.workflow_record_id.res_id,
+ "name": self.workflow_record_id.name,
+ "view_mode": "form",
+ }
+
+
diff --git a/soong_workflow/models/soong_workflow_record.py b/soong_workflow/models/soong_workflow_record.py
index 70ea05046..d17e09e69 100644
--- a/soong_workflow/models/soong_workflow_record.py
+++ b/soong_workflow/models/soong_workflow_record.py
@@ -75,6 +75,15 @@ class SoongWorkflowRecord(models.Model):
return [('id', operator, user_employee.id)]
return (['!'] if operator == '!=' else []) + [('department_id', '=', user_employee.department_id.id)]
+ def open_record(self):
+ return {
+ "type": "ir.actions.act_window",
+ "res_model": self.res_model,
+ "res_id": self.res_id,
+ "name": self.name,
+ "view_mode": "form",
+ }
+
# def get_department_employees(self, department_id):
# valid_user_ids = set()
# employee_ids = self.sudo().env['hr.employee'].search([('department_id', '=', department_id.id)])
@@ -186,12 +195,3 @@ class SoongWorkflowRecord(models.Model):
for record in self:
record.active = False
- def open_record(self):
- return {
- "type": "ir.actions.act_window",
- "res_model": self.res_model,
- "res_id": self.res_id,
- "name": self.name,
- "view_mode": "form",
- }
-
diff --git a/soong_workflow/security/ir.model.access.csv b/soong_workflow/security/ir.model.access.csv
index b34e83b99..3a686cb45 100644
--- a/soong_workflow/security/ir.model.access.csv
+++ b/soong_workflow/security/ir.model.access.csv
@@ -39,4 +39,5 @@ access_soong_workflow_apostille_wizard_user,soong_workflow_apostille_wizard,mode
access_soong_workflow_apostille_ok_wizard_user,soong_workflow_apostille_ok_wizard,model_soong_workflow_apostille_ok_wizard,soong_workflow.group_soong_workflow_user,1,1,1,1
access_soong_workflow_record_delete_wizard,soong_workflow_record_delete_wizard,model_soong_workflow_record_delete_wizard,soong_workflow.group_soong_workflow_user,1,1,1,1
access_role_group_wizard,role_group_wizard,model_role_group_wizard,soong_workflow.group_soong_workflow_user,1,1,1,1
-access_soong_workflow_record_revoke_wizard,soong_workflow_record_revoke_wizard,model_soong_workflow_record_revoke_wizard,soong_workflow.group_soong_workflow_user,1,1,1,1
\ No newline at end of file
+access_soong_workflow_record_revoke_wizard,soong_workflow_record_revoke_wizard,model_soong_workflow_record_revoke_wizard,soong_workflow.group_soong_workflow_user,1,1,1,1
+access_soong_workflow_line,soong_workflow_line,model_soong_workflow_line,soong_workflow.group_soong_workflow_user,1,1,1,1
\ No newline at end of file
diff --git a/soong_workflow/templates/soong_workflow_templates.xml b/soong_workflow/templates/soong_workflow_templates.xml
index 0b8bac7c8..9bd6b4a3e 100644
--- a/soong_workflow/templates/soong_workflow_templates.xml
+++ b/soong_workflow/templates/soong_workflow_templates.xml
@@ -5,13 +5,14 @@
-
+
+
@@ -25,6 +26,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
@@ -32,19 +45,20 @@
-
+
+
-
+
@@ -52,6 +66,17 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/yuthon_property/models/property_accounts_receivable.py b/yuthon_property/models/property_accounts_receivable.py
index 526a311ed..f7af4fd7a 100644
--- a/yuthon_property/models/property_accounts_receivable.py
+++ b/yuthon_property/models/property_accounts_receivable.py
@@ -33,12 +33,15 @@ class PropertyAccountsReceivable(models.Model):
is_billing = fields.Boolean(string='开票')
is_reconciliation = fields.Boolean(string='对账')
difference_amount = fields.Float(string='差额')
+ is_submitted = fields.Boolean(string='未交')
is_invalid = fields.Boolean(string='作废')
is_red = fields.Boolean(string='红冲')
is_push = fields.Boolean(string='已推送')
management_type_id = fields.Many2one('yuthon.management.type', string='应收类型')
last_update_time = fields.Datetime(string='最后修改时间')
+
+
def unlink(self):
return super().unlink()
diff --git a/yuthon_property/views/property_accounts_receivable_views.xml b/yuthon_property/views/property_accounts_receivable_views.xml
index 106e126cc..482e4e421 100644
--- a/yuthon_property/views/property_accounts_receivable_views.xml
+++ b/yuthon_property/views/property_accounts_receivable_views.xml
@@ -12,6 +12,7 @@
+
@@ -21,7 +22,7 @@
-
+
diff --git a/yuthon_property_approval/data/property_contract_time.xml b/yuthon_property_approval/data/property_contract_time.xml
index 18c540f06..2014a1029 100644
--- a/yuthon_property_approval/data/property_contract_time.xml
+++ b/yuthon_property_approval/data/property_contract_time.xml
@@ -28,4 +28,17 @@
-1
+
+ 定时任务:更新合同违约金
+
+ code
+ model.contract_penalty()
+
+
+ 1
+ months
+
+ -1
+
+
\ No newline at end of file
diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py
index 70eed8191..c5932055b 100644
--- a/yuthon_property_approval/models/inherit_yuthon_property.py
+++ b/yuthon_property_approval/models/inherit_yuthon_property.py
@@ -34,12 +34,23 @@ class PropertyBankStatements(models.Model):
def button_manage(self):
pass
+ def contract_penalty(self):
+ statements_ids = self.env['property.bank.statements'].search([])
+ for record in statements_ids:
+ self._handle_contract_penalty(record)
+
+
def _handle_contract_penalty(self, record):
+ '''
+ 处理合同违约金
+ :param record: property.bank.statements 记录
+ :return:
+ '''
for contract_id in record.contract_ids:
receivable_id = self.env['property.accounts.receivable'].search([('contract_id', '=', contract_id.id)])
if receivable_id:
- dt = datetime.strptime(str(record.start_time), '%Y-%m-%d %H:%M:%S').date()
- due = datetime.strptime(str(receivable_id.due_date), '%Y-%m-%d').date()
+ dt = datetime.strptime(str(record.start_time), '%Y-%m-%d %H:%M:%S').date() # 对账日期
+ due = datetime.strptime(str(receivable_id.due_date), '%Y-%m-%d').date() # 应收日期
# 判断是否违约
if receivable_id.due_date > record.start_time and not receivable_id.is_reconciliation:
original_amount = (due - dt).days * (receivable_id.original_amount - record.original_amount) * 0.001
@@ -226,6 +237,13 @@ class PropertyAccountsReceivable(models.Model):
penalty = fields.Float(string="违约金")
penalty_date = fields.Date(string="违约金日期")
+ @api.model
+ def write(self, vals):
+ # 当修改 penalty_date 时,自动将 is_reconciliation 设置为 True
+ if 'penalty_date' in vals:
+ vals['is_reconciliation'] = True
+ return super(PropertyAccountsReceivable, self).write(vals)
+
@api.onchange('penalty_date')
def _onchange_penalty_date(self):
for record in self: