diff --git a/yuthon_property/models/property_meter_archives.py b/yuthon_property/models/property_meter_archives.py
index 0739e77ea..6e866dfe5 100644
--- a/yuthon_property/models/property_meter_archives.py
+++ b/yuthon_property/models/property_meter_archives.py
@@ -10,7 +10,6 @@ class PropertyMeterArchives(models.Model):
name = fields.Char(string='仪表编号')
unit_number = fields.Char(string='单元编号')
installation_location = fields.Char(string='安装位置')
- device_number = fields.Char(string='设备编号')
is_state = fields.Boolean(string='是否启用')
type = fields.Selection([('public', '公共'), ('fees', '收费')], string='类型')
gauge_magnification = fields.Float(string='仪表倍率', default=1)
@@ -24,6 +23,7 @@ class PropertyMeterArchives(models.Model):
last_meter = fields.Date(string='上次抄表日期')
current_meter = fields.Float(string='本次用量', tracking=True)
ratio = fields.Float(string='倍率')
+ unit = fields.Float(string='单价')
archives_state = fields.Selection([('stop', '停用'), ('use', '正常'), ('rent', '出租')], string='状态', compute='_compute_archives_state', store=True, default='use')
dosage = fields.Float(string='用量')
is_push = fields.Boolean(string='已推送')
diff --git a/yuthon_property/models/property_meter_water.py b/yuthon_property/models/property_meter_water.py
index c21cd7b52..7a789b787 100644
--- a/yuthon_property/models/property_meter_water.py
+++ b/yuthon_property/models/property_meter_water.py
@@ -9,7 +9,6 @@ class PropertyMeterWater(models.Model):
name = fields.Char(string='仪表编号')
unit_number = fields.Char(string='单元编号')
installation_location = fields.Char(string='安装位置')
- device_number = fields.Char(string='设备编号')
is_state = fields.Boolean(string='是否启用')
type = fields.Selection([('public', '公共'), ('fees', '收费')], string='类型')
gauge_magnification = fields.Float(string='仪表倍率', default=1)
@@ -21,6 +20,7 @@ class PropertyMeterWater(models.Model):
meter_date = fields.Date(string='抄表年月')
last_dosage = fields.Float(string='上次用量')
last_meter = fields.Date(string='上次抄表日期')
+ unit = fields.Float(string='单价')
current_meter = fields.Float(string='本次用量', tracking=True)
ratio = fields.Float(string='倍率')
dosage = fields.Float(string='用量')
diff --git a/yuthon_property/models/property_tariff_list.py b/yuthon_property/models/property_tariff_list.py
index 6074b515a..c03bb21b6 100644
--- a/yuthon_property/models/property_tariff_list.py
+++ b/yuthon_property/models/property_tariff_list.py
@@ -13,19 +13,27 @@ class PropertyTariffList(models.Model):
due_date = fields.Date(string='应收日期')
tariff_meter_reading = fields.Float(string='电费读数')
fee_id = fields.Many2one('yuthon.water.setting', string="收费标准")
- original_amount = fields.Float(string='金额')
+ original_amount = fields.Float(string='金额', compute='_compute_original_amount', store=True)
deduction_amount = fields.Float(string='减免金额')
remarks = fields.Text(string='备注')
is_cancel = fields.Boolean(string='作废')
is_red = fields.Boolean(string='红冲')
+ dosage = fields.Float(string='用量')
+ unit = fields.Float(string='单价')
red_date = fields.Date(string='红冲日期')
fee_status = fields.Selection([('unpaid', '未收'), ('paid', '已收')], string='收费状态')
is_invoice = fields.Boolean(string='开票')
is_suspend = fields.Boolean(string='挂起')
create_time = fields.Datetime(string='创建时间')
write_time = fields.Datetime(string='最后修改时间')
+ name = fields.Char(string='仪表编号')
is_push = fields.Boolean(string='是否推送')
+ @api.depends('dosage', 'unit')
+ def _compute_original_amount(self):
+ for record in self:
+ record.original_amount = record.dosage * record.unit
+
def get_no_read_count(self):
return self.env['property.tariff.list'].search_count([('is_push', '=', False)])
diff --git a/yuthon_property/models/property_water_list.py b/yuthon_property/models/property_water_list.py
index a15a51f60..172a47e2d 100644
--- a/yuthon_property/models/property_water_list.py
+++ b/yuthon_property/models/property_water_list.py
@@ -13,12 +13,15 @@ class PropertyWaterList(models.Model):
due_date = fields.Date(string='应收日期')
water_meter_reading = fields.Float(string='水表读数')
fee_id = fields.Many2one('yuthon.water.setting', string="水费标准")
- original_amount = fields.Float(string='金额')
+ original_amount = fields.Float(string='金额', compute='_compute_original_amount', store=True)
deduction_amount = fields.Float(string='减免金额')
remarks = fields.Text(string='备注')
+ name = fields.Char(string='仪表编号')
is_cancel = fields.Boolean(string='作废')
is_red = fields.Boolean(string='红冲')
red_date = fields.Date(string='红冲日期')
+ dosage = fields.Float(string='用量')
+ unit = fields.Float(string='单价')
fee_status = fields.Selection([('unpaid', '未收'), ('paid', '已收')], string='收费状态')
is_invoice = fields.Boolean(string='开票')
is_suspend = fields.Boolean(string='挂起')
@@ -26,6 +29,11 @@ class PropertyWaterList(models.Model):
write_time = fields.Datetime(string='最后修改时间')
is_push = fields.Boolean(string='是否推送')
+ @api.depends('dosage', 'unit')
+ def _compute_original_amount(self):
+ for record in self:
+ record.original_amount = record.dosage * record.unit
+
def get_no_read_count(self):
return self.search_count([('is_push', '=', False)])
diff --git a/yuthon_property/views/property_meter_archives_views.xml b/yuthon_property/views/property_meter_archives_views.xml
index 057739140..8f8828ac1 100644
--- a/yuthon_property/views/property_meter_archives_views.xml
+++ b/yuthon_property/views/property_meter_archives_views.xml
@@ -18,7 +18,6 @@
-
@@ -45,6 +44,7 @@
+
diff --git a/yuthon_property/views/property_meter_water_views.xml b/yuthon_property/views/property_meter_water_views.xml
index 3c30e536b..55db218fe 100644
--- a/yuthon_property/views/property_meter_water_views.xml
+++ b/yuthon_property/views/property_meter_water_views.xml
@@ -19,7 +19,6 @@
-
@@ -45,6 +44,7 @@
+
diff --git a/yuthon_property/views/property_tariff_list_views.xml b/yuthon_property/views/property_tariff_list_views.xml
index 08b1aa5f2..c2305d09f 100644
--- a/yuthon_property/views/property_tariff_list_views.xml
+++ b/yuthon_property/views/property_tariff_list_views.xml
@@ -5,6 +5,7 @@
property.tariff.list
+
@@ -12,6 +13,8 @@
+
+
diff --git a/yuthon_property/views/property_water_list_views.xml b/yuthon_property/views/property_water_list_views.xml
index 6d5ce1865..c8368505d 100644
--- a/yuthon_property/views/property_water_list_views.xml
+++ b/yuthon_property/views/property_water_list_views.xml
@@ -5,6 +5,7 @@
property.water.list
+
@@ -12,6 +13,8 @@
+
+
diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py
index b8279f4a5..980d6daf8 100644
--- a/yuthon_property_approval/models/property_lease_contract.py
+++ b/yuthon_property_approval/models/property_lease_contract.py
@@ -256,7 +256,6 @@ class PropertyLeaseContract(models.Model):
if lease.address_id:
if lease.address_id.is_meter:
rec.is_water = True
- # 获取未拆除的水表(demolition_date 为空或大于今天)
active_water_meters = lease.address_id.water_meter_ids.filtered(
lambda m: not m.demolition_date or m.demolition_date > fields.Date.today()
)
diff --git a/yuthon_property_approval/views/inherit_yuthon_property_views.xml b/yuthon_property_approval/views/inherit_yuthon_property_views.xml
index e39818fb6..02bcb6b03 100644
--- a/yuthon_property_approval/views/inherit_yuthon_property_views.xml
+++ b/yuthon_property_approval/views/inherit_yuthon_property_views.xml
@@ -130,6 +130,8 @@
+
+
@@ -139,7 +141,7 @@
property.deposit.list
tree,search
[('is_push', '=', False)]
- {'group_by': ['admin_id', 'due_date:month']}
+ {'search_default_group_admin_id': True, 'search_default_group_due_date': True}
@@ -152,6 +154,8 @@
+
+
@@ -183,7 +187,7 @@
property.tariff.list
tree
[('is_push', '=', False)]
- {'group_by': ['admin_id', 'due_date:month']}
+ {'search_default_group_admin_id': True, 'search_default_group_due_date': True}
@@ -196,6 +200,8 @@
+
+
@@ -227,7 +233,7 @@
property.water.list
tree,form,search
[('is_push', '=', False)]
- {'group_by': ['admin_id', 'due_date:month']}
+ {'search_default_group_admin_id': True, 'search_default_group_due_date': True}
@@ -253,6 +259,8 @@
+
+
@@ -271,7 +279,7 @@
property.management.list
tree,search
[('is_push', '=', False)]
- {'group_by': ['admin_id', 'due_date:month']}
+ {'search_default_group_admin_id': True, 'search_default_group_due_date': True}
diff --git a/yuthon_property_approval/wizard/property_rental_wizard.py b/yuthon_property_approval/wizard/property_rental_wizard.py
index 3138a63cf..f70a9d016 100644
--- a/yuthon_property_approval/wizard/property_rental_wizard.py
+++ b/yuthon_property_approval/wizard/property_rental_wizard.py
@@ -49,6 +49,62 @@ class PropertyRentalWizard(models.Model):
"month": self.select_month,
})
+ def create_water_fee_list(self, record):
+ """封装创建水费记录的逻辑"""
+ for lease in record.lease_ids:
+ if lease.address_id and lease.address_id.is_meter:
+ active_water_meters = lease.address_id.water_meter_ids.filtered(
+ lambda m: (not m.demolition_date or m.demolition_date > fields.Date.today())
+ and m.property_meter_water_id.water_state in ('use', 'rent')
+ )
+ remarks = self._get_date_range_remark(record.actual_start_time, record.actual_end_time)
+ for meter in active_water_meters:
+ water_list = self.env['property.water.list'].search(
+ [('name', '=', meter.property_meter_water_id.name)], limit=1
+ )
+ values = {
+ 'contract_id': record.id,
+ 'property_id': lease.address_id.id,
+ 'lessee_id': record.lessee_id.id,
+ 'dosage': meter.property_meter_water_id.current_meter,
+ 'name': meter.property_meter_water_id.name,
+ 'unit': meter.property_meter_water_id.unit,
+ 'due_date': meter.property_meter_water_id.meter_date if meter.property_meter_water_id.meter_date else None,
+ 'remarks':remarks
+ }
+ if water_list:
+ water_list.write(values)
+ else:
+ self.env['property.water.list'].create(values)
+
+ def create_ele_fee_list(self, record):
+ """封装创建电费记录的逻辑 """
+ for lease in record.lease_ids:
+ if lease.address_id.is_electricity_meter:
+ active_electric_meters = lease.address_id.energy_meter_ids.filtered(
+ lambda m: not m.demolition_date or m.demolition_date > fields.Date.today()
+ and m.property_meter_archives_id.archives_state in ('use', 'rent')
+ )
+ remarks = self._get_date_range_remark(record.actual_start_time, record.actual_end_time)
+ for meter in active_electric_meters:
+ tariff_list = self.env['property.tariff.list'].search(
+ [('name', '=', meter.property_meter_archives_id.name)], limit=1
+ )
+ values = {
+ 'contract_id': record.id,
+ 'property_id': lease.address_id.id,
+ 'lessee_id': record.lessee_id.id,
+ 'dosage': meter.property_meter_archives_id.current_meter,
+ 'name': meter.property_meter_archives_id.name,
+ 'unit': meter.property_meter_archives_id.unit,
+ 'remarks':remarks,
+ 'due_date': meter.property_meter_archives_id.meter_date if meter.property_meter_archives_id.meter_date else None,
+ }
+ if tariff_list:
+ tariff_list.write(values)
+ else:
+ self.env['property.tariff.list'].create(values)
+
def create_deposit_list(self, record):
"""封装创建押金记录的逻辑 - 根据合同中的多种押金类型创建多条记录"""
property_id = record.lease_ids[0].address_id.id if record.lease_ids else None
@@ -79,7 +135,7 @@ class PropertyRentalWizard(models.Model):
"original_amount": amount,
})
- def create_management_list(self, record,start_date):
+ def create_management_list(self, record, start_date):
"""封装创建管理费记录的逻辑"""
first_day_of_month = start_date.replace(day=1)
last_day_of_month = first_day_of_month + relativedelta(months=1) - timedelta(days=1)
@@ -175,5 +231,18 @@ class PropertyRentalWizard(models.Model):
for rent_id in record.breakdown_ids:
self.process_rent_record(record, rent_id, date_field_year_month, days, period_month, multiplier, is_year)
self.create_deposit_list(record)
+ # 生成水电费列表
+ self.create_water_fee_list(record)
+ self.create_ele_fee_list(record)
+ def _get_date_range_remark(self, start_date, end_date):
+ """生成日期区间备注(格式:YYYYMMDD-YYYYMMDD)"""
+ # 处理开始日期:如果日大于15,则取16日,否则取1日
+ start_day = 16 if start_date.day > 15 else 1
+ start_date_str = start_date.replace(day=start_day).strftime('%Y%m%d')
+ # 处理结束日期:如果日小于15,则取当日,否则取15日
+ end_day = end_date.day if end_date.day < 15 else 15
+ end_date_str = end_date.replace(day=end_day).strftime('%Y%m%d')
+
+ return f"{start_date_str}-{end_date_str}"
\ No newline at end of file
diff --git a/yuthon_salary/wizard/salary_compute_wizard.py b/yuthon_salary/wizard/salary_compute_wizard.py
index 5e34444b8..7a01cb069 100644
--- a/yuthon_salary/wizard/salary_compute_wizard.py
+++ b/yuthon_salary/wizard/salary_compute_wizard.py
@@ -54,6 +54,10 @@ class SalaryComputeWizard(models.Model):
])
self.employee_ids = [(6, 0, employees.ids)]
self.employee_number = len(self.employee_ids)
+ for employee_id in self.employee_ids.ids:
+ employee = self.env['hr.employee'].browse(employee_id)
+ # 打印员工姓名
+ print(f"员工姓名: {employee.name}")
@api.onchange('employee_ids')
def onchange_employee_ids(self):
@@ -194,7 +198,7 @@ class SalaryComputeWizard(models.Model):
# 判断是否为入职当月
if contract_year == self.select_year and contract_month == self.select_time:
result = 0 # 入职当月住房公积金为0
- elif field_name == 'b_year': # 新增企业年金计算
+ elif field_name == 'b_year':
# 获取合同转正日期的年份和月份
if contract_end_date: # 确保转正日期存在
contract_end_year = str(contract_end_date.year)