添加功能
This commit is contained in:
@@ -269,7 +269,7 @@ class MeterArchivesLine(models.Model):
|
||||
else:
|
||||
record.current_meter = 0
|
||||
|
||||
@api.onchange('current_meter', 'unit')
|
||||
@api.onchange('current_meter', 'unit', 'line_loss')
|
||||
def onchange_receivables(self):
|
||||
for record in self:
|
||||
# 因为current_meter 取不到值所有复制一遍
|
||||
|
||||
@@ -238,7 +238,7 @@ class MeterWaterLine(models.Model):
|
||||
else:
|
||||
rec.meter_date_month = False
|
||||
|
||||
@api.onchange('current_meter', 'unit')
|
||||
@api.onchange('current_meter', 'unit', 'line_loss')
|
||||
def onchange_receivables(self):
|
||||
for record in self:
|
||||
# 因为current_meter 取不到值所有复制一遍
|
||||
|
||||
@@ -29,35 +29,37 @@ class MeterPriceWizard(models.TransientModel):
|
||||
])
|
||||
for valid in valid_contract_lines:
|
||||
if valid.archives_id.type == 'fees':
|
||||
if valid.yuthon_property_ids:
|
||||
contract_id = self.env['property.contract.line'].search([
|
||||
('yuthon_property_id', '=', valid.yuthon_property_ids[0].id),
|
||||
('start_time', '<=', self.price_date),
|
||||
('end_date', '>=', self.price_date),
|
||||
], limit=1)
|
||||
if contract_id:
|
||||
if contract_id.lease_contract_id.ele_price > 0:
|
||||
unit = contract_id.lease_contract_id.ele_price
|
||||
if valid.contract_id.id:
|
||||
electric_id = self.env['property.electric.fee.line'].search([
|
||||
('property_meter_archives_id.name', '=', '950404861125'),
|
||||
('contract_id', '=', valid.contract_id.id),
|
||||
])
|
||||
if electric_id:
|
||||
if electric_id.unit_price > 0:
|
||||
unit = electric_id.unit_price
|
||||
line_loss = electric_id.line_loss if electric_id.line_loss > 0 else self.line_loss
|
||||
else:
|
||||
unit = self.price
|
||||
line_loss = self.line_loss
|
||||
else:
|
||||
unit = self.price
|
||||
line_loss = self.line_loss
|
||||
else:
|
||||
unit = self.price
|
||||
line_loss = self.line_loss
|
||||
else:
|
||||
unit = 0
|
||||
line_loss = 0
|
||||
|
||||
valid.write({
|
||||
'unit': unit,
|
||||
'meter_date': self.price_date,
|
||||
'line_loss': self.line_loss
|
||||
'line_loss': line_loss
|
||||
})
|
||||
|
||||
self.env['hydropower.logs'].create({
|
||||
'meter_type': 'electric',
|
||||
'logs_date': self.price_date,
|
||||
'price': self.price,
|
||||
'line_loss': self.line_loss,
|
||||
'line_loss':self.line_loss,
|
||||
})
|
||||
|
||||
|
||||
|
||||
@@ -99,28 +99,6 @@ class PropertyStatementsWizard(models.Model):
|
||||
elif original_amount:
|
||||
self.env['property.bank.statements'].create(bank_data)
|
||||
|
||||
def _handle_contract_penalty(self, record):
|
||||
'''
|
||||
处理合同违约金
|
||||
:param record: property.bank.statements 记录
|
||||
:return:
|
||||
'''
|
||||
for contract_id in record.contract_ids:
|
||||
receivable_id = self.env['property.accounts.receivable'].search([('contract_id', '=', contract_id.id)])
|
||||
if receivable_id:
|
||||
dt = datetime.strptime(str(record.start_time), '%Y-%m-%d %H:%M:%S').date() # 流水交易时间
|
||||
due = datetime.strptime(str(receivable_id.due_date), '%Y-%m-%d').date() + relativedelta(months=1, day=1) # 应收日期
|
||||
# 判断是否违约
|
||||
if receivable_id.submitted and not receivable_id.is_reconciliation or not receivable_id.is_suspend:
|
||||
original_amount = (due - dt).days * receivable_id.original_amount * int(receivable_id.percentage_liquidated_damages.name)
|
||||
self.env['property.penalty.list'].create({
|
||||
'contract_id': contract_id.id,
|
||||
'property_id': contract_id.lease_ids[0].address_id.id,
|
||||
'lessee_id': contract_id.lessee_id.id,
|
||||
'original_amount': original_amount
|
||||
})
|
||||
receivable_id.write({'penalty':original_amount})
|
||||
receivable_id.is_reconciliation = True
|
||||
|
||||
def classify_by_last_four(self, input_str):
|
||||
if not isinstance(input_str, str) or len(input_str) < 4:
|
||||
|
||||
@@ -29,28 +29,31 @@ class WaterPriceWizard(models.TransientModel):
|
||||
])
|
||||
for valid in valid_contract_lines:
|
||||
if valid.water_id.type == 'fees':
|
||||
if valid.yuthon_property_ids:
|
||||
contract_id = self.env['property.contract.line'].search([
|
||||
('yuthon_property_id', '=', valid.yuthon_property_ids[0].id),
|
||||
('start_time', '<=', self.price_date),
|
||||
('end_date', '>=', self.price_date),
|
||||
], limit=1)
|
||||
if contract_id:
|
||||
if contract_id.lease_contract_id.water_price > 0:
|
||||
unit = contract_id.lease_contract_id.water_price
|
||||
if valid.contract_id.id:
|
||||
water_id = self.env['property.water.fee.line'].search([
|
||||
('property_meter_water_id', '=', valid.water_id.id),
|
||||
])
|
||||
if water_id:
|
||||
if water_id.unit_price > 0:
|
||||
unit = water_id.unit_price
|
||||
line_loss = water_id.line_loss if water_id.line_loss > 0 else self.line_loss
|
||||
else:
|
||||
unit = self.price
|
||||
line_loss = self.line_loss
|
||||
else:
|
||||
unit = self.price
|
||||
line_loss = self.line_loss
|
||||
else:
|
||||
unit = self.price
|
||||
line_loss = self.line_loss
|
||||
else:
|
||||
unit = 0
|
||||
line_loss = 0
|
||||
|
||||
valid.write({
|
||||
'unit': unit,
|
||||
'meter_date': self.price_date,
|
||||
'line_loss': self.line_loss
|
||||
'line_loss': line_loss,
|
||||
})
|
||||
|
||||
self.env['hydropower.logs'].create({
|
||||
|
||||
@@ -93,6 +93,7 @@ class PropertyLeaseContract(models.Model):
|
||||
_rec_name = 'contract_code'
|
||||
|
||||
property_name = fields.Char(string='物业信息')
|
||||
version = fields.Char(string="合同版本", default="V1.0")
|
||||
code = fields.Char(string="流水号", default=lambda self: self.env['ir.sequence'].next_by_code('property_lease_contract_code'))
|
||||
admin_id = fields.Many2one('res.users', string="管理员", compute="_compute_admin_id", store=True)
|
||||
tenure_type = fields.Selection([('self', '自有'), ('agency', '代管')], string='权属类型', compute="_compute_admin_id", store=True)
|
||||
@@ -191,12 +192,10 @@ class PropertyLeaseContract(models.Model):
|
||||
use_address = fields.Char(string="财务专用地址")
|
||||
not_tax_amount = fields.Float(string="不含税价")
|
||||
tax = fields.Float(string="税金")
|
||||
is_water = fields.Boolean(string="是否有水费", compute='_compute_lease_ids')
|
||||
is_electricity = fields.Boolean(string="是否有电费", compute='_compute_lease_ids')
|
||||
is_water = fields.Boolean(string="是否有水费")
|
||||
is_electricity = fields.Boolean(string="是否有电费")
|
||||
is_manage = fields.Boolean(string="是否有管理费", compute='compute_is_manage')
|
||||
miscellaneous = fields.Text(string="其他约定")
|
||||
water_price = fields.Float(string="水费单价")
|
||||
ele_price = fields.Float(string="电费单价")
|
||||
number = fields.Integer(string="次数", default=0)
|
||||
total_area = fields.Float(string="总面积", digits=(16, 4))
|
||||
not_received = fields.Float(string="未收", compute="_compute_contract_count")
|
||||
@@ -219,8 +218,8 @@ class PropertyLeaseContract(models.Model):
|
||||
ele_breakdown_ids = fields.One2many('property.ele.breakdown.line', 'breakdown_id', string="物业电费明细行")
|
||||
management_breakdown_ids = fields.One2many('property.management.breakdown.line', 'breakdown_id', string="物业管理费明细行")
|
||||
|
||||
water_fee_ids = fields.One2many('property.water.fee.line', 'contract_id', string="物业水表明细行", compute='_compute_lease_ids', store=True)
|
||||
electricity_fee_ids = fields.One2many('property.electric.fee.line', 'contract_id', string="物业电表明细行", compute='_compute_lease_ids', store=True)
|
||||
water_fee_ids = fields.One2many('property.water.fee.line', 'contract_id', string="物业水表明细行")
|
||||
electricity_fee_ids = fields.One2many('property.electric.fee.line', 'contract_id', string="物业电表明细行")
|
||||
mange_fee_ids = fields.One2many('property.manage.fee.line', 'contract_id', string="物业管理费明细行", store=True) # 不需要
|
||||
other_ids = fields.One2many('property.other.fee.line', 'other_id', string="其他费用明细行")
|
||||
lease_bank_ids = fields.One2many('property.bank.line', 'contract_id', string="承租方账户明细行")
|
||||
@@ -478,10 +477,10 @@ class PropertyLeaseContract(models.Model):
|
||||
self._context.get('active_ids', self._context.get('active_id')))
|
||||
for rec in contract_ids:
|
||||
if rec.lease_ids:
|
||||
rec.admin_id = rec.lease_ids[0].admin_line_id.id
|
||||
rec.onchange_lease_ids()
|
||||
|
||||
@api.depends("lease_ids")
|
||||
def _compute_lease_ids(self):
|
||||
@api.onchange("lease_ids")
|
||||
def onchange_lease_ids(self):
|
||||
for rec in self:
|
||||
# 初始化值
|
||||
rec.is_water = False
|
||||
@@ -519,6 +518,7 @@ class PropertyLeaseContract(models.Model):
|
||||
'contract_id': rec.id,
|
||||
'property_meter_archives_id': meter.property_meter_archives_id.id,
|
||||
}])
|
||||
|
||||
rec.is_water = bool(water_fee_values)
|
||||
rec.is_electricity = bool(electricity_fee_values)
|
||||
if water_fee_values:
|
||||
@@ -1511,6 +1511,8 @@ class PropertyLeaseContract(models.Model):
|
||||
existing_records = self.search([
|
||||
('id', '!=', record.id),
|
||||
('contract_code', '!=', False),
|
||||
('version', '=', record.version),
|
||||
('contract_type', '=', record.contract_type),
|
||||
])
|
||||
for existing in existing_records:
|
||||
if self._normalize_contract_code(existing.contract_code) == normalized_code:
|
||||
@@ -1673,8 +1675,7 @@ class PropertyLeaseContract(models.Model):
|
||||
contract_id.write({
|
||||
'lease_ids': lease_list,
|
||||
'other_ids': other_list,})
|
||||
# 'management_list_ids':management_list,})
|
||||
|
||||
contract_id.onchange_lease_ids()
|
||||
return {
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'display_notification',
|
||||
@@ -1867,7 +1868,7 @@ class PropertyLeaseContract(models.Model):
|
||||
'name': '续期合同',
|
||||
'res_model': 'property.lease.contract',
|
||||
'view_mode': 'form',
|
||||
'res_id': new_contract.id, # 指定新合同的ID
|
||||
'res_id': new_contract.id,
|
||||
'target': 'current',
|
||||
}
|
||||
|
||||
@@ -2047,7 +2048,7 @@ class PropertyManagementBreakdownLine(models.Model):
|
||||
|
||||
class PropertyWaterFeeLine(models.Model):
|
||||
_name = 'property.water.fee.line'
|
||||
_description = '物业水费明细行'
|
||||
_description = '物业水表库明细行'
|
||||
|
||||
contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批")
|
||||
property_meter_water_id = fields.Many2one('property.meter.water', string="水表库")
|
||||
@@ -2055,12 +2056,14 @@ class PropertyWaterFeeLine(models.Model):
|
||||
unit_number = fields.Char(related='property_meter_water_id.unit_number', string="单元编号/用途", store=True)
|
||||
start_date = fields.Date(related='contract_id.term_start_time', string="开始日期")
|
||||
end_date = fields.Date(related='contract_id.term_end_time', string="结束日期")
|
||||
unit_price = fields.Float(string='固定单价', digits=(16, 4))
|
||||
line_loss = fields.Float(string='线损')
|
||||
epitope_values_id = fields.Many2one(related='property_meter_water_id.epitope_values_id', string="表位置")
|
||||
|
||||
|
||||
class PropertyElectricFeeLine(models.Model):
|
||||
_name = 'property.electric.fee.line'
|
||||
_description = '物业电费明细行'
|
||||
_description = '物业电表信息明细行'
|
||||
|
||||
contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批")
|
||||
property_meter_archives_id = fields.Many2one('property.meter.archives', string="电表编号")
|
||||
@@ -2068,6 +2071,8 @@ class PropertyElectricFeeLine(models.Model):
|
||||
unit_number = fields.Char(related='property_meter_archives_id.unit_number', string="单元编号/用途", store=True)
|
||||
start_date = fields.Date(related='contract_id.term_start_time', string="开始日期")
|
||||
end_date = fields.Date(related='contract_id.term_end_time', string="结束日期")
|
||||
unit_price = fields.Float(string='固定单价', digits=(16, 4))
|
||||
line_loss = fields.Float(string='线损')
|
||||
epitope_values_id = fields.Many2one(related='property_meter_archives_id.epitope_values_id', string="表位置")
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class PropertyLeaseRenewal(models.Model):
|
||||
company_id = fields.Many2one(related='user_id.company_id', string="公司")
|
||||
code = fields.Char(string="编号",
|
||||
default=lambda self: self.env['ir.sequence'].next_by_code('property_lease_renewal_code'))
|
||||
renewal_type = fields.Selection([('early_checkout', '提前退租'), ('lease', '承租方变更')], string='变更类型')
|
||||
renewal_type = fields.Selection([('early_checkout', '提前退租'), ('lease', '承租方变更'), ('agreement','补充协议')], string='变更类型')
|
||||
urgency_level = fields.Selection([('normal', '普件'), ('urgent', '急件'), ('emergency', '特急件')], string='紧急度',
|
||||
default='normal')
|
||||
def _get_default_name_title(self):
|
||||
@@ -80,9 +80,54 @@ class PropertyLeaseRenewal(models.Model):
|
||||
'rent': rec.contract_id.rent,
|
||||
}])
|
||||
lessee_id.write({'property_contract_ids': property_contract_list})
|
||||
else:
|
||||
elif rec.renewal_type == 'early_checkout':
|
||||
rec.contract_id.write({
|
||||
'actual_end_time': rec.early_quitting_date})
|
||||
else:
|
||||
version_str = rec.contract_id.version.lstrip('V')
|
||||
main_version = version_str.split('.')[0]
|
||||
new_main_version = int(main_version) + 1
|
||||
new_version = f"V{new_main_version}.0"
|
||||
new_contract = rec.contract_id.with_context(skip_contract_code_check=True).copy()
|
||||
new_contract.write({
|
||||
'version': new_version
|
||||
})
|
||||
water_lines = self.env['property.water.fee.line'].search([
|
||||
('contract_id', '=', rec.contract_id.id)
|
||||
])
|
||||
for line in water_lines:
|
||||
line.copy({'contract_id': new_contract.id})
|
||||
# 复制电费明细行
|
||||
electric_lines = self.env['property.electric.fee.line'].search([
|
||||
('contract_id', '=', rec.contract_id.id)
|
||||
])
|
||||
for line in electric_lines:
|
||||
line.copy({'contract_id': new_contract.id})
|
||||
# 复制物业管理费明细行
|
||||
manage_lines = self.env['property.manage.fee.line'].search([
|
||||
('contract_id', '=', rec.contract_id.id)
|
||||
])
|
||||
for line in manage_lines:
|
||||
line.copy({'contract_id': new_contract.id})
|
||||
# 复制其他费用明细行
|
||||
other_lines = self.env['property.other.fee.line'].search([
|
||||
('other_id', '=', rec.contract_id.id)
|
||||
])
|
||||
for line in other_lines:
|
||||
line.copy({'other_id': new_contract.id})
|
||||
# 复制子合同明细
|
||||
subset_lines = self.env['property.subset.contract'].search([
|
||||
('subset_id', '=', rec.contract_id.id)
|
||||
])
|
||||
for line in subset_lines:
|
||||
line.copy({'subset_id': new_contract.id})
|
||||
lease_lines = self.env['property.lease.contract.line'].search([
|
||||
('lease_id', '=', rec.contract_id.id)
|
||||
])
|
||||
for line in lease_lines:
|
||||
line.copy({'lease_id': new_contract.id})
|
||||
new_contract._compute_name()
|
||||
|
||||
rec.contract_id.get_property_contract_time()
|
||||
rec.hide = True
|
||||
|
||||
|
||||
@@ -113,4 +113,6 @@ access_penalty_pay_line, penalty_pay_line,model_penalty_pay_line,base.group_user
|
||||
access_contract_accounts_receivable, contract_accounts_receivable,model_contract_accounts_receivable,base.group_user,1,1,1,1
|
||||
access_property_water_breakdown_line, property_water_breakdown_line,model_property_water_breakdown_line,base.group_user,1,1,1,1
|
||||
access_property_ele_breakdown_line, property_ele_breakdown_line,model_property_ele_breakdown_line,base.group_user,1,1,1,1
|
||||
access_property_management_breakdown_line, property_management_breakdown_line,model_property_management_breakdown_line,base.group_user,1,1,1,1
|
||||
access_property_management_breakdown_line, property_management_breakdown_line,model_property_management_breakdown_line,base.group_user,1,1,1,1
|
||||
access_property_electric_fee_line,property_electric_fee_line,model_property_electric_fee_line,base.group_user,1,1,1,1
|
||||
access_property_water_fee_line,property_water_fee_line,model_property_water_fee_line,base.group_user,1,1,1,1
|
||||
|
||||
|
@@ -65,6 +65,7 @@
|
||||
<div class="d-inline-flex w-100">
|
||||
<field name="contract_code" class="me-2" style="max-width: 12rem;" string="合同编号"/>
|
||||
<field name="contract_type" class="me-2" style="max-width: 7rem;" force_save="1"/>
|
||||
<field name="version" class="me-2" style="max-width: 7rem;" force_save="1"/>
|
||||
</div>
|
||||
</group>
|
||||
<group>
|
||||
@@ -249,8 +250,6 @@
|
||||
</group>
|
||||
<group>
|
||||
<field name="miscellaneous"/>
|
||||
<field name="water_price" invisible="contract_sort != 'property'"/>
|
||||
<field name="ele_price" invisible="contract_sort != 'property'"/>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="租金明细" invisible="(state in ['分管领导', '总经理']) and (not work_end)">
|
||||
@@ -279,13 +278,15 @@
|
||||
<page string="水表明细" invisible="not is_water">
|
||||
<field name="water_fee_ids" string=" ">
|
||||
<tree editable="bottom">
|
||||
<field name="contract_id" column_invisible="1"/>
|
||||
<field name="contract_id" column_invisible="1"/>
|
||||
<field name="epitope_values_id"/>
|
||||
<field name="unit_number"/>
|
||||
<field name="property_meter_water_id" options="{'no_open': True}"/>
|
||||
<field name="rate"/>
|
||||
<field name="unit_number"/>
|
||||
<field name="line_loss"/>
|
||||
<field name="unit_price"/>
|
||||
<field name="start_date"/>
|
||||
<field name="end_date"/>
|
||||
<field name="epitope_values_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
@@ -293,12 +294,14 @@
|
||||
<field name="electricity_fee_ids" string=" ">
|
||||
<tree editable="bottom">
|
||||
<field name="contract_id" column_invisible="1"/>
|
||||
<field name="epitope_values_id"/>
|
||||
<field name="unit_number"/>
|
||||
<field name="property_meter_archives_id" options="{'no_open': True}"/>
|
||||
<field name="rate"/>
|
||||
<field name="unit_number"/>
|
||||
<field name="line_loss"/>
|
||||
<field name="unit_price"/>
|
||||
<field name="start_date"/>
|
||||
<field name="end_date"/>
|
||||
<field name="epitope_values_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
@@ -464,6 +467,7 @@
|
||||
<div class="d-inline-flex w-100">
|
||||
<field name="contract_code" class="me-2" style="max-width: 12rem;" string="合同编号"/>
|
||||
<field name="contract_type" class="me-2" style="max-width: 7rem;" force_save="1"/>
|
||||
<field name="version" class="me-2" style="max-width: 7rem;" force_save="1"/>
|
||||
</div>
|
||||
</group>
|
||||
<group>
|
||||
@@ -663,8 +667,6 @@
|
||||
</group>
|
||||
<group>
|
||||
<field name="miscellaneous"/>
|
||||
<field name="water_price" invisible="contract_sort != 'property'"/>
|
||||
<field name="ele_price" invisible="contract_sort != 'property'"/>
|
||||
</group>
|
||||
<notebook class="o_collapsible_notebook">
|
||||
<page string="租金明细" invisible="contract_sort != 'property'">
|
||||
@@ -749,12 +751,14 @@
|
||||
<field name="water_fee_ids" string=" ">
|
||||
<tree editable="bottom">|
|
||||
<field name="contract_id" column_invisible="1"/>
|
||||
<field name="epitope_values_id"/>
|
||||
<field name="unit_number"/>
|
||||
<field name="property_meter_water_id" options="{'no_open': True}"/>
|
||||
<field name="rate"/>
|
||||
<field name="unit_number"/>
|
||||
<field name="line_loss"/>
|
||||
<field name="unit_price"/>
|
||||
<field name="start_date"/>
|
||||
<field name="end_date"/>
|
||||
<field name="epitope_values_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
@@ -762,12 +766,14 @@
|
||||
<field name="electricity_fee_ids" string=" ">
|
||||
<tree editable="bottom">
|
||||
<field name="contract_id" column_invisible="1"/>
|
||||
<field name="epitope_values_id"/>
|
||||
<field name="unit_number"/>
|
||||
<field name="property_meter_archives_id" options="{'no_open': True}"/>
|
||||
<field name="rate"/>
|
||||
<field name="unit_number"/>
|
||||
<field name="line_loss"/>
|
||||
<field name="unit_price"/>
|
||||
<field name="start_date"/>
|
||||
<field name="end_date"/>
|
||||
<field name="epitope_values_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
|
||||
@@ -44,8 +44,9 @@
|
||||
<field name="company_id" invisible="1"/>
|
||||
<field name="department_id" invisible="1"/>
|
||||
<field name="work_end" invisible="1"/>
|
||||
<field name="contract_id" invisible="renewal_type != 'agreement'"/>
|
||||
</group>
|
||||
<group string="原租赁合同信息" col="3">
|
||||
<group string="原租赁合同信息" col="3" invisible="renewal_type == 'agreement'">
|
||||
<group>
|
||||
<field name="hide" invisible="1"/>
|
||||
<field name="lessee_id" invisible="hide"/>
|
||||
@@ -67,7 +68,7 @@
|
||||
<field name="property_name"/>
|
||||
</group>
|
||||
</group>
|
||||
<group string="变更信息" col="3">
|
||||
<group string="变更信息" col="3" invisible="renewal_type == 'agreement'">
|
||||
<group>
|
||||
<field name="early_quitting_date" invisible="renewal_type != 'early_checkout'"/>
|
||||
<field name="new_lessee_name" invisible="renewal_type != 'lease'"/>
|
||||
|
||||
Reference in New Issue
Block a user