diff --git a/yuthon_property_approval/__manifest__.py b/yuthon_property_approval/__manifest__.py
index 43c62641d..077342503 100644
--- a/yuthon_property_approval/__manifest__.py
+++ b/yuthon_property_approval/__manifest__.py
@@ -12,6 +12,7 @@
'data/property_contract_time.xml',
'security/ir.model.access.csv',
'views/inherit_rent_list_views.xml',
+ 'views/inherit_property_management_list.xml',
'views/inherit_property_deposit_list.xml',
'views/property_billing_confirmation.xml',
'views/property_approval_views.xml',
diff --git a/yuthon_property_approval/models/property_lease_contract.py b/yuthon_property_approval/models/property_lease_contract.py
index 3ae2acd8c..44800de78 100644
--- a/yuthon_property_approval/models/property_lease_contract.py
+++ b/yuthon_property_approval/models/property_lease_contract.py
@@ -20,9 +20,10 @@ class PropertyDepositList(models.Model):
_inherit = 'property.deposit.list'
contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批")
- deposit = fields.Float(related='contract_id.deposit',string="押金/履约保证金", store=True)
- rent = fields.Float(related='contract_id.rent',string="租金", store=True)
- percentage_damages = fields.Float(related='contract_id.percentage_damages',string="违约金", store=True)
+ deposit = fields.Float(related='contract_id.deposit', string="押金/履约保证金", store=True)
+ performance_bonds = fields.Float(related='contract_id.performance_bonds', string="经营履约保证金")
+ utility_bills = fields.Float(related='contract_id.utility_bills', string="水电费押金")
+ renovation_deposit = fields.Float(related='contract_id.renovation_deposit', string="装修押金")
aggregate = fields.Float(string="合计", store=True)
@@ -50,6 +51,136 @@ class PropertyBankLine(models.Model):
contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批")
+class PropertyTariffList(models.Model):
+ _inherit = 'property.tariff.list'
+
+ contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批")
+
+
+class PropertyWaterList(models.Model):
+ _inherit = 'property.water.list'
+
+ contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批")
+
+class PropertyElectricReading(models.Model):
+ _inherit = 'property.electric.reading'
+
+ contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批")
+
+ def button_push_electric(self):
+ pass
+
+ def batch_reading_electric(self):
+ pass
+
+
+class PropertyWaterReading(models.Model):
+ _inherit = 'property.water.reading'
+
+ contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批")
+
+ def button_push_water(self):
+ pass
+
+ def batch_reading_water(self):
+ pass
+
+class PropertyMeterArchives(models.Model):
+ _inherit = 'property.meter.archives'
+
+ contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批")
+
+ def batch_contract_association(self):
+ archives_ids = self.env["property.meter.archives"].browse(self._context.get('active_ids', self._context.get('active_id')))
+ for record in archives_ids:
+ if record.yuthon_property_id.id:
+ contract_id = self.env["property.lease.contract.line"].search([('address_id', '=', record.yuthon_property_id.id)], limit=1)
+ if contract_id:
+ record.sudo().write({
+ 'contract_id': contract_id.lease_id.id})
+
+ def button_reading_push(self):
+ for rec in self:
+ rec.write({
+ 'is_push': True,
+ })
+ if rec.is_push:
+ raise UserError("该仪表已经推送,不能重复推送")
+ self.env["property.electric.reading"].create({
+ 'code': rec.name,
+ 'property_id': rec.yuthon_property_id.id if rec.yuthon_property_id else None,
+ 'ratio': rec.gauge_magnification,
+ 'position': rec.unit_number,
+ 'type': rec.type,
+ 'contract_id':rec.contract_id.id
+ })
+
+ def batch_reading_push(self):
+ archives_ids = self.env["property.meter.archives"].browse(self._context.get('active_ids', self._context.get('active_id')))
+ for record in archives_ids:
+ record.write({
+ 'is_push': True,
+ })
+ if record.is_push:
+ raise UserError(f"该{record.name}仪表已经推送,不能重复推送")
+ self.env["property.electric.reading"].create({
+ 'code': record.name,
+ 'property_id': record.yuthon_property_id.id if record.yuthon_property_id else None,
+ 'ratio': record.gauge_magnification,
+ 'position': record.unit_number,
+ 'type': record.type,
+ 'contract_id':record.contract_id.id
+ })
+
+class PropertyMeterWater(models.Model):
+ _inherit = 'property.meter.water'
+
+ contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批")
+
+ def button_reading_water_push(self):
+ for rec in self:
+ rec.write({
+ 'is_push': True,
+ })
+ if rec.is_push:
+ raise UserError(f"该仪表已经推送,不能重复推送")
+ self.env["property.water.reading"].create({
+ 'code': rec.name ,
+ 'property_id': rec.yuthon_property_id.id if rec.yuthon_property_id else None,
+ 'ratio': rec.gauge_magnification,
+ 'position': rec.unit_number ,
+ 'type': rec.type,
+ 'contract_id': rec.contract_id.id
+ })
+
+ def batch_reading_water_push(self):
+ water_ids = self.env["property.meter.water"].browse(self._context.get('active_ids', self._context.get('active_id')))
+ for record in water_ids:
+ record.write({
+ 'is_push': True,
+ })
+ if record.is_push:
+ raise UserError(f"该{record.unit_number}仪表已经推送,不能重复推送")
+ self.env["property.water.reading"].create({
+ 'code': record.name,
+ 'property_id': record.yuthon_property_id.id if record.yuthon_property_id else None,
+ 'ratio': record.gauge_magnification,
+ 'position': record.unit_number,
+ 'type': record.type,
+ 'contract_id': record.contract_id.id
+ })
+
+ def batch_contract_association_water(self):
+ archives_ids = self.env["property.meter.water"].browse(
+ self._context.get('active_ids', self._context.get('active_id')))
+ for record in archives_ids:
+ if record.yuthon_property_id.id:
+ contract_id = self.env["property.lease.contract.line"].search(
+ [('address_id', '=', record.yuthon_property_id.id)], limit=1)
+ if contract_id:
+ record.sudo().write({
+ 'contract_id': contract_id.lease_id.id})
+
class PropertyContractLine(models.Model):
_name = 'property.contract.line'
_description = '物业合同明细行'
diff --git a/yuthon_property_approval/views/inherit_property_deposit_list.xml b/yuthon_property_approval/views/inherit_property_deposit_list.xml
index 3f7408d60..be0cee455 100644
--- a/yuthon_property_approval/views/inherit_property_deposit_list.xml
+++ b/yuthon_property_approval/views/inherit_property_deposit_list.xml
@@ -7,8 +7,9 @@
-
-
+
+
+
diff --git a/yuthon_property_approval/views/inherit_property_management_list.xml b/yuthon_property_approval/views/inherit_property_management_list.xml
new file mode 100644
index 000000000..a96de4169
--- /dev/null
+++ b/yuthon_property_approval/views/inherit_property_management_list.xml
@@ -0,0 +1,17 @@
+
+
+ property.management.list.tree
+ property.management.list
+
+
+
+
+
+
+
+
+ 管理费列表
+ property.management.list
+ tree
+
+
diff --git a/yuthon_property_approval/views/inherit_rent_list_views.xml b/yuthon_property_approval/views/inherit_rent_list_views.xml
index 703f8185a..2f7289e5e 100644
--- a/yuthon_property_approval/views/inherit_rent_list_views.xml
+++ b/yuthon_property_approval/views/inherit_rent_list_views.xml
@@ -26,4 +26,182 @@
[('is_push', '=', False)]
{'search_default_group_contract_id': 1}
+
+ property.deposit.list.tree
+ property.deposit.list
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 押金列表
+ property.deposit.list
+ tree
+
+
+ property.tariff.list.tree
+ property.tariff.list
+
+
+
+
+
+
+
+
+ 电费列表
+ property.tariff.list
+ tree
+
+
+ property.water.list.tree
+ property.water.list
+
+
+
+
+
+
+
+
+ 水费列表
+ property.water.list
+ tree,form,search
+
+
+ property.electric.reading.tree
+ property.electric.reading
+
+
+
+
+
+
+
+
+
+
+
+ 批量推送
+
+
+ code
+ action = model.batch_reading_electric()
+
+
+ 电费抄表任务
+ property.electric.reading
+ tree,form,search
+
+
+ property.water.reading.tree
+ property.water.reading
+
+
+
+
+
+
+
+
+
+
+
+ 批量推送
+
+
+ code
+ action = model.batch_reading_water()
+
+
+ 水费抄表任务
+ property.water.reading
+ tree,form,search
+
+
+ property.meter.archives.tree
+ property.meter.archives
+
+
+
+
+
+
+
+
+ property.meter.archives.tree
+ property.meter.archives
+
+
+
+
+
+
+
+
+ 批量推送
+
+
+ code
+ action = model.batch_reading_push()
+
+
+ 批量关联合同
+
+
+ code
+ action = model.batch_contract_association()
+
+
+ 电表仪表库档案
+ property.meter.archives
+ tree,form
+
+
+ property.meter.water.tree
+ property.meter.water
+
+
+
+
+
+
+
+
+ property.meter.water.tree
+ property.meter.water
+
+
+
+
+
+
+
+
+ 水表仪表库档案
+ property.meter.water
+ tree,form
+
+
+ 批量推送
+
+
+ code
+ action = model.batch_reading_water_push()
+
+
+ 批量关联合同
+
+
+ code
+ action = model.batch_contract_association_water()
+
\ No newline at end of file
diff --git a/yuthon_property_approval/views/property_menu_all.xml b/yuthon_property_approval/views/property_menu_all.xml
index 4388c9bbc..13fc1732d 100644
--- a/yuthon_property_approval/views/property_menu_all.xml
+++ b/yuthon_property_approval/views/property_menu_all.xml
@@ -327,4 +327,40 @@
name="押金列表"
parent="yuthon_property.yuthon_property_fee_management"
action="property_deposit_list_action"/>
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/yuthon_property_approval/wizard/property_rental_wizard.py b/yuthon_property_approval/wizard/property_rental_wizard.py
index bfc718f13..df734e4c6 100644
--- a/yuthon_property_approval/wizard/property_rental_wizard.py
+++ b/yuthon_property_approval/wizard/property_rental_wizard.py
@@ -16,17 +16,77 @@ class PropertyRentalWizard(models.Model):
def create_rent_list(self, record, rent_id, rent_amount, start_date,multiplier):
"""封装创建租金记录的逻辑"""
property_id = record.lease_ids[0].address_id.id if record.lease_ids else None
- self.sudo().env["property.rent.list"].create({
+ first_day_of_month = start_date.replace(day=1)
+ last_day_of_month = first_day_of_month + relativedelta(months=1) - timedelta(days=1)
+ rent_id = self.env['property.rent.list'].search([
+ ('property_id', '=', property_id),
+ ('due_date', '>=', first_day_of_month),
+ ('due_date', '<=', last_day_of_month)
+ ])
+ if not rent_id:
+ self.sudo().env["property.rent.list"].create({
+ "contract_id": record.id,
+ "due_date": start_date,
+ 'multiplier':multiplier,
+ "lessee_id": record.lessee_id.id,
+ "property_id": property_id,
+ "original_amount": rent_amount,
+ "year": self.select_year,
+ "month": self.select_month,
+ })
+ else:
+ rent_id.write({
+ "contract_id": record.id,
+ "due_date": start_date,
+ 'multiplier': multiplier,
+ "lessee_id": record.lessee_id.id,
+ "property_id": property_id,
+ "original_amount": rent_amount,
+ "year": self.select_year,
+ "month": self.select_month,
+ })
+
+ def create_deposit_list(self, record):
+ """封装创建押金记录的逻辑"""
+ property_id = record.lease_ids[0].address_id.id if record.lease_ids else None
+ self.sudo().env["property.deposit.list"].create({
"contract_id": record.id,
- "due_date": start_date,
- 'multiplier':multiplier,
- "lessee_id": record.lessee_id.id,
"property_id": property_id,
- "original_amount": rent_amount,
- "year": self.select_year,
- "month": self.select_month,
})
+ 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)
+ for lease_id in record.lease_ids:
+ property_id = lease_id.address_id
+ management_id = self.env['property.management.list'].search([
+ ('property_id', '=', property_id.id),
+ ('due_date', '>=', first_day_of_month),
+ ('due_date', '<=', last_day_of_month)
+ ])
+ if property_id.message_standard_id:
+ standard_id = property_id.message_standard_id
+ original_amount = property_id.management_area * standard_id.amount
+ if not management_id:
+ self.sudo().env["property.management.list"].create({
+ "contract_id": record.id,
+ "property_id": property_id.id,
+ 'original_amount':original_amount,
+ 'message_standard_id': property_id.message_standard_id.id,
+ 'lessee_id': property_id.lessee_id.id,
+ "due_date":start_date
+ })
+ else:
+ management_id.write({
+ "contract_id": record.id,
+ "property_id": property_id.id,
+ 'original_amount': original_amount,
+ 'message_standard_id': property_id.message_standard_id.id,
+ 'lessee_id': property_id.lessee_id.id,
+ "due_date": start_date
+ })
+
def process_rent_record(self, record, rent_id, date_field_year_month, days, period_month=0, multiplier=1, is_year=0):
"""封装处理租金逻辑,增加 multiplier 参数用于乘法"""
start_date_adj = rent_id.start_data + relativedelta(months=period_month)
@@ -42,15 +102,14 @@ class PropertyRentalWizard(models.Model):
multiplier = rent_id.month_number
adjusted_rent = rent_amount * multiplier
# 调整后的租金
- now_data = datetime.now()
- start_date = now_data.replace(day=start_day)
+ start_date = start_date_adj.replace(day=start_day)
if start_year_month <= date_field_year_month < end_year_month:
self.create_rent_list(record, rent_id, adjusted_rent, start_date,multiplier)
-
+ self.create_management_list(record, start_date)
elif start_year_month <= date_field_year_month <= end_year_month:
if rent_id.end_data.day < days:
self.create_rent_list(record, rent_id, adjusted_rent, rent_id.start_data,multiplier)
-
+ self.create_management_list(record, start_date)
# 尝试处理下一个租金分解
rent_ids = record.breakdown_ids
current_index = rent_ids.ids.index(rent_id.id)
@@ -58,6 +117,7 @@ class PropertyRentalWizard(models.Model):
next_rent_id = rent_ids[current_index + 1]
adjusted_rent_next = ( next_rent_id.period_rent if period_month else next_rent_id.monthly_amount) * multiplier
self.create_rent_list(record, next_rent_id, adjusted_rent_next, next_rent_id.start_data,multiplier)
+ self.create_management_list(record, start_date)
except (IndexError, ValueError):
pass
@@ -71,7 +131,6 @@ class PropertyRentalWizard(models.Model):
def confirm(self):
"""主逻辑入口"""
- self.env["property.rent.list"].search([]).unlink()
records = self.env['property.lease.contract'].search(
[('cycle_dict', 'in', ['monthly', 'quarter', 'half', 'year'])])
year, month = int(self.select_year), int(self.select_month)
@@ -88,7 +147,8 @@ class PropertyRentalWizard(models.Model):
is_year = 1
# 获取租金乘数(1 表示按月,3 表示季租金,6 表示半年租金,年后面赋值)
multiplier = self.get_multiplier(record.cycle_dict)
-
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)
+