@@ -310,6 +310,69 @@ class PropertyLeaseContract(models.Model):
|
||||
issues_result = fields.Html(string="会议结果")
|
||||
related_issues_id = fields.Many2one('issue.library', string="关联议题")
|
||||
|
||||
# 催费通知单字段
|
||||
fees_date = fields.Date(string="催费日期", compute='_compute_fees_all', store=True)
|
||||
fees_rent = fields.Float(string="租金", compute='_compute_fees_all', store=True)
|
||||
fees_water = fields.Float(string="水费", compute='_compute_fees_all', store=True)
|
||||
fees_electricity = fields.Float(string="电费", compute='_compute_fees_all', store=True)
|
||||
fees_manage = fields.Float(string="管理费", compute='_compute_fees_all', store=True)
|
||||
fees_expenses = fields.Float(string="杂项费", compute='_compute_fees_all', store=True)
|
||||
fees_bollards = fields.Float(string="灯箱费", compute='_compute_fees_all', store=True)
|
||||
betweene_tubes = fields.Float(string="管子间", compute='_compute_fees_all', store=True)
|
||||
fees_total = fields.Float(string="合计", compute='_compute_fees_all', store=True)
|
||||
|
||||
@api.depends()
|
||||
def _compute_fees_all(self):
|
||||
receivable_obj = self.env['property.accounts.receivable']
|
||||
fee_mapping = {
|
||||
'fees_rent': ['租金'],
|
||||
'fees_water': ['水费'],
|
||||
'fees_electricity': ['电费'],
|
||||
'fees_manage': ['管理费'],
|
||||
'fees_bollards': ['广告灯箱费'],
|
||||
'betweene_tubes': ['管子间'],
|
||||
'fees_expenses': ['人工费/日光灯款/代垫用料费']
|
||||
}
|
||||
|
||||
for contract in self:
|
||||
receivable_records = receivable_obj.search([
|
||||
('submitted', '!=', 0),
|
||||
('contract_id', '=', contract.id)
|
||||
])
|
||||
contract.fees_rent = 0.0
|
||||
contract.fees_water = 0.0
|
||||
contract.fees_electricity = 0.0
|
||||
contract.fees_manage = 0.0
|
||||
contract.fees_expenses = 0.0
|
||||
contract.fees_bollards = 0.0
|
||||
contract.betweene_tubes = 0.0
|
||||
contract.fees_date = False
|
||||
contract.fees_total = 0.0
|
||||
|
||||
if not receivable_records:
|
||||
continue
|
||||
all_due_dates = []
|
||||
|
||||
for field_name, target_names in fee_mapping.items():
|
||||
filtered_recs = receivable_records.filtered(
|
||||
lambda r: r.management_type_id and r.management_type_id.name in target_names
|
||||
)
|
||||
if filtered_recs:
|
||||
setattr(contract, field_name, sum(filtered_recs.mapped('submitted')))
|
||||
valid_dates = [d for d in filtered_recs.mapped('due_date') if d]
|
||||
all_due_dates.extend(valid_dates)
|
||||
|
||||
if all_due_dates:
|
||||
contract.fees_date = max(all_due_dates)
|
||||
|
||||
contract.fees_total = (
|
||||
contract.fees_rent + contract.fees_water + contract.fees_electricity +
|
||||
contract.fees_manage + contract.fees_expenses + contract.fees_bollards +
|
||||
contract.betweene_tubes
|
||||
)
|
||||
|
||||
|
||||
|
||||
@api.depends('contract_code', 'version')
|
||||
def _compute_display_name(self):
|
||||
for rec in self:
|
||||
@@ -1967,11 +2030,15 @@ class PropertyLeaseContract(models.Model):
|
||||
if len(lease_contract_ids) > 1:
|
||||
raise UserError("只能单个操作合同续租")
|
||||
for original_contract in lease_contract_ids:
|
||||
record_id = self.env['property.lease.contract'].search([('contract_id', '=', original_contract)])
|
||||
if record_id:
|
||||
raise UserError("该合同已续租,请勿重复操作")
|
||||
new_contract = original_contract.with_context(skip_contract_code_check=True).copy()
|
||||
new_term_start = original_contract.term_end_time + timedelta(
|
||||
days=1) if original_contract.term_end_time else False
|
||||
new_contract.write({
|
||||
'admin_id': original_contract.admin_id,
|
||||
'code': self.env['ir.sequence'].next_by_code('property_lease_contract_code'),
|
||||
'contract_code': None,
|
||||
'work_end': False,
|
||||
'lease_term_year': None,
|
||||
@@ -2037,10 +2104,17 @@ class PropertyLeaseContract(models.Model):
|
||||
main_version = version_str.split('.')[0]
|
||||
new_main_version = int(main_version) + 1
|
||||
new_version = f"V{new_main_version}.0"
|
||||
record_id = self.env['property.lease.contract'].search([('contract_code', '=', lease_contract_ids.contract_code),
|
||||
('version', '=', new_version)
|
||||
])
|
||||
if record_id:
|
||||
raise UserError("该合同已有补充协议审批,请勿重复操作")
|
||||
new_contract = lease_contract_ids.with_context(skip_contract_code_check=True).copy()
|
||||
new_contract.write({
|
||||
'version': new_version,
|
||||
'condition': 'new',
|
||||
'code': self.env['ir.sequence'].next_by_code('property_lease_contract_code'),
|
||||
'self_users_ids': [(6, 0, [self.env.user.id])],
|
||||
'contact_state': 'to',
|
||||
})
|
||||
water_lines = self.env['property.water.fee.line'].search([
|
||||
@@ -2079,7 +2153,7 @@ class PropertyLeaseContract(models.Model):
|
||||
line.copy({'lease_id': new_contract.id})
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'name': '续期合同',
|
||||
'name': '合同补充',
|
||||
'res_model': 'property.lease.contract',
|
||||
'view_mode': 'form',
|
||||
'res_id': new_contract.id,
|
||||
|
||||
@@ -376,7 +376,7 @@
|
||||
<header>
|
||||
<!-- <button name="all_put_evaluation_plan" string="评估推送" type="object" class="btn btn-primary"/>-->
|
||||
<button name="button_lease_extension" type="object" class="btn-primary" string="续租"/>
|
||||
<button name="button_lease_supplement" type="object" class="btn-primary" string="合同补充"/>
|
||||
<button name="button_lease_supplement" type="object" class="btn-primary" string="补充协议"/>
|
||||
<button name="button_lease_change" type="object" class="btn-primary" string="变更"/>
|
||||
<button name="refund_deposit" type="object" class="btn-primary" string="退押金"/>
|
||||
<button name="action_copy_record1" type="object" string="拆分" class="btn-primary"/>
|
||||
|
||||
@@ -45,7 +45,7 @@ class PropertyReconciliationWizard(models.Model):
|
||||
def _compute_receivable_total(self):
|
||||
for rec in self:
|
||||
rec.receivable_total = sum(line.rent for line in rec.reconciliation_line_ids)
|
||||
rec.amount_reconciled = rec.bank_id.no_amount - sum(line.amount for line in self.reconciliation_line_ids)
|
||||
rec.amount_reconciled = min(0 ,rec.bank_id.no_amount - sum(line.amount for line in self.reconciliation_line_ids))
|
||||
|
||||
@api.depends('reconciliation_line_ids.collection_type', 'reconciliation_line_ids.rent')
|
||||
def _compute_rent_total(self):
|
||||
|
||||
Reference in New Issue
Block a user