Merge pull request !1280 from 李鹏宇/dev_zhou
This commit is contained in:
李鹏宇
2025-01-11 07:30:26 +00:00
committed by Gitee
3 changed files with 53 additions and 9 deletions
@@ -144,7 +144,6 @@ class PropertyLeaseContract(models.Model):
other_ids = fields.One2many('property.other.fee.line', 'other_id', string="其他费用明细行")
rent_list_ids = fields.One2many('property.rent.list', 'contract_id', string="租金明细行")
management_list_ids = fields.One2many('property.management.list', 'contract_id', string="管理费用明细行")
# 附件
license_id = fields.Many2one('ir.attachment', string="营业执照")
card_id = fields.Many2one('ir.attachment', string="经办人身份证")
@@ -155,6 +154,49 @@ class PropertyLeaseContract(models.Model):
responsibility_book_id = fields.Many2one('ir.attachment', string="安全生产责任书")
handover_time = fields.Date(string="交接日期")
def get_breakdown_rent(self, select_month, select_year):
rent_monthly = 0
monthly_records = self.env['property.lease.contract'].search([('cycle_dict', '=', 'monthly')])
year = int(select_year)
month = int(select_month)
date_field = datetime(year, month, 1).date()
for record in monthly_records:
days = record.date_payment_month
if not record.rent_free_period_month:
for rent_id in record.breakdown_ids:
start_date_year_month = rent_id.start_date.strftime('%Y-%m')
end_date_year_month = rent_id.end_date.strftime('%Y-%m')
date_field_year_month = date_field.strftime('%Y-%m')
if start_date_year_month <= date_field_year_month < end_date_year_month:
rent_monthly = rent_id.monthly_amount
elif start_date_year_month <= date_field_year_month <= end_date_year_month:
end_days = rent_id.end_date.day
if end_days < days:
rent_monthly = rent_id.monthly_amount
else:
rent_monthly = rent_id[+1].monthly_amount
else:
pass
else:
period_month = record.rent_free_period_month
for rent_id in record.breakdown_ids:
start_date_year_month = (rent_id.start_date + relativedelta(months=period_month)).strftime('%Y-%m')
end_date_year_month = rent_id.end_date.strftime('%Y-%m')
date_field_year_month = date_field.strftime('%Y-%m')
if start_date_year_month <= date_field_year_month < end_date_year_month:
rent_monthly = rent_id.monthly_amount
elif start_date_year_month <= date_field_year_month <= end_date_year_month:
end_days = rent_id.end_date.day
if end_days < days:
rent_monthly = rent_id.monthly_amount
else:
rent_monthly = rent_id[+1].monthly_amount
else:
pass
return rent_monthly
@api.depends('not_received', 'now_receivable')
def _compute_comparison(self):
for record in self:
@@ -416,7 +458,7 @@ class PropertyLeaseContract(models.Model):
all_period_rent = record.do_generate_details_core(start_date, first_year_end_date, False)
record.first_year_rent = all_period_rent
def do_generate_details_core(self, start_date=None, end_date=None, write_db=False):
def do_generate_details_core(self, start_date, end_date, write_db=False):
all_period_rent = 0
unit_price = self.unit_price # 单价
@@ -823,7 +865,7 @@ class PropertyLeaseContract(models.Model):
rec.is_electricity = True
for electricity_id in property_id.energy_meter_ids:
electricity_list.append([0, 0, {
'fees_id': property_id.electricity_id.id,
'fees_id': electricity_id.id,
'proportional':electricity_id.rate,
}])
else:
@@ -310,7 +310,7 @@
<field name="not_received" decoration-muted="comparison == 'equal'"
decoration-danger = "comparison == 'outweigh'"
decoration-success = "comparison == 'less'"/>
<field name="comparison"/>
<field name="comparison" column_invisible="1"/>
<field name="percentage_damages"/>
<field name="total_receivable"/>
<field name="term_start_month_day"/>
@@ -379,7 +379,7 @@
<field name="department_id" invisible="1"/>
<field name="name"/>
<field name="use_address"/>
<field name="deposit_status"/>
<field name="deposit_status" invisible="1"/>
<field name="address_for_delivery"/>
<field name="condition" invisible="1" readonly="1"/>
<field name="is_equal" invisible="1"/>
@@ -624,6 +624,7 @@
<field name="name"/>
<searchpanel>
<field name="company_id"/>
<field name="admin_id"/>
</searchpanel>
<group expand="0" string="Group By">
<filter name="group_by_condition" context="{'group_by': 'condition'}"/>
@@ -646,6 +647,7 @@
<record id="property_lease_contract_all_action" model="ir.actions.act_window">
<field name="name">全部合同</field>
<field name="res_model">property.lease.contract</field>
<field name="domain">[('condition', 'in', ['be_executed', 'executed', 'expired' ,'advance'])]</field>
<field name="view_mode">tree,form,search</field>
<field name="view_ids" eval="[(5, 0, 0),
(0, 0, {'view_mode': 'tree', 'view_id': ref('yuthon_property_approval.view_property_lease_contract_tree1')}),
@@ -655,6 +657,7 @@
<field name="name">合同审批</field>
<field name="res_model">property.lease.contract</field>
<field name="view_mode">tree,form,search</field>
<field name="domain">[('condition', 'in', ['new', 'approval', 'cancel'])]</field>
<field name="context">{'search_default_group_by_condition':1}</field>
<field name="view_ids" eval="[(5, 0, 0),
(0, 0, {'view_mode': 'tree', 'view_id': ref('yuthon_property_approval.view_property_lease_contract_tree')}),
@@ -30,14 +30,13 @@ class PropertyRentalWizard(models.Model):
raise UserError(_("请填写租期结束时间!"))
rent_id = self.sudo().env["property.rent.list"].search([("contract_id", "=", record.id)])
start_date = record.term_start_time
end_date = record.term_end_time + relativedelta(days=1)
all_period_rent = record.do_generate_details_core(start_date, end_date)
rent_monthly = record.get_breakdown_rent(self.select_month, self.select_year)
if not rent_id:
self.sudo().env["property.rent.list"].create({
"contract_id": record.id,
"contract_code": record.code,
"due_date": start_date,
"original_amount": all_period_rent,
"original_amount": rent_monthly,
"year": self.select_year,
'month': self.select_month,
})
@@ -46,7 +45,7 @@ class PropertyRentalWizard(models.Model):
"contract_id": record.id,
"contract_code": record.code,
"due_date": start_date,
"original_amount": all_period_rent,
"original_amount": rent_monthly,
"year": self.select_year,
'month': self.select_month,
})