@@ -66,6 +66,7 @@ class PropertyLeaseContract(models.Model):
|
||||
tax_number = fields.Char(related='lessee_id.tax_number', string="税号")
|
||||
industry_id = fields.Many2one(related='lessee_id.industry_id', string="行业")
|
||||
address_for_delivery = fields.Char(string="送达地址")
|
||||
precinct_id = fields.Many2one('yuthon.precinct.message', string="所属片区")
|
||||
|
||||
lease_term = fields.Float(string="租期")
|
||||
lease_term_year = fields.Integer(string="租期(年)")
|
||||
@@ -128,7 +129,7 @@ class PropertyLeaseContract(models.Model):
|
||||
actual_receivable = fields.Float(string="实际应收")
|
||||
now_receivable = fields.Float(string="当期应收")
|
||||
total_receivable = fields.Float(string="总已收")
|
||||
comparison = fields.Selection([('outweigh', '大于'), ('equal', '等于'), ('less', '小于')], string="对比", compute='_compute_comparison', store=True)
|
||||
comparison = fields.Selection([('outweigh', '大于'), ('equal', '等于'), ('less', '小于')], string="对比", compute='_compute_comparison')
|
||||
progress_percentage = fields.Float(string="合同进度", compute="_compute_progress_percentage")
|
||||
condition = fields.Selection([('new', '新建'), ('approval', '审批中'), ('cancel', '作废'), ('be_executed', '待执行'), ('executed', '已执行'), ('expired', '已终止'), ('advance', '提前终止')], string="状态", default='new')
|
||||
contract_type = fields.Selection([('lease_renewal', '续租'), ('interim', '临租'), ('new', '补充协议'), ('first', '首租')], string="合同类型", default='first')
|
||||
@@ -144,7 +145,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 +155,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:
|
||||
@@ -165,6 +208,8 @@ class PropertyLeaseContract(models.Model):
|
||||
record.comparison = 'less'
|
||||
else:
|
||||
record.comparison = 'equal'
|
||||
else:
|
||||
record.comparison = None
|
||||
|
||||
@api.depends('term_end_time', 'actual_end_time', 'term_start_time')
|
||||
def _compute_end_comparison(self):
|
||||
@@ -416,7 +461,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 +868,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:
|
||||
@@ -840,7 +885,8 @@ class PropertyLeaseContract(models.Model):
|
||||
rec.electricity_fee_ids = [(5, 0, 0)]
|
||||
rec.mange_fee_ids = [(5, 0, 0)]
|
||||
rec.admin_id = rec.lease_ids[0].admin_id.id if rec.lease_ids else ''
|
||||
rec.company_id =rec.lease_ids[0].address_id.company_id.id if rec.lease_ids else ''
|
||||
rec.company_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.electricity_fee_ids = electricity_list
|
||||
rec.mange_fee_ids = fee_list
|
||||
|
||||
@@ -851,7 +897,8 @@ class PropertyLeaseContract(models.Model):
|
||||
admin_id = record.lease_ids[0].admin_id.id if record.lease_ids else ''
|
||||
record.write({'company_id': company_id,
|
||||
'admin_id': admin_id,
|
||||
'actual_end_time': datetime.now()})
|
||||
'actual_end_time': datetime.now(),
|
||||
'precinct_id': record.lease_ids[0].address_id.precinct_id.id if record.lease_ids else ''})
|
||||
|
||||
def action_yuthon_property_contract_wizard(self):
|
||||
return {
|
||||
|
||||
@@ -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"/>
|
||||
@@ -423,6 +423,7 @@
|
||||
<field name="invoicing_begins"/>
|
||||
<field name="tax_number"/>
|
||||
<field name="industry_id"/>
|
||||
<field name="precinct_id" invisible="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="contact"/>
|
||||
@@ -624,6 +625,7 @@
|
||||
<field name="name"/>
|
||||
<searchpanel>
|
||||
<field name="company_id"/>
|
||||
<field name="precinct_id"/>
|
||||
</searchpanel>
|
||||
<group expand="0" string="Group By">
|
||||
<filter name="group_by_condition" context="{'group_by': 'condition'}"/>
|
||||
@@ -637,7 +639,7 @@
|
||||
<field name="name">我的合同</field>
|
||||
<field name="res_model">property.lease.contract</field>
|
||||
<field name="view_mode">tree,form,search</field>
|
||||
<field name="domain">[('admin_id','=',uid)]</field>
|
||||
<field name="domain">[('admin_id', '=', uid)]</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_tree1')}),
|
||||
@@ -646,6 +648,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 +658,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,
|
||||
})
|
||||
Reference in New Issue
Block a user