!5762 添加功能

Merge pull request !5762 from 李鹏宇/dev_zhou
This commit is contained in:
李鹏宇
2025-10-17 08:37:43 +00:00
committed by Gitee
4 changed files with 25 additions and 26 deletions
@@ -11,6 +11,7 @@ class PropertyRentList(models.Model):
rent_month = fields.Float(string='当月租金')
tax = fields.Float(string='税率')
title_certificate = fields.Char(sting="产权证号")
acc_type = fields.Selection([('new', '新租'), ('done', '到期')], string='类型')
invoicing_type = fields.Selection([('spot', '专票'), ('cape', '普票')], related='lessee_id.invoicing_type',
string="开票类型")
due_date = fields.Date(string='应收日期')
@@ -6,6 +6,7 @@
<field name="arch" type="xml">
<tree editable="bottom" string="租金列表" decoration-danger = "charge_status == 'unpaid'"
decoration-success="charge_status == 'fully_paid'" js_class="custom_rent_list_button" delete="false" limit="15">
<field name="acc_type" string=" " readonly="1"/>
<field name="property_id" options="{'no_create': True}" column_invisible="1"/>
<field name="lessee_id" readonly="1"/>
<field name="due_date" readonly="1"/>
@@ -879,17 +879,6 @@ class PropertyRentList(models.Model):
due_date_end = False
theoretical_end = False
contract = rec.contract_id
existing_receivable = self.env['property.accounts.receivable'].search([
('lessee_id', '=', rec.lessee_id.id),
('management_type_id.name', '=', '租金'),
('contract_id', '=', contract),
], limit=1)
if not existing_receivable:
acc_type = 'new'
else:
acc_type = None
if contract and contract.cycle_mode and due_date:
due_date_obj = fields.Date.from_string(due_date)
contract_actual_end = fields.Date.from_string(
@@ -927,7 +916,7 @@ class PropertyRentList(models.Model):
'lessee_id': contract.lessee_id.id if contract and contract.lessee_id else None,
'original_amount': rec.original_amount,
'due_date': due_date,
'acc_type': acc_type,
'acc_type': rec.acc_type,
'due_date_end': due_date_end,
'create_time': datetime.now(),
'management_type_id': management_type.id,
@@ -27,23 +27,26 @@ class PropertyRentalWizard(models.Model):
('due_date', '<=', last_day_of_month),
])
# 判断是否有已生成应收
existing_receivable = self.env['property.accounts.receivable'].search([
('lessee_id', '=', record.lessee_id.id),
('due_date', '>=', first_day_of_month),
('due_date', '<=', last_day_of_month),
('management_type_id.name', '=', '租金'),
('contract_id', '=', record.id),
], limit=1)
if existing_receivable:
return
else:
acc_type = 'new'
if not rent_id:
# 判断是否有已生成应收
existing_receivable = self.env['property.accounts.receivable'].search([
('lessee_id', '=', record.lessee_id.id),
('due_date', '>=', first_day_of_month),
('due_date', '<=', last_day_of_month),
('management_type_id.name', '=', '租金'),
('contract_id', '=', record.id),
], limit=1)
if existing_receivable:
return
self.sudo().env["property.rent.list"].create({
"contract_id": record.id,
"due_date": start_date,
'multiplier': multiplier,
'acc_type': acc_type,
"lessee_id": record.lessee_id.id,
"property_id": property_id,
"original_amount": rent_amount,
@@ -56,6 +59,7 @@ class PropertyRentalWizard(models.Model):
"due_date": start_date,
'multiplier': multiplier,
"lessee_id": record.lessee_id.id,
'acc_type': acc_type,
"property_id": property_id,
"original_amount": rent_amount,
"year": self.select_year,
@@ -156,8 +160,12 @@ class PropertyRentalWizard(models.Model):
end_year_month = rent_id.end_data.strftime('%Y-%m')
start_day = start_date_adj.day
rent_amount = rent_id.monthly_amount
# 调整后的租金
date_str = f"{date_field_year_month}-{start_day}"
# 调整后的租金
target_year, target_month = map(int, date_field_year_month.split('-'))
max_day = calendar.monthrange(target_year, target_month)[1]
# 修正日:如果原始日超过当月最大天数,取当月最后一天
adjusted_day = min(start_day, max_day)
date_str = f"{date_field_year_month}-{adjusted_day}"
start_date = datetime.strptime(date_str, "%Y-%m-%d")
# 当期应收日期
if not record.is_contract: