添加功能
This commit is contained in:
@@ -33,7 +33,7 @@ class PropertyBankStatements(models.Model):
|
||||
contract_penalty = fields.Char(string="合同累计违约金")
|
||||
original_amount = fields.Float(string='交易金额')
|
||||
lending_direction = fields.Selection([('borrow', '借'), ('loan', '贷')], string='借贷方向')
|
||||
yes_amount = fields.Float(stringo='已对')
|
||||
yes_amount = fields.Float(string='已对')
|
||||
no_amount = fields.Float(string='未对', compute='_compute_no_amount')
|
||||
reconciliation_time = fields.Datetime('对账时间')
|
||||
voucher_type = fields.Selection([('electronic_transfer', '电子转账凭证'), ('telegraphic_transfer', '电汇凭证')], string='凭证种类')
|
||||
|
||||
@@ -558,6 +558,7 @@ class PropertyBankStatements(models.Model):
|
||||
statements = self.env['property.bank.statements'].search([
|
||||
('name', '=', account),
|
||||
('start_time', '<', current_transaction_time - timedelta(hours=8)),
|
||||
('your_own_unit', '=', self.your_own_unit),
|
||||
('bank_state', '=', 'not_reconciled'),
|
||||
('id', '!=', self.id),
|
||||
])
|
||||
@@ -1018,6 +1019,25 @@ class PropertyRentList(models.Model):
|
||||
property_address = fields.Text(string="物业信息", compute='get_property_address')
|
||||
contract_sort = fields.Selection(related='contract_id.contract_sort', string="资产类型", store=True)
|
||||
company_id = fields.Many2one(related='contract_id.lessor_id', string="出租方公司", store=True)
|
||||
is_company = fields.Boolean(string='是否是本公司', compute='_compute_is_company', store=False)
|
||||
|
||||
@api.depends('company_id')
|
||||
@api.depends_context('uid', 'company')
|
||||
def _compute_is_company(self):
|
||||
user_companies = self.env['res.company'].browse(self.env.companies.ids)
|
||||
user_company_names = set(user_companies.mapped('name'))
|
||||
account_mapping = {
|
||||
'集团本部': ['天河投资', '天投城建'],
|
||||
'天河物管': ['天河物管'],
|
||||
'天河粮储': ['天河粮储']
|
||||
}
|
||||
for record in self:
|
||||
record.is_company = False
|
||||
for company_name, allowed_accounts in account_mapping.items():
|
||||
if company_name in user_company_names:
|
||||
if record.company_id.referred in allowed_accounts:
|
||||
record.is_company = True
|
||||
break
|
||||
|
||||
@api.depends('contract_id')
|
||||
def get_property_address(self):
|
||||
|
||||
@@ -1945,30 +1945,30 @@ class PropertyLeaseContract(models.Model):
|
||||
line.copy({'contract_id': new_contract.id})
|
||||
# 复制电费明细行
|
||||
electric_lines = self.env['property.electric.fee.line'].search([
|
||||
('contract_id', '=', lease_contract_ids.contract_id.id)
|
||||
('contract_id', '=', lease_contract_ids.id)
|
||||
])
|
||||
for line in electric_lines:
|
||||
line.copy({'contract_id': new_contract.id})
|
||||
# 复制物业管理费明细行
|
||||
manage_lines = self.env['property.manage.fee.line'].search([
|
||||
('contract_id', '=', lease_contract_ids.contract_id.id)
|
||||
('contract_id', '=', lease_contract_ids.id)
|
||||
])
|
||||
for line in manage_lines:
|
||||
line.copy({'contract_id': new_contract.id})
|
||||
# 复制其他费用明细行
|
||||
other_lines = self.env['property.other.fee.line'].search([
|
||||
('other_id', '=', lease_contract_ids.contract_id.id)
|
||||
('other_id', '=', lease_contract_ids.id)
|
||||
])
|
||||
for line in other_lines:
|
||||
line.copy({'other_id': new_contract.id})
|
||||
# 复制子合同明细
|
||||
subset_lines = self.env['property.subset.contract'].search([
|
||||
('subset_id', '=', lease_contract_ids.contract_id.id)
|
||||
('subset_id', '=', lease_contract_ids.id)
|
||||
])
|
||||
for line in subset_lines:
|
||||
line.copy({'subset_id': new_contract.id})
|
||||
lease_lines = self.env['property.lease.contract.line'].search([
|
||||
('lease_id', '=', lease_contract_ids.contract_id.id)
|
||||
('lease_id', '=', lease_contract_ids.id)
|
||||
])
|
||||
for line in lease_lines:
|
||||
line.copy({'lease_id': new_contract.id})
|
||||
@@ -1976,6 +1976,7 @@ class PropertyLeaseContract(models.Model):
|
||||
new_contract.write({
|
||||
'version': new_version,
|
||||
'condition': 'new',
|
||||
'contact_state': 'to',
|
||||
})
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
|
||||
@@ -20,8 +20,8 @@ class PropertyMergeApproval(models.Model):
|
||||
merge_units = fields.Char(string='单元')
|
||||
merge_property_floor_id = fields.Many2one('property.floor.setting', string='楼层')
|
||||
merge_asset_type_id = fields.Many2one('yuthon.resource.type', string='资产类型')
|
||||
merge_building_area = fields.Float(string='建筑面积', digits=(16, 4))
|
||||
merge_rent_area = fields.Float(string='可租面积')
|
||||
management_area = fields.Float(string='管理面积', digits=(16, 4))
|
||||
merge_rent_area = fields.Float(string='可租面积', digits=(16, 4))
|
||||
merge_remarks = fields.Char(string='备注')
|
||||
is_issues = fields.Boolean(string='是否上会')
|
||||
issues_result = fields.Html(string="会议结果")
|
||||
@@ -42,16 +42,16 @@ class PropertyMergeApproval(models.Model):
|
||||
@api.onchange('property_merge_approval_line_ids')
|
||||
def _onchange_property_merge_approval_line_ids(self):
|
||||
name = []
|
||||
merge_building_area = 0
|
||||
management_area = 0
|
||||
merge_rent_area = 0
|
||||
if self.property_merge_approval_line_ids:
|
||||
for property_margin in self.property_merge_approval_line_ids:
|
||||
property_name = str(property_margin.property_id.name) if property_margin.property_id.name else ""
|
||||
name.append(property_name)
|
||||
merge_building_area += property_margin.building_area
|
||||
management_area += property_margin.management_area
|
||||
merge_rent_area += property_margin.rent_area
|
||||
self.property_name = ','.join(name)
|
||||
self.merge_building_area = merge_building_area
|
||||
self.management_area = management_area
|
||||
self.merge_rent_area = merge_rent_area
|
||||
|
||||
def put_merge_message(self):
|
||||
@@ -60,7 +60,7 @@ class PropertyMergeApproval(models.Model):
|
||||
property_id = source_property.with_context(skip_contract_code_check=True).copy()
|
||||
property_id.write({
|
||||
'name': self.property_name,
|
||||
'building_area': self.merge_building_area,
|
||||
'building_area': self.management_area,
|
||||
'rent_area': self.merge_rent_area,
|
||||
'effective_date': self.start_date,
|
||||
'is_done_split': True,
|
||||
@@ -107,6 +107,7 @@ class PropertyMergeApproval(models.Model):
|
||||
latest_line.write({'end_date': self.start_date})
|
||||
latest_line.copy({
|
||||
'rent_area': self.merge_rent_area,
|
||||
'management_area': self.management_area,
|
||||
'yuthon_property_id': property_id.id
|
||||
})
|
||||
property_id.manage_information_ids.write({'start_time': self.start_date,
|
||||
@@ -138,7 +139,7 @@ class PropertyMergeApprovalLine(models.Model):
|
||||
units = fields.Char(related='property_id.units', string='单元')
|
||||
property_floor_id = fields.Many2one(related='property_id.property_floor_id', string='楼层')
|
||||
asset_type_id = fields.Many2one(related='property_id.asset_type_id', string='资产类型')
|
||||
building_area = fields.Float(related='property_id.building_area', string='建筑面积', digits=(16, 4))
|
||||
management_area = fields.Float(related='property_id.management_area', string='管理面积', digits=(16, 4))
|
||||
rent_area = fields.Float(related='property_id.rent_area', string='可租面积', digits=(16, 4))
|
||||
remarks = fields.Char(string='备注')
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@
|
||||
<field name="name">租金列表</field>
|
||||
<field name="res_model">property.rent.list</field>
|
||||
<field name="view_mode">tree,search</field>
|
||||
<field name="domain">[('is_push', '=', False)]</field>
|
||||
<field name="domain">[('is_push', '=', False), ('is_company', '=', True)]</field>
|
||||
<field name="context">{'search_default_group_admin_id': True, 'search_default_group_due_date': True}</field>
|
||||
<field name="search_view_id" ref="yuthon_property_approval.view_property_rent_list_search"/>
|
||||
</record>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<field name="property_name"/>
|
||||
<field name="code"/>
|
||||
<field name="merge_asset_type_id"/>
|
||||
<field name="merge_building_area"/>
|
||||
<field name="management_area"/>
|
||||
<field name="merge_rent_area"/>
|
||||
<field name="start_date"/>
|
||||
</tree>
|
||||
@@ -67,7 +67,7 @@
|
||||
<field name="units"/>
|
||||
<field name="property_floor_id" options="{'no_create': True}"/>
|
||||
<field name="asset_type_id" options="{'no_create': True}"/>
|
||||
<field name="building_area"/>
|
||||
<field name="management_area"/>
|
||||
<field name="rent_area"/>
|
||||
<field name="remarks"/>
|
||||
</tree>
|
||||
@@ -82,7 +82,7 @@
|
||||
<field name="merge_asset_type_id" invisible="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="merge_building_area"/>
|
||||
<field name="management_area"/>
|
||||
<field name="merge_rent_area"/>
|
||||
<field name="merge_remarks"/>
|
||||
</group>
|
||||
|
||||
@@ -20,6 +20,15 @@ class BindingInformationWizard(models.Model):
|
||||
string='可用物业ID',
|
||||
store=True
|
||||
)
|
||||
available_contract_ids = fields.Many2many(
|
||||
'property.lease.contract',
|
||||
'binding_information_wizard_available_contract_rel',
|
||||
'wizard_id',
|
||||
'contract_id',
|
||||
compute='_compute_available_records',
|
||||
string='可用合同ID',
|
||||
store=True
|
||||
)
|
||||
|
||||
@api.onchange('contract_ids')
|
||||
def onchange_contract_ids(self):
|
||||
@@ -37,17 +46,29 @@ class BindingInformationWizard(models.Model):
|
||||
if new_property_ids:
|
||||
self.property_ids = [(4, property_id) for property_id in new_property_ids]
|
||||
|
||||
@api.onchange('bank_id')
|
||||
def _onchange_bank_id(self):
|
||||
"""计算可用的物业和合同ID"""
|
||||
for record in self:
|
||||
# 搜索未对账的应收记录
|
||||
unreconciled_records = self.env['property.accounts.receivable'].search([
|
||||
('is_reconciliation', '=', False)
|
||||
])
|
||||
contract_ids = list(set(record.contract_id.id for record in unreconciled_records if record.contract_id))
|
||||
|
||||
# 设置计算字段值
|
||||
record.available_contract_ids = [(6, 0, contract_ids)] if contract_ids else [(5,)]
|
||||
|
||||
def confirm(self):
|
||||
if self.bank_id.name:
|
||||
bank_ids = self.env['property.bank.statements'].search([('name', '=', self.bank_id.name),
|
||||
('your_own_unit', '=', self.bank_id.your_own_unit)])
|
||||
for bank_id in bank_ids:
|
||||
if self.contract_ids:
|
||||
bank_id.write({
|
||||
'contract_ids': [(6, 0, self.contract_ids.ids)],
|
||||
'admin_id': self.contract_ids[0].admin_id.id if self.contract_ids[0].admin_id else False
|
||||
if self.contract_ids:
|
||||
new_contracts = self.contract_ids - self.bank_id.contract_ids
|
||||
if new_contracts:
|
||||
self.bank_id.write({
|
||||
'contract_ids': [(4, cont.id) for cont in new_contracts]
|
||||
})
|
||||
|
||||
# 根据银行账号查找承租方信息
|
||||
bank_account = self.env['property.bank.line'].search([
|
||||
('bank', '=', self.bank_id.name),
|
||||
('tenant_id.name', '!=', False),
|
||||
@@ -61,18 +82,25 @@ class BindingInformationWizard(models.Model):
|
||||
if invalid_bank_lines:
|
||||
invalid_bank_lines.unlink()
|
||||
|
||||
bank_ids = self.env['property.bank.statements'].search([('name', '=', self.bank_id.name),
|
||||
('your_own_unit', '=',
|
||||
self.bank_id.your_own_unit)])
|
||||
for bank_id in bank_ids:
|
||||
bank_id.write({
|
||||
'contract_ids': [(6, 0, self.bank_id.contract_ids.ids)],
|
||||
})
|
||||
|
||||
if bank_account:
|
||||
all_contracts = self.contract_ids
|
||||
for contract in all_contracts:
|
||||
tenant_id = self.env['property.tenant.line'].sudo().search([
|
||||
('tenant_id', '=', bank_account.tenant_id.id),
|
||||
('lease_contract_id', '=', contract.id),
|
||||
])
|
||||
if not tenant_id:
|
||||
self.env['property.tenant.line'].sudo().create({
|
||||
'tenant_id': bank_account.tenant_id.id,
|
||||
'lease_contract_id': contract.id,
|
||||
})
|
||||
# 获取已存在的合同明细行的合同ID
|
||||
existing_contract_ids = bank_account.tenant_id.property_contract_ids.mapped('lease_contract_id.id')
|
||||
all_contracts = self.contract_ids | self.bank_id.contract_ids
|
||||
# 过滤出需要新增的合同(排除已存在的)
|
||||
new_contracts = all_contracts.filtered(lambda c: c.id not in existing_contract_ids)
|
||||
for contract in new_contracts:
|
||||
self.env['property.tenant.line'].sudo().create({
|
||||
'tenant_id': bank_account.tenant_id.id,
|
||||
'lease_contract_id': contract.id,
|
||||
})
|
||||
else:
|
||||
tenant = self.env['property.tenant.information'].create({
|
||||
'name': self.bank_id.name_account,
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
<field name="bank_id" invisible="1"/>
|
||||
<field name="available_property_ids" widget="many2many_tags" invisible="1"/>
|
||||
<field name="lessee_ids" widget="many2many_tags" readonly="1"/>
|
||||
<field name="available_contract_ids" widget="many2many_tags" invisible="1"/>
|
||||
<field name="your_own_unit" invisible="1"/>
|
||||
<field name="property_ids" widget="many2many_tags" domain="[('id', 'in', available_property_ids)]" options="{'no_create': True}"/>
|
||||
<field name="contract_ids" widget="many2many_tags" domain="[('lessee_id', 'in', lessee_ids), ('lessor_id.referred', '=', your_own_unit), ('is_split', '=', False)]" options="{'no_create': True}"/>
|
||||
<field name="contract_ids" widget="many2many_tags" domain="[('lessee_id', 'in', lessee_ids), ('lessor_id.referred', '=', your_own_unit), ('is_split', '=', False), ('id', 'in', available_contract_ids)]" options="{'no_create': True}"/>
|
||||
</group>
|
||||
</sheet>
|
||||
<footer>
|
||||
|
||||
@@ -317,13 +317,22 @@ class PropertyReconciliationWizard(models.Model):
|
||||
"""
|
||||
remaining_amount = self.bank_id.no_amount
|
||||
penalty_lines = [line for line in self.reconciliation_line_ids if line.collection_type == "penalty"] # 违约金行
|
||||
deposit_lines = [line for line in self.reconciliation_line_ids if line.collection_type == "deposit"] # 押金行
|
||||
rent_lines = [line for line in self.reconciliation_line_ids if line.collection_type == "rent"] # 租金行
|
||||
other_lines = [line for line in self.reconciliation_line_ids if line.collection_type not in ["deposit", "rent"]]
|
||||
|
||||
# 优先处理押金行
|
||||
sorted_deposit_lines = sorted(deposit_lines, key=lambda line: line.due_date)
|
||||
for line in sorted_deposit_lines:
|
||||
type_priority = {
|
||||
'deposit': 0, # 押金优先
|
||||
'rent': 1, # 其次租金
|
||||
'other': 2, # 其他类型
|
||||
'penalty': 3
|
||||
}
|
||||
all_lines = sorted(
|
||||
self.reconciliation_line_ids,
|
||||
key=lambda line: (
|
||||
line.due_date, # 第一排序键:日期
|
||||
type_priority.get(line.collection_type, 3)
|
||||
)
|
||||
)
|
||||
for line in all_lines:
|
||||
if remaining_amount <= 0:
|
||||
break
|
||||
deposit = line.rent or 0
|
||||
@@ -333,37 +342,6 @@ class PropertyReconciliationWizard(models.Model):
|
||||
remaining_amount -= assign_amount
|
||||
line.onchange_remake()
|
||||
|
||||
# 3. 处理租金行(原有逻辑不变,按“日期最早+金额最小”排序)
|
||||
sorted_rent_lines = sorted(
|
||||
rent_lines,
|
||||
key=lambda line: (
|
||||
line.due_date,
|
||||
line.rent or 0
|
||||
)
|
||||
)
|
||||
for line in sorted_rent_lines:
|
||||
if remaining_amount <= 0:
|
||||
break
|
||||
rent = line.rent or 0
|
||||
line.amount = 0
|
||||
assign_amount = min(rent, remaining_amount)
|
||||
line.amount = assign_amount
|
||||
remaining_amount -= assign_amount
|
||||
line.onchange_remake()
|
||||
|
||||
# 4. 处理其他类型行(原有逻辑不变,按日期排序)
|
||||
if remaining_amount > 0:
|
||||
sorted_other_lines = sorted(other_lines, key=lambda line: line.due_date)
|
||||
for line in sorted_other_lines:
|
||||
if remaining_amount <= 0:
|
||||
break
|
||||
amount_needed = line.rent or 0
|
||||
line.amount = 0
|
||||
assign_amount = min(amount_needed, remaining_amount)
|
||||
line.amount = assign_amount
|
||||
remaining_amount -= assign_amount
|
||||
line.onchange_remake()
|
||||
|
||||
for line in penalty_lines:
|
||||
line.color = 'blue'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user