diff --git a/yuthon_hr_attendance/models/yuthon_duty_plan.py b/yuthon_hr_attendance/models/yuthon_duty_plan.py
index 17b16dd5f..b7d30e077 100644
--- a/yuthon_hr_attendance/models/yuthon_duty_plan.py
+++ b/yuthon_hr_attendance/models/yuthon_duty_plan.py
@@ -63,6 +63,7 @@ class YuthonDutyPlan(models.Model):
next_next_year = next_year
next_next_month = next_month + 1
last_day_of_month = datetime(next_next_year, next_next_month, 1)
+
role_a = self.env['planning.role'].search([('name', '=', '联安粮库')], limit=1)
role_template_a = self.env['planning.slot.template'].search([('planning_name', '=', '白班'), ('role_id', '=', role_a.id)])
role_template_b = self.env['planning.slot.template'].search([('planning_name', '=', '白值'), ('role_id', '=', role_a.id)])
diff --git a/yuthon_property/models/property_management_list.py b/yuthon_property/models/property_management_list.py
index 3692bc2a8..796862305 100644
--- a/yuthon_property/models/property_management_list.py
+++ b/yuthon_property/models/property_management_list.py
@@ -6,8 +6,8 @@ class PropertyManagementList(models.Model):
_description = '物业费管理列表'
contract_code = fields.Char(string='合同编号')
- property_id = fields.Many2one('yuthon.property', string='物业')
- admin_id = fields.Many2one(related='property_id.admin_id', string="片区管理员", store=True)
+ property_ids = fields.Many2many('yuthon.property', string='物业')
+ admin_id = fields.Many2one('res.users', string="片区管理员", store=True, compute="_compute_admin_id")
lessee_id = fields.Many2one('property.tenant.information', string='承租方')
due_date = fields.Date(string='应收日期')
message_standard_id = fields.Many2one('property.message.fee', string="管理费标准")
@@ -17,6 +17,15 @@ class PropertyManagementList(models.Model):
remarks = fields.Text(string='备注')
is_push = fields.Boolean(string='是否推送')
+ @api.depends('property_ids')
+ def _compute_admin_id(self):
+ for record in self:
+ record.admin_id = record.property_ids[0].admin_id
+
+ def push_management(self):
+ rec = self.env['property.management.list'].search([('is_push', '=', False)])
+ rec.is_push = True
+
def get_no_read_count(self):
return self.search_count([('is_push', '=', False)])
diff --git a/yuthon_property/views/property_management_list_views.xml b/yuthon_property/views/property_management_list_views.xml
index f6a844538..12c1ad417 100644
--- a/yuthon_property/views/property_management_list_views.xml
+++ b/yuthon_property/views/property_management_list_views.xml
@@ -5,7 +5,7 @@
property.management.list
-
+
diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py
index 6b02fc6c7..6bc2db38e 100644
--- a/yuthon_property_approval/models/inherit_yuthon_property.py
+++ b/yuthon_property_approval/models/inherit_yuthon_property.py
@@ -776,39 +776,39 @@ class PropertyAccountsReceivable(models.Model):
else:
receivable.payout_date = receivable.due_date
- @api.model_create_multi
- def create(self, vals_list):
- records = super().create(vals_list)
- for record in records:
- if record.lessee_id and record.contract_id:
- lease_address_ids = record.contract_id.lease_ids.mapped('address_id.id')
- property_ids_value = [(6, 0, lease_address_ids)] if lease_address_ids else [(6, 0, [])]
- statements = self.env['property.bank.statements'].search([
- ('name_account', '=', record.lessee_id.name),
- ('bank_state', '=', 'not_reconciled'),
- ])
- contract_id_value = [(4, record.contract_id.id)] if record.contract_id else []
- for statement in statements:
- statement.write({
- 'property_ids': property_ids_value,
- 'contract_ids': contract_id_value,
- })
-
- contract_account_map = {}
- for vals in vals_list:
- if 'contract_id' in vals and vals['contract_id']:
- contract_id = vals['contract_id']
- if contract_id not in contract_account_map:
- contract_account = self.env['contract.accounts.receivable'].search([
- ('contract_id', '=', contract_id)
- ], limit=1)
- if not contract_account:
- contract_account = self.env['contract.accounts.receivable'].create({
- 'contract_id': contract_id
- })
- contract_account.onchange_contract_id()
-
- return records
+ # @api.model_create_multi
+ # def create(self, vals_list):
+ # records = super().create(vals_list)
+ # for record in records:
+ # if record.lessee_id and record.contract_id:
+ # lease_address_ids = record.contract_id.lease_ids.mapped('address_id.id')
+ # property_ids_value = [(6, 0, lease_address_ids)] if lease_address_ids else [(6, 0, [])]
+ # statements = self.env['property.bank.statements'].search([
+ # ('name_account', '=', record.lessee_id.name),
+ # ('bank_state', '=', 'not_reconciled'),
+ # ])
+ # contract_id_value = [(4, record.contract_id.id)] if record.contract_id else []
+ # for statement in statements:
+ # statement.write({
+ # 'property_ids': property_ids_value,
+ # 'contract_ids': contract_id_value,
+ # })
+ #
+ # contract_account_map = {}
+ # for vals in vals_list:
+ # if 'contract_id' in vals and vals['contract_id']:
+ # contract_id = vals['contract_id']
+ # if contract_id not in contract_account_map:
+ # contract_account = self.env['contract.accounts.receivable'].search([
+ # ('contract_id', '=', contract_id)
+ # ], limit=1)
+ # if not contract_account:
+ # contract_account = self.env['contract.accounts.receivable'].create({
+ # 'contract_id': contract_id
+ # })
+ # contract_account.onchange_contract_id()
+ #
+ # return records
@api.onchange('penalty_date')
def _onchange_penalty_date(self):
@@ -867,7 +867,8 @@ class PropertyAccountsReceivable(models.Model):
'水费': 'meter.water.line',
'电费': 'meter.archives.line',
'押金': 'property.deposit.list',
- '租金': 'property.rent.list'
+ '租金': 'property.rent.list',
+ '管理费': 'property.management.list',
}
archives_ids = self.env["property.accounts.receivable"].browse(
self._context.get('active_ids', self._context.get('active_id')))
@@ -1081,9 +1082,15 @@ class PropertyManagementList(models.Model):
_inherit = 'property.management.list'
contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批")
+ property_name = fields.Text(string='物业', compute="_compute_property_name")
company_id = fields.Many2one(related='contract_id.lessor_id', string="出租方公司", store=True)
tenure_type = fields.Selection(related='contract_id.tenure_type', string="权属类型", store=True)
+ @api.depends('contract_id')
+ def _compute_property_name(self):
+ for record in self:
+ record.property_name = record.contract_id.property_name
+
def push_management(self):
for rec in self:
management_type_id = self.env['yuthon.management.type'].search([('name', '=', '管理费')], limit=1)
diff --git a/yuthon_property_approval/views/inherit_yuthon_property_views.xml b/yuthon_property_approval/views/inherit_yuthon_property_views.xml
index b9a97b6c0..7bdc54b4c 100644
--- a/yuthon_property_approval/views/inherit_yuthon_property_views.xml
+++ b/yuthon_property_approval/views/inherit_yuthon_property_views.xml
@@ -346,6 +346,7 @@
+
@@ -355,7 +356,7 @@
property.management.list
-
+
@@ -365,7 +366,7 @@
-
+
diff --git a/yuthon_property_approval/wizard/penalty_line_wizard.py b/yuthon_property_approval/wizard/penalty_line_wizard.py
index 4221c39f9..f676aba38 100644
--- a/yuthon_property_approval/wizard/penalty_line_wizard.py
+++ b/yuthon_property_approval/wizard/penalty_line_wizard.py
@@ -94,11 +94,9 @@ class PenaltyLineWizard(models.Model):
if is_penalty:
penalty_pay_count += 1
current_idx = penalty_pay_count
- type_name = "违约金"
else:
rent_pay_count += 1
current_idx = rent_pay_count
- type_name = "租金"
pay_year = pay_date.year
pay_month = pay_date.month
@@ -124,14 +122,14 @@ class PenaltyLineWizard(models.Model):
new_penalty_lines.append((0, 0, {
'date': pay_date,
- 'remake': f'支付租金¥{pay_line.amount}',
+ 'remake': f'支付金额¥{pay_line.amount}',
'days_overdue': days_overdue,
'remaining_principal': remaining_principal,
'penalty': round(current_penalty, 2),
}))
management_type = penalty_type if is_penalty else rent_type
- pay_remake = f'第{current_idx}次支付{type_name},金额:¥{pay_amount}'
+ pay_remake = f'第{current_idx}次支付金额:¥{pay_amount}'
new_pay_lines.append((0, 0, {
'date': pay_date,
'amount': pay_amount,
diff --git a/yuthon_property_approval/wizard/property_rental_wizard.py b/yuthon_property_approval/wizard/property_rental_wizard.py
index dea4913fb..3661d560f 100644
--- a/yuthon_property_approval/wizard/property_rental_wizard.py
+++ b/yuthon_property_approval/wizard/property_rental_wizard.py
@@ -107,57 +107,54 @@ class PropertyRentalWizard(models.Model):
"""封装创建管理费记录的逻辑"""
first_day_of_month = start_date.replace(day=1)
last_day_of_month = first_day_of_month + relativedelta(months=1) - timedelta(days=1)
+ management_id = self.env['property.management.list'].search([
+ ('contract_id', '=', record.id),
+ ('due_date', '>=', first_day_of_month),
+ ('due_date', '<=', last_day_of_month)
+ ])
+ total_original_amount = 0
+ if record.contract_sort not in ['guanggao', 'guanzi', 'room']:
+ for lease_id in record.lease_ids:
+ standard_amount = lease_id.message_standard_id.amount or 0.0
+ property_area = lease_id.property_area or 0.0
+ total_original_amount += int(round(property_area * standard_amount))
+ else:
+ total_original_amount = rent_amount
+
+ has_valid_property = False
for lease_id in record.lease_ids:
property_id = lease_id.address_id
- management_id = self.env['property.management.list'].search([
- ('contract_id', '=', record.id),
- ('due_date', '>=', first_day_of_month),
- ('due_date', '<=', last_day_of_month)
- ])
- matched_info = self.env['manage.information.line']
- if record.contract_sort in ['guanggao','guanzi', 'room']:
- original_amount = rent_amount
+ if property_id and property_id.message_standard_id:
+ has_valid_property = True
+ break
+
+ is_special_contract = record.contract_sort in ['guanggao', 'guanzi', 'room']
+ if (not is_special_contract and has_valid_property) or is_special_contract:
+ area_value = sum(
+ lease_id.property_area or 0.0
+ for lease_id in record.lease_ids
+ if record.lease_ids
+ )
+ if not management_id:
+ self.sudo().env["property.management.list"].create({
+ "contract_id": record.id,
+ "area":area_value,
+ 'property_ids': [(6, 0, [lease_id.address_id.id for lease_id in record.lease_ids if lease_id.address_id])],
+ 'original_amount':total_original_amount,
+ 'message_standard_id': record.lease_ids[0].message_standard_id.id,
+ 'lessee_id': record.lessee_id.id,
+ "due_date":start_date
+ })
else:
- original_amount = 0
- standard_id = property_id.message_standard_id
- target_month_first_day = start_date.replace(day=1)
- target_month_last_day = target_month_first_day + relativedelta(months=1) - relativedelta(
- days=1)
- matched_info = self.env['manage.information.line'].search([
- ('yuthon_property_id', '=', property_id.id),
- ('start_time', '<=', target_month_last_day),
- '|',
- ('end_date', '>=', target_month_first_day),
- ('end_date', '=', False)
- ], limit=1)
-
- if matched_info:
- original_amount = int(round(matched_info.management_area * standard_id.amount))
-
- is_special_contract = record.contract_sort in ['guanggao', 'guanzi', 'room']
- has_valid_property_info = property_id.manage_information_ids and property_id.message_standard_id
- if (not is_special_contract and has_valid_property_info) or is_special_contract:
- area_value = matched_info.management_area if matched_info else 0
- if not management_id:
- self.sudo().env["property.management.list"].create({
- "contract_id": record.id,
- "property_id": property_id.id,
- "area":area_value,
- 'original_amount':original_amount,
- 'message_standard_id': property_id.message_standard_id.id,
- 'lessee_id': record.lessee_id.id,
- "due_date":start_date
- })
- else:
- management_id.write({
- "contract_id": record.id,
- "property_id": property_id.id,
- "area": area_value,
- 'original_amount': original_amount,
- 'message_standard_id': property_id.message_standard_id.id,
- 'lessee_id': record.lessee_id.id,
- "due_date": start_date
- })
+ management_id.write({
+ "contract_id": record.id,
+ "area": area_value,
+ 'property_ids': [(6, 0, [lease_id.address_id.id for lease_id in record.lease_ids if lease_id.address_id])],
+ 'original_amount': total_original_amount,
+ 'message_standard_id': record.lease_ids[0].message_standard_id.id,
+ 'lessee_id': record.lessee_id.id,
+ "due_date": start_date
+ })
def process_rent_record(self, record, rent_id, date_field_year_month, multiplier=1):
"""封装处理租金逻辑,增加 multiplier 参数用于乘法"""