diff --git a/sh_backmate_theme_adv_enterprise/controllers/home.py b/sh_backmate_theme_adv_enterprise/controllers/home.py index da7eb2554..1b8dc7679 100644 --- a/sh_backmate_theme_adv_enterprise/controllers/home.py +++ b/sh_backmate_theme_adv_enterprise/controllers/home.py @@ -19,6 +19,8 @@ MENU_BADGE_MODEL_FUNC_ENUM = { 'yuthon_notice.yuthon_notice_my_menu': {'model': 'yuthon.notice', 'func': 'get_no_read_count'}, 'soong_workflow.menu_workflow_approval_request_my': {'model': 'soong.workflow.record', 'func': 'get_no_read_count'}, 'yuthon_will_task.menu_yuthon_will_task_root': {'model': 'yuthon.will.task', 'func': 'read_number'}, + 'yuthon_property_approval.property_lease_contract_coming_menu': {'model': 'property.lease.contract', 'func': 'read_coming_count'}, + 'yuthon_property_approval.property_lease_contract_coming_due_menu': {'model': 'property.lease.contract', 'func': 'read_due_count'}, } diff --git a/yuthon_property_approval/models/property_early_quitting.py b/yuthon_property_approval/models/property_early_quitting.py index c6bca8af3..f8d23b32f 100644 --- a/yuthon_property_approval/models/property_early_quitting.py +++ b/yuthon_property_approval/models/property_early_quitting.py @@ -19,5 +19,11 @@ class PropertyEarlyQuitting(models.Model): start_data = fields.Date(string="合同开始日期") end_data = fields.Date(string="合同结束日期") early_quitting_date = fields.Date(string="提前退租日期") - contract_id = fields.Many2one('ir.attachment', string="合同") - reason = fields.Char(string="退租原因") \ No newline at end of file + original_contract_id = fields.Many2one('ir.attachment', string="合同") + contract_id = fields.Many2one('yuthon.property.contract', string="合同") + reason = fields.Char(string="退租原因") + + def button_approval(self): + for rec in self: + rec.contract_id.write({ + 'actual_end_time': rec.new_end_date}) diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py index f649fc6d1..f0aabd9da 100644 --- a/yuthon_property_approval/models/property_lease_contract.py +++ b/yuthon_property_approval/models/property_lease_contract.py @@ -185,10 +185,12 @@ class PropertyLeaseContract(models.Model): if record.term_end_time and record.actual_end_time: if record.actual_end_time < record.term_end_time: delta = record.term_end_time - record.actual_end_time - if 0< delta.days < 90: + if 30< delta.days < 90: record.expiration_coming = 'coming' - elif record.actual_end_time == record.term_end_time: - record.expiration_coming = 'due' + elif delta.days <=30: + record.expiration_coming = 'due' + else: + record.expiration_coming = None else: record.expiration_coming = None else: @@ -1081,18 +1083,19 @@ class PropertyLeaseContract(models.Model): record.write({'condition': 'executed'}) elif current_date < record.term_start_time: record.write({'condition': 'be_executed'}) - # 延租 + # 续租 def button_lease_extension(self): form_id = self.env.ref('yuthon_property_approval.view_property_lease_extension_form').id address_id = self.lease_ids[0].address_id if self.lease_ids else '' return { - 'name': '延租申请', + 'name': '续租申请', "type": "ir.actions.act_window", 'res_model': 'property.lease.extension', "views": [[form_id, "form"]], "context": { 'default_address_id': address_id.id, - 'default_end_date': self.term_end_time + 'default_end_date': self.term_end_time, + 'default_contract_id': self.id }, } @@ -1110,6 +1113,7 @@ class PropertyLeaseContract(models.Model): 'default_address_id': address_id.id, 'default_end_data': self.term_end_time, 'default_start_data': self.term_start_time, + 'default_contract_id': self.id, }, } @@ -1124,6 +1128,11 @@ class PropertyLeaseContract(models.Model): "views": [[form_id, "form"]], } + def read_coming_count(self): + return self.search_count([('expiration_coming', '=', 'coming'), ('admin_id', '=', self.env.user.id)]) + + def read_due_count(self): + return self.search_count([('expiration_coming', '=', 'due'), ('admin_id', '=', self.env.user.id)]) class PropertyLeaseContractLine(models.Model): _name = 'property.lease.contract.line' diff --git a/yuthon_property_approval/models/property_lease_extension.py b/yuthon_property_approval/models/property_lease_extension.py index 526c73866..c4817e4c7 100644 --- a/yuthon_property_approval/models/property_lease_extension.py +++ b/yuthon_property_approval/models/property_lease_extension.py @@ -6,7 +6,7 @@ from odoo import models, fields, api, exceptions, _ class PropertyLeaseExtension(models.Model): _name = 'property.lease.extension' - _description = '延租申请' + _description = '续租申请' _inherit = ['mail.thread.main.attachment', 'mail.activity.mixin', 'soong.workflow.mixin'] _rec_name = 'name' @@ -17,6 +17,12 @@ class PropertyLeaseExtension(models.Model): original_contract_id = fields.Many2one('ir.attachment', string="原合同") lessee_id = fields.Many2one(related='address_id.lessee_id', string="承租方") address_id = fields.Many2one('yuthon.property', string="物业地址") + contract_id = fields.Many2one('yuthon.property.contract', string="合同") end_date = fields.Date(string="原到期时间") new_end_date = fields.Date(string="延期至") reason_extension = fields.Char(string="延期原因") + + def button_approval(self): + for rec in self: + rec.contract_id.write({ + 'actual_end_time': rec.new_end_date}) diff --git a/yuthon_property_approval/views/property_early_quitting.xml b/yuthon_property_approval/views/property_early_quitting.xml index 0ca44b8a2..0383b475d 100644 --- a/yuthon_property_approval/views/property_early_quitting.xml +++ b/yuthon_property_approval/views/property_early_quitting.xml @@ -33,6 +33,7 @@ + diff --git a/yuthon_property_approval/views/property_lease_extension.xml b/yuthon_property_approval/views/property_lease_extension.xml index 677fe5f48..aeccf56db 100644 --- a/yuthon_property_approval/views/property_lease_extension.xml +++ b/yuthon_property_approval/views/property_lease_extension.xml @@ -32,6 +32,7 @@ +