@@ -707,6 +707,16 @@ class VacationLeaveLine(models.Model):
|
||||
adjust_date = fields.Date(string='调整至')
|
||||
text = fields.Text(string='备注')
|
||||
|
||||
def open_record(self):
|
||||
if self.workflow_record_id:
|
||||
return {
|
||||
"name": "流程详情",
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': f'{self.workflow_record_id.res_model}',
|
||||
'res_id': self.workflow_record_id.res_id,
|
||||
'view_mode': 'form',
|
||||
}
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
return super(VacationLeaveLine, self).create(vals)
|
||||
@@ -808,6 +818,16 @@ class VacationMealLine(models.Model):
|
||||
is_manual = fields.Boolean(string="手动修改")
|
||||
text = fields.Text(string='备注')
|
||||
|
||||
def open_record(self):
|
||||
if self.workflow_record_id:
|
||||
return {
|
||||
"name": "流程详情",
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': f'{self.workflow_record_id.res_model}',
|
||||
'res_id': self.workflow_record_id.res_id,
|
||||
'view_mode': 'form',
|
||||
}
|
||||
|
||||
def create(self, vals):
|
||||
record = super(VacationMealLine, self).create(vals)
|
||||
record._sync_to_employee()
|
||||
@@ -850,6 +870,16 @@ class VacationMedicalLine(models.Model):
|
||||
is_void = fields.Boolean(string='是否作废', default=False)
|
||||
text = fields.Text(string='备注')
|
||||
|
||||
def open_record(self):
|
||||
if self.workflow_record_id:
|
||||
return {
|
||||
"name": "流程详情",
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': f'{self.workflow_record_id.res_model}',
|
||||
'res_id': self.workflow_record_id.res_id,
|
||||
'view_mode': 'form',
|
||||
}
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
# 调用父类方法创建记录
|
||||
@@ -893,6 +923,17 @@ class VacationOtherLine(models.Model):
|
||||
lines = fields.Float(string='天数')
|
||||
text = fields.Text(string='备注')
|
||||
|
||||
def open_record(self):
|
||||
if self.workflow_record_id:
|
||||
return {
|
||||
"name": "流程详情",
|
||||
'type': 'ir.actions.act_window',
|
||||
'res_model': f'{self.workflow_record_id.res_model}',
|
||||
'res_id': self.workflow_record_id.res_id,
|
||||
'view_mode': 'form',
|
||||
}
|
||||
|
||||
|
||||
class DetailsTree(models.Model):
|
||||
_name = 'details.tree'
|
||||
_description = '明细表'
|
||||
|
||||
@@ -143,6 +143,7 @@
|
||||
<page string="年假">
|
||||
<field name="leave_ids" context="{'default_employee_id': employee_id}">
|
||||
<tree editable="bottom" delete="false" decoration-muted="is_void">
|
||||
<button name="open_record" type="object" string="详情" class="btn-primary" invisible="not workflow_record_id"/>
|
||||
<field name="employee_id" column_invisible="1"/>
|
||||
<field name="vacation_id" column_invisible="1"/>
|
||||
<field name="workflow_record_id" domain="[('workflow_id.name', '=', '请假'), ('create_uid.employee_id', '=', employee_id)]"/>
|
||||
@@ -183,6 +184,7 @@
|
||||
<page string="误餐">
|
||||
<field name="meal_fee_ids" context="{'default_employee_id': employee_id}">
|
||||
<tree editable="bottom" delete="false" decoration-muted="is_void">
|
||||
<button name="open_record" type="object" string="详情" class="btn-primary" invisible="not workflow_record_id"/>
|
||||
<field name="employee_id" column_invisible="1"/>
|
||||
<field name="vacation_id" column_invisible="1"/>
|
||||
<field name="workflow_record_id" domain="[('workflow_id.name', '=', '外出'), ('create_uid.employee_id', '=', employee_id)]"/>
|
||||
@@ -200,6 +202,7 @@
|
||||
<page string="其他请假">
|
||||
<field name="other_fee_ids" context="{'default_employee_id': employee_id}">
|
||||
<tree editable="bottom" delete="false" decoration-muted="is_void">
|
||||
<button name="open_record" type="object" string="详情" class="btn-primary" invisible="not workflow_record_id"/>
|
||||
<field name="employee_id" column_invisible="1"/>
|
||||
<field name="vacation_id" column_invisible="1"/>
|
||||
<field name="workflow_record_id" domain="[('workflow_id.name', '=', '请假'), ('create_uid.employee_id', '=', employee_id)]"/>
|
||||
|
||||
@@ -87,6 +87,7 @@ class PropertyLeaseContract(models.Model):
|
||||
precinct_id = fields.Many2one('yuthon.precinct.message', string="所属片区")
|
||||
active = fields.Boolean('Active', default=True, tracking=True)
|
||||
|
||||
|
||||
lease_term_year = fields.Integer(string="租期(年)")
|
||||
lease_term_month = fields.Integer(string="租期(月)")
|
||||
lease_term_day = fields.Integer(string="租期(日)")
|
||||
@@ -182,8 +183,11 @@ class PropertyLeaseContract(models.Model):
|
||||
management_list_ids = fields.One2many('property.management.list', 'contract_id', string="管理费用明细行")
|
||||
contact_state = fields.Selection([('to', '待执行' ), ('ing', '执行中'), ('terminate', '中止'), ('complete', '完成'), ('early_termination', '提前终止')], string='合同管理状态', default='to')
|
||||
# 附件
|
||||
license_id = fields.Many2one('ir.attachment', string="营业执照")
|
||||
legal_entity_id = fields.Many2one('ir.attachment', string="身份证")
|
||||
license_id = fields.Many2many('ir.attachment',
|
||||
relation='property_lease_contract_license_rel',
|
||||
column1='contract_id',
|
||||
column2='attachment_id',
|
||||
string="证照")
|
||||
power_attorney_id = fields.Many2one('ir.attachment', string="授权委托书")
|
||||
asset_valuation_id = fields.Many2one('ir.attachment', string="资产评估结果明细表")
|
||||
lease_contract = fields.Many2one('ir.attachment', string="合同/协议")
|
||||
@@ -359,8 +363,6 @@ class PropertyLeaseContract(models.Model):
|
||||
|
||||
|
||||
@api.depends(
|
||||
'license_id.name',
|
||||
'legal_entity_id.name',
|
||||
'asset_valuation_id.name',
|
||||
'lease_contract.name',
|
||||
'confirmation_transaction_id.name',
|
||||
@@ -369,10 +371,6 @@ class PropertyLeaseContract(models.Model):
|
||||
def _compute_attachment_names(self):
|
||||
"""计算附件名称字段"""
|
||||
for record in self:
|
||||
# 营业执照名称
|
||||
record.license_name = record.license_id.name if record.license_id else ''
|
||||
# 身份证名称
|
||||
record.legal_entity_name = record.legal_entity_id.name if record.legal_entity_id else ''
|
||||
# 资产评估结果明细表名称
|
||||
record.asset_valuation_name = record.asset_valuation_id.name if record.asset_valuation_id else ''
|
||||
# 租赁合同(住宅)名称
|
||||
@@ -1700,6 +1698,7 @@ class PropertyLeaseContractLine(models.Model):
|
||||
admin_line_id = fields.Many2one(related='address_id.admin_id', string="管理员")
|
||||
property_area = fields.Float(related='address_id.management_area', string="面积")
|
||||
message_standard_id = fields.Many2one(related='address_id.message_standard_id', string="管理费标准")
|
||||
message_unit = fields.Float(related='message_standard_id.amount', string="管理费单价")
|
||||
evaluate_unit_price = fields.Float(string="评估单价")
|
||||
|
||||
|
||||
|
||||
@@ -342,8 +342,7 @@
|
||||
<page string="附件" invisible="state in ['协办', '分管领导', '总经理', '二部协办']">
|
||||
<group col="2">
|
||||
<group>
|
||||
<field name="license_id" widget="preview_many2one"/>
|
||||
<field name="legal_entity_id" widget="preview_many2one"/>
|
||||
<field name="license_id" widget="preview_many2many"/>
|
||||
<field name="handover_time" invisible="1"/>
|
||||
<field name="lease_contract" widget="preview_many2one"/>
|
||||
</group>
|
||||
@@ -509,7 +508,9 @@
|
||||
<tree editable="bottom" create="false">
|
||||
<field name="lease_id" column_invisible="1"/>
|
||||
<field name="address_id"/>
|
||||
<field name="property_area"/>
|
||||
<field name="admin_line_id"/>
|
||||
<field name="message_unit"/>
|
||||
<field name="property_area"/>
|
||||
<field name="evaluate_unit_price"/>
|
||||
<field name="message_standard_id"/>
|
||||
@@ -769,7 +770,6 @@
|
||||
<group col="2">
|
||||
<group>
|
||||
<field name="license_id" widget="preview_many2one"/>
|
||||
<field name="legal_entity_id" widget="preview_many2one"/>
|
||||
<field name="lease_contract" widget="preview_many2one"/>
|
||||
</group>
|
||||
<group>
|
||||
|
||||
@@ -125,6 +125,31 @@ class PropertyReconciliationWizard(models.Model):
|
||||
'remake': f'违约金({start_date_str}至{end_date_str},共{late_days}天)',
|
||||
})
|
||||
|
||||
# 查找应收是否有未交全的租金
|
||||
unpaid_rent_recs = self.env['property.accounts.receivable'].search([
|
||||
('management_type_id.name', '=', '租金'),
|
||||
('contract_id', '=', contract_id.id),
|
||||
('submitted', '!=', 0),
|
||||
('payout_date', '!=', None),
|
||||
])
|
||||
if unpaid_rent_recs:
|
||||
first_day = (unpaid_rent_recs.payout_date + timedelta(days=1))
|
||||
last_month_rent = unpaid_rent_recs.submitted
|
||||
penalty_days = self.actual_date - first_day
|
||||
penalty_amount = (penalty_days.days + 1) * round(
|
||||
last_month_rent * float(contract_id.percentage_liquidated_damages.name), 2
|
||||
) if contract_id else 0.0
|
||||
if penalty_amount > 0:
|
||||
new_lines.append((0, 0, {
|
||||
'contract_id': contract_id.id if contract_id else None,
|
||||
'rent_month': 0,
|
||||
'due_date': fields.Date.to_string(first_day),
|
||||
'rent': penalty_amount,
|
||||
'amount': 0,
|
||||
'collection_type': 'penalty',
|
||||
'remake': f'违约金({fields.Date.to_string(first_day)}至{fields.Date.to_string(self.actual_date)},共{penalty_days.days + 1}天)',
|
||||
}))
|
||||
|
||||
# 3. 添加到总列表
|
||||
for vals in contract_penalties:
|
||||
new_lines.append((0, 0, vals))
|
||||
@@ -137,6 +162,7 @@ class PropertyReconciliationWizard(models.Model):
|
||||
self.reconciliation_line_ids = keep_lines + new_lines
|
||||
if self.reconciliation_line_ids:
|
||||
self.reconciliation_line_ids.sorted(key=lambda r: r.sequence)
|
||||
|
||||
all_penalties = all(line.collection_type == 'penalty' for line in self.reconciliation_line_ids)
|
||||
if all_penalties and self.reconciliation_line_ids:
|
||||
total = sum(line.rent for line in self.reconciliation_line_ids)
|
||||
@@ -238,33 +264,10 @@ class PropertyReconciliationWizard(models.Model):
|
||||
'collection_type': 'penalty',
|
||||
'remake': f'违约金({fields.Date.to_string(first_day)}至{fields.Date.to_string(self.actual_date)},共{penalty_days}天',
|
||||
}))
|
||||
if missing_penalty_lines:
|
||||
self.write({ 'reconciliation_line_ids': missing_penalty_lines})
|
||||
|
||||
# 查找上个月应收是否有未交全的租金
|
||||
unpaid_rent_recs = self.env['property.accounts.receivable'].search([
|
||||
('management_type_id.name', '=', '租金'),
|
||||
('contract_id', '=', contract_id.id),
|
||||
('submitted', '!=', 0),
|
||||
('payout_date', '!=', None),
|
||||
('due_date', '=like', f'{last_month_str}%')
|
||||
])
|
||||
if unpaid_rent_recs:
|
||||
first_day = (unpaid_rent_recs.payout_date + timedelta(days=1))
|
||||
last_month_rent = unpaid_rent_recs.submitted
|
||||
penalty_days = self.actual_date - first_day
|
||||
penalty_amount = (penalty_days.days +1) * round(last_month_rent * float(contract.percentage_liquidated_damages.name), 2
|
||||
) if contract else 0.0
|
||||
if penalty_amount > 0:
|
||||
missing_penalty_lines.append((0, 0, {
|
||||
'contract_id': contract.id if contract else None,
|
||||
'rent_month': 0,
|
||||
'due_date': fields.Date.to_string(first_day),
|
||||
'rent': penalty_amount,
|
||||
'amount': 0,
|
||||
'collection_type': 'penalty',
|
||||
'remake': f'违约金({fields.Date.to_string(first_day)}至{fields.Date.to_string(self.actual_date)},共{penalty_days.days + 1}天)',
|
||||
}))
|
||||
# 添加缺失的违约金记录
|
||||
if missing_penalty_lines:
|
||||
self.write({'reconciliation_line_ids': missing_penalty_lines})
|
||||
|
||||
self.create_reconciliation_vals()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user