From e870c427715246dc299800b6c306d84d025298b5 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: Mon, 27 Oct 2025 18:52:26 +0800 Subject: [PATCH 1/2] =?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_management_list.py | 13 ++- .../views/property_management_list_views.xml | 2 +- .../models/inherit_yuthon_property.py | 6 ++ .../views/inherit_yuthon_property_views.xml | 5 +- .../wizard/property_rental_wizard.py | 93 +++++++++---------- 5 files changed, 66 insertions(+), 53 deletions(-) diff --git a/yuthon_property/models/property_management_list.py b/yuthon_property/models/property_management_list.py index 3692bc2a8..796862305 100644 --- a/yuthon_property/models/property_management_list.py +++ b/yuthon_property/models/property_management_list.py @@ -6,8 +6,8 @@ class PropertyManagementList(models.Model): _description = '物业费管理列表' contract_code = fields.Char(string='合同编号') - property_id = fields.Many2one('yuthon.property', string='物业') - admin_id = fields.Many2one(related='property_id.admin_id', string="片区管理员", store=True) + property_ids = fields.Many2many('yuthon.property', string='物业') + admin_id = fields.Many2one('res.users', string="片区管理员", store=True, compute="_compute_admin_id") lessee_id = fields.Many2one('property.tenant.information', string='承租方') due_date = fields.Date(string='应收日期') message_standard_id = fields.Many2one('property.message.fee', string="管理费标准") @@ -17,6 +17,15 @@ class PropertyManagementList(models.Model): remarks = fields.Text(string='备注') is_push = fields.Boolean(string='是否推送') + @api.depends('property_ids') + def _compute_admin_id(self): + for record in self: + record.admin_id = record.property_ids[0].admin_id + + def push_management(self): + rec = self.env['property.management.list'].search([('is_push', '=', False)]) + rec.is_push = True + def get_no_read_count(self): return self.search_count([('is_push', '=', False)]) diff --git a/yuthon_property/views/property_management_list_views.xml b/yuthon_property/views/property_management_list_views.xml index f6a844538..f5323ded3 100644 --- a/yuthon_property/views/property_management_list_views.xml +++ b/yuthon_property/views/property_management_list_views.xml @@ -5,7 +5,7 @@ property.management.list - + diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py index c9f106b84..c894263ac 100644 --- a/yuthon_property_approval/models/inherit_yuthon_property.py +++ b/yuthon_property_approval/models/inherit_yuthon_property.py @@ -1081,9 +1081,15 @@ class PropertyManagementList(models.Model): _inherit = 'property.management.list' contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") + property_name = fields.Text(string='物业', compute="_compute_property_name") company_id = fields.Many2one(related='contract_id.lessor_id', string="出租方公司", store=True) tenure_type = fields.Selection(related='contract_id.tenure_type', string="权属类型", store=True) + @api.depends('contract_id') + def _compute_property_name(self): + for record in self: + record.property_name = record.contract_id.property_name + def push_management(self): for rec in self: management_type_id = self.env['yuthon.management.type'].search([('name', '=', '管理费')], limit=1) diff --git a/yuthon_property_approval/views/inherit_yuthon_property_views.xml b/yuthon_property_approval/views/inherit_yuthon_property_views.xml index b9a97b6c0..7bdc54b4c 100644 --- a/yuthon_property_approval/views/inherit_yuthon_property_views.xml +++ b/yuthon_property_approval/views/inherit_yuthon_property_views.xml @@ -346,6 +346,7 @@ + @@ -355,7 +356,7 @@ property.management.list - + @@ -365,7 +366,7 @@ - + diff --git a/yuthon_property_approval/wizard/property_rental_wizard.py b/yuthon_property_approval/wizard/property_rental_wizard.py index dea4913fb..3661d560f 100644 --- a/yuthon_property_approval/wizard/property_rental_wizard.py +++ b/yuthon_property_approval/wizard/property_rental_wizard.py @@ -107,57 +107,54 @@ class PropertyRentalWizard(models.Model): """封装创建管理费记录的逻辑""" first_day_of_month = start_date.replace(day=1) last_day_of_month = first_day_of_month + relativedelta(months=1) - timedelta(days=1) + management_id = self.env['property.management.list'].search([ + ('contract_id', '=', record.id), + ('due_date', '>=', first_day_of_month), + ('due_date', '<=', last_day_of_month) + ]) + total_original_amount = 0 + if record.contract_sort not in ['guanggao', 'guanzi', 'room']: + for lease_id in record.lease_ids: + standard_amount = lease_id.message_standard_id.amount or 0.0 + property_area = lease_id.property_area or 0.0 + total_original_amount += int(round(property_area * standard_amount)) + else: + total_original_amount = rent_amount + + has_valid_property = False for lease_id in record.lease_ids: property_id = lease_id.address_id - management_id = self.env['property.management.list'].search([ - ('contract_id', '=', record.id), - ('due_date', '>=', first_day_of_month), - ('due_date', '<=', last_day_of_month) - ]) - matched_info = self.env['manage.information.line'] - if record.contract_sort in ['guanggao','guanzi', 'room']: - original_amount = rent_amount + if property_id and property_id.message_standard_id: + has_valid_property = True + break + + is_special_contract = record.contract_sort in ['guanggao', 'guanzi', 'room'] + if (not is_special_contract and has_valid_property) or is_special_contract: + area_value = sum( + lease_id.property_area or 0.0 + for lease_id in record.lease_ids + if record.lease_ids + ) + if not management_id: + self.sudo().env["property.management.list"].create({ + "contract_id": record.id, + "area":area_value, + 'property_ids': [(6, 0, [lease_id.address_id.id for lease_id in record.lease_ids if lease_id.address_id])], + 'original_amount':total_original_amount, + 'message_standard_id': record.lease_ids[0].message_standard_id.id, + 'lessee_id': record.lessee_id.id, + "due_date":start_date + }) else: - original_amount = 0 - standard_id = property_id.message_standard_id - target_month_first_day = start_date.replace(day=1) - target_month_last_day = target_month_first_day + relativedelta(months=1) - relativedelta( - days=1) - matched_info = self.env['manage.information.line'].search([ - ('yuthon_property_id', '=', property_id.id), - ('start_time', '<=', target_month_last_day), - '|', - ('end_date', '>=', target_month_first_day), - ('end_date', '=', False) - ], limit=1) - - if matched_info: - original_amount = int(round(matched_info.management_area * standard_id.amount)) - - is_special_contract = record.contract_sort in ['guanggao', 'guanzi', 'room'] - has_valid_property_info = property_id.manage_information_ids and property_id.message_standard_id - if (not is_special_contract and has_valid_property_info) or is_special_contract: - area_value = matched_info.management_area if matched_info else 0 - if not management_id: - self.sudo().env["property.management.list"].create({ - "contract_id": record.id, - "property_id": property_id.id, - "area":area_value, - 'original_amount':original_amount, - 'message_standard_id': property_id.message_standard_id.id, - 'lessee_id': record.lessee_id.id, - "due_date":start_date - }) - else: - management_id.write({ - "contract_id": record.id, - "property_id": property_id.id, - "area": area_value, - 'original_amount': original_amount, - 'message_standard_id': property_id.message_standard_id.id, - 'lessee_id': record.lessee_id.id, - "due_date": start_date - }) + management_id.write({ + "contract_id": record.id, + "area": area_value, + 'property_ids': [(6, 0, [lease_id.address_id.id for lease_id in record.lease_ids if lease_id.address_id])], + 'original_amount': total_original_amount, + 'message_standard_id': record.lease_ids[0].message_standard_id.id, + 'lessee_id': record.lessee_id.id, + "due_date": start_date + }) def process_rent_record(self, record, rent_id, date_field_year_month, multiplier=1): """封装处理租金逻辑,增加 multiplier 参数用于乘法""" From c2fea0aceadbfd6404c1171c0a6cf9a854da3d58 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: Mon, 27 Oct 2025 18:53:01 +0800 Subject: [PATCH 2/2] =?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 --- yuthon_property/views/property_management_list_views.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yuthon_property/views/property_management_list_views.xml b/yuthon_property/views/property_management_list_views.xml index f5323ded3..12c1ad417 100644 --- a/yuthon_property/views/property_management_list_views.xml +++ b/yuthon_property/views/property_management_list_views.xml @@ -5,7 +5,7 @@ property.management.list - +