diff --git a/yuthon_property_approval/__manifest__.py b/yuthon_property_approval/__manifest__.py index 90c34510e..b112eb7e1 100644 --- a/yuthon_property_approval/__manifest__.py +++ b/yuthon_property_approval/__manifest__.py @@ -9,6 +9,7 @@ 'license': 'LGPL-3', 'data': [ 'data/sale_renting_code_data.xml', + 'data/property_contract_time.xml', 'security/ir.model.access.csv', 'views/property_billing_confirmation.xml', 'views/property_approval_views.xml', diff --git a/yuthon_property_approval/data/property_contract_time.xml b/yuthon_property_approval/data/property_contract_time.xml new file mode 100644 index 000000000..678bc6586 --- /dev/null +++ b/yuthon_property_approval/data/property_contract_time.xml @@ -0,0 +1,18 @@ + + + + + 定时任务:更新物业合同状态 + + code + model.get_property_contract_time() + + + 1 + days + + -1 + + + + \ No newline at end of file diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py index 310d01e86..840803851 100644 --- a/yuthon_property_approval/models/property_lease_contract.py +++ b/yuthon_property_approval/models/property_lease_contract.py @@ -1083,6 +1083,16 @@ class PropertyLeaseContract(models.Model): if record.lease_ids: record.admin_id = record.lease_ids[0].admin_id.id + def get_property_contract_time(self): + for record in self.search([]): + if record.term_start_time: + current_date = date.today() + if record.condition != 'cancel': + if current_date >= record.term_start_time: + record.write({'message_type': 'executed'}) + elif current_date < record.term_start_time: + record.write({'message_type': 'be_executed'}) + class PropertyLeaseContractLine(models.Model): _name = 'property.lease.contract.line' _description = '物业列表明细行'