From 420723d6eb9dc98ef5005368cb69453e0f6be7ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= <9664676+pengyuthon@user.noreply.gitee.com> Date: Thu, 11 Dec 2025 18:08:49 +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 --- .../models/property_accounts_receivable.py | 2 +- .../models/property_bills_list.py | 1 + .../models/property_lease_contract.py | 61 +++++++++---------- .../models/property_lease_renewal.py | 37 +++++------ .../security/ir.model.access.csv | 1 - .../views/property_bills_list_views.xml | 1 + .../views/property_lease_contract.xml | 54 ++++++++++------ .../wizard/penalty_line_wizard.py | 11 ++++ .../wizard/property_bills_wizard.py | 4 +- 9 files changed, 99 insertions(+), 73 deletions(-) diff --git a/yuthon_property/models/property_accounts_receivable.py b/yuthon_property/models/property_accounts_receivable.py index 7f74fd3a3..d8cf09e44 100644 --- a/yuthon_property/models/property_accounts_receivable.py +++ b/yuthon_property/models/property_accounts_receivable.py @@ -33,7 +33,7 @@ class PropertyAccountsReceivable(models.Model): print_date = fields.Date(string='打印日期') print_number = fields.Integer(string='打印次数') delivered1 = fields.Float(string='已交') - has_date = fields.Date(string='退押金日期') + has_date = fields.Date(string='退款日期') delivered = fields.Boolean() submitted = fields.Float(string='未收', compute='compute_submitted', store=True) is_invalid = fields.Boolean(string='作废') diff --git a/yuthon_property_approval/models/property_bills_list.py b/yuthon_property_approval/models/property_bills_list.py index 598347026..409cd735e 100644 --- a/yuthon_property_approval/models/property_bills_list.py +++ b/yuthon_property_approval/models/property_bills_list.py @@ -13,6 +13,7 @@ class PropertyBillsList(models.Model): contract_id = fields.Many2one('property.lease.contract', string="合同编号") lessee_id = fields.Many2one(related="contract_id.lessee_id", string="承租方", store=True) property_name = fields.Char(related='contract_id.property_name', string="物业信息") + remake = fields.Text(string="备注") def action_pay(self): return { diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py index b3008644b..c688d641c 100644 --- a/yuthon_property_approval/models/property_lease_contract.py +++ b/yuthon_property_approval/models/property_lease_contract.py @@ -204,7 +204,7 @@ class PropertyLeaseContract(models.Model): tax = fields.Float(string="税金") is_water = fields.Boolean(string="是否有水费") is_electricity = fields.Boolean(string="是否有电费") - is_manage = fields.Boolean(string="是否有管理费", compute='compute_is_manage') + is_manage = fields.Boolean(string="是否有管理费") miscellaneous = fields.Text(string="其他约定") number = fields.Integer(string="次数", default=0) total_area = fields.Float(string="总面积", digits=(16, 4)) @@ -231,11 +231,9 @@ class PropertyLeaseContract(models.Model): water_fee_ids = fields.One2many('property.water.fee.line', 'contract_id', string="物业水表明细行") electricity_fee_ids = fields.One2many('property.electric.fee.line', 'contract_id', string="物业电表明细行") - mange_fee_ids = fields.One2many('property.manage.fee.line', 'contract_id', string="物业管理费明细行", store=True) # 不需要 other_ids = fields.One2many('property.other.fee.line', 'other_id', string="其他费用明细行") lease_bank_ids = fields.One2many('property.bank.line', 'contract_id', string="承租方账户明细行") bank_statements_ids = fields.One2many('property.bank.statements', 'contract_id', string="银行流水明细行") - management_list_ids = fields.One2many('property.management.list', 'contract_id', string="管理费用明细行") contact_state = fields.Selection([('to', '待执行' ), ('ing', '执行中'), ('terminate', '中止'), ('complete', '完成'), ('early_termination', '提前终止'), ('settle', '结清')], string='合同管理状态', default='to') # 附件 license_ids = fields.Many2many('ir.attachment', @@ -617,8 +615,7 @@ class PropertyLeaseContract(models.Model): contract_ids = self.env["property.lease.contract"].browse( self._context.get('active_ids', self._context.get('active_id'))) for rec in contract_ids: - rec.compute_expiration_coming() - + rec.onchange_lease_ids() def update_admin_id(self): contract_ids = self.env["property.lease.contract"].browse( @@ -635,12 +632,18 @@ class PropertyLeaseContract(models.Model): @api.onchange("lease_ids") def onchange_lease_ids(self): for rec in self: + start = rec.term_start_time + end = rec.term_end_time + total_months = (end.year - start.year) * 12 + (end.month - start.month) + management_month_number = max(total_months, 0) # 初始化值 rec.is_water = False rec.is_electricity = False rec.water_fee_ids = [(5, 0, 0)] rec.electricity_fee_ids = [(5, 0, 0)] + rec.management_breakdown_ids = [(5, 0, 0)] water_fee_values = [] + message_fee_values = [] electricity_fee_values = [] if rec.lease_ids: # 处理每个租赁记录 @@ -672,21 +675,26 @@ class PropertyLeaseContract(models.Model): 'property_meter_archives_id': meter.property_meter_archives_id.id, }]) + if lease.address_id.is_message_fee and lease.address_id.message_standard_id: + message_fee_values.append([0, 0, { + 'breakdown_id': rec.id, + 'management_unit_price': lease.address_id.message_standard_id.amount, + 'management_monthly_amount': lease.address_id.message_standard_id.amount * lease.address_id.rent_area, + 'start_data': rec.term_start_time, + 'management_month_number': management_month_number + 1, + 'management_period_rent': management_month_number * lease.address_id.message_standard_id.amount * lease.address_id.rent_area, + 'end_data': rec.term_end_time, + }]) + + rec.is_manage = bool(message_fee_values) rec.is_water = bool(water_fee_values) rec.is_electricity = bool(electricity_fee_values) if water_fee_values: rec.water_fee_ids = water_fee_values if electricity_fee_values: rec.electricity_fee_ids = electricity_fee_values - - @api.depends('lease_ids') - def compute_is_manage(self): - for rec in self: - rec.is_manage = False - for lease in rec.lease_ids: - if lease.address_id.is_message_fee and lease.address_id.message_standard_id: - rec.is_manage = True - break + if message_fee_values: + rec.management_breakdown_ids = message_fee_values def all_end_approval(self): contract_ids = self.env["property.lease.contract"].browse( @@ -1629,14 +1637,13 @@ class PropertyLeaseContract(models.Model): rec.is_water = False rec.electricity_fee_ids = [(5, 0, 0)] - rec.mange_fee_ids = [(5, 0, 0)] rec.admin_id = rec.lease_ids[0].admin_line_id.id if rec.lease_ids else '' rec.tenure_type = rec.lease_ids[0].address_id.tenure_type if rec.lease_ids else '' rec.lessor_id = rec.lease_ids[0].address_id.company_id.id if rec.lease_ids else '' rec.precinct_id = rec.lease_ids[0].address_id.precinct_id.id if rec.lease_ids else '' rec.total_area = sum([lease.property_area for lease in rec.lease_ids]) rec.electricity_fee_ids = electricity_list - rec.mange_fee_ids = fee_list + def trigger_lease_ids(self): property_ids = self.env["property.lease.contract"].browse(self._context.get('active_ids', self._context.get('active_id'))) @@ -2065,11 +2072,11 @@ class PropertyLeaseContract(models.Model): for line in electric_lines: line.copy({'contract_id': new_contract.id}) # 复制物业管理费明细行 - manage_lines = self.env['property.manage.fee.line'].search([ - ('contract_id', '=', original_contract.id) - ]) + manage_lines = self.env['property.management.breakdown.line'].search([ + ('breakdown_id', '=', original_contract.id) + ]) for line in manage_lines: - line.copy({'contract_id': new_contract.id}) + line.copy({'breakdown_id': new_contract.id}) # 复制其他费用明细行 other_lines = self.env['property.other.fee.line'].search([ ('other_id', '=', original_contract.id) @@ -2133,11 +2140,11 @@ class PropertyLeaseContract(models.Model): for line in electric_lines: line.copy({'contract_id': new_contract.id}) # 复制物业管理费明细行 - manage_lines = self.env['property.manage.fee.line'].search([ - ('contract_id', '=', lease_contract_ids.id) + manage_lines = self.env['property.management.breakdown.line'].search([ + ('breakdown_id', '=', lease_contract_ids.id) ]) for line in manage_lines: - line.copy({'contract_id': new_contract.id}) + line.copy({'breakdown_id': new_contract.id}) # 复制其他费用明细行 other_lines = self.env['property.other.fee.line'].search([ ('other_id', '=', lease_contract_ids.id) @@ -2411,14 +2418,6 @@ class PropertyElectricFeeLine(models.Model): for line in rec.property_meter_archives_id.line_ids: line.line_loss = rec.line_loss -class PropertyManageFeeLine(models.Model): - _name = 'property.manage.fee.line' - _description = '物业管理费明细行' - - contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") - charges = fields.Char(string="收费项", default='管理费') - fees_id = fields.Many2one('property.message.fee', string="收费标准") - class PropertyOtherFeeLine(models.Model): _name = 'property.other.fee.line' diff --git a/yuthon_property_approval/models/property_lease_renewal.py b/yuthon_property_approval/models/property_lease_renewal.py index a3d19cce0..0146a3b78 100644 --- a/yuthon_property_approval/models/property_lease_renewal.py +++ b/yuthon_property_approval/models/property_lease_renewal.py @@ -57,7 +57,7 @@ class PropertyLeaseRenewal(models.Model): active = fields.Boolean('Active', default=True, tracking=True) work_end = fields.Boolean(string="结束") - deposit = fields.Float(string="押金") + deposit = fields.Float(string="原押金") is_full_refund = fields.Boolean(string="是否全额退押", default=True) refund_amount = fields.Float(string="退款金额") balance = fields.Float(string="余额") @@ -181,8 +181,8 @@ class PropertyLeaseRenewal(models.Model): ('due_date', '<=', rec.early_quitting_date), ('contract_id', '=', rec.contract_id.id), ]) - if any(not receivable.is_reconciliation for receivable in receivable_ids): - raise UserError("该合同下存在未对账的应收单,无法提前退押金") + # if any(not receivable.is_reconciliation for receivable in receivable_ids): + # raise UserError("该合同下存在未对账的应收单,无法提前退押金") rec.contract_id.write({ 'actual_end_time': rec.early_quitting_date @@ -199,21 +199,22 @@ class PropertyLeaseRenewal(models.Model): 'management_type_id': refund_line.management_type_id.id, 'amount': refund_line.refund_amount, 'contract_id': rec.contract_id.id, + 'remake': rec.remake }) - - if rec.is_full_refund: - deposit_management_type = self.env['yuthon.management.type'].search( - [('name', '=', '押金')], - limit=1 - ) - deposit_amount = rec.deposit if rec.is_full_refund else rec.refund_amount - if deposit_amount > 0: - bills_line_list.append({ - 'due_date': fields.Date.today(), - 'management_type_id': deposit_management_type.id, - 'amount': deposit_amount, - 'contract_id': rec.contract_id.id, - }) + # 押金 + deposit_management_type = self.env['yuthon.management.type'].search( + [('name', '=', '押金')], + limit=1 + ) + deposit_amount = rec.deposit if rec.is_full_refund else rec.refund_amount + if deposit_amount > 0: + bills_line_list.append({ + 'due_date': fields.Date.today(), + 'management_type_id': deposit_management_type.id, + 'amount': deposit_amount, + 'contract_id': rec.contract_id.id, + 'remake': rec.remake + }) if not rec.is_full_refund: start_time = datetime.combine(rec.early_quitting_date, datetime.min.time().replace(hour=8, minute=00)) @@ -221,7 +222,7 @@ class PropertyLeaseRenewal(models.Model): 'start_time': start_time, 'original_amount': rec.balance, 'name_account': rec.lessee_id.name, - 'remake': f'合同为{rec.contract_id.contract_code}{rec.remake}', + 'remake': rec.remake, }) # 创建应付账单 diff --git a/yuthon_property_approval/security/ir.model.access.csv b/yuthon_property_approval/security/ir.model.access.csv index 42ded9296..654d19221 100644 --- a/yuthon_property_approval/security/ir.model.access.csv +++ b/yuthon_property_approval/security/ir.model.access.csv @@ -27,7 +27,6 @@ access_property_lease_contract_line,property_lease_contract_line,model_property_ access_property_rent_breakdown_line,property_rent_breakdown_line,model_property_rent_breakdown_line,base.group_user,1,1,1,1 access_property_water_fee_line,property_water_fee_line,model_property_water_fee_line,base.group_user,1,1,1,1 access_property_electric_fee_line,property_electric_fee_line,model_property_electric_fee_line,base.group_user,1,1,1,1 -access_property_manage_fee_line,property_manage_fee_line,model_property_manage_fee_line,base.group_user,1,1,1,1 access_property_other_fee_line,property_other_fee_line,model_property_other_fee_line,base.group_user,1,1,1,1 access_property_renamed,property_renamed,model_property_renamed,base.group_user,1,1,1,1 access_property_lessee_change,property_lessee_change,model_property_lessee_change,base.group_user,1,1,1,1 diff --git a/yuthon_property_approval/views/property_bills_list_views.xml b/yuthon_property_approval/views/property_bills_list_views.xml index 50aa5869a..db98b6a62 100644 --- a/yuthon_property_approval/views/property_bills_list_views.xml +++ b/yuthon_property_approval/views/property_bills_list_views.xml @@ -13,6 +13,7 @@ +