添加功能

This commit is contained in:
李鹏宇
2025-11-28 20:14:29 +08:00
parent 3d4006ccea
commit 5e9e011f6e
2 changed files with 32 additions and 7 deletions
@@ -1,6 +1,7 @@
from odoo import models, fields, api, _, SUPERUSER_ID
from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
from datetime import datetime, timedelta, date
class AccountsWizard(models.Model):
@@ -9,7 +10,7 @@ class AccountsWizard(models.Model):
accounts_id = fields.Many2one('property.accounts.receivable', string='对账单')
def invalid(self):
receivable_log = (f'当前登录人{self.env.user.name}于{fields.Datetime.now()}将物业为 {self.accounts_id.property_id.name}的应收账单状态修改为作废')
receivable_log = (f'当前登录人{self.env.user.name}于{fields.Datetime.now()}将物业为 {self.accounts_id.property_name}的应收账单状态修改为作废')
for record in self.accounts_id:
original_log = record.receivable_log or ''
if original_log:
@@ -23,7 +24,7 @@ class AccountsWizard(models.Model):
# 激活
def suspend(self):
receivable_log = (
f'当前登录人{self.env.user.name}于{fields.Datetime.now()}将物业为 {self.accounts_id.property_id.name}的应收账单挂起')
f'当前登录人{self.env.user.name}于{fields.Datetime.now()}将物业为 {self.accounts_id.property_name}的应收账单挂起')
for record in self.accounts_id:
original_log = record.receivable_log or ''
if original_log:
@@ -35,7 +36,7 @@ class AccountsWizard(models.Model):
# 挂起
def unsuspend(self):
receivable_log = (
f'当前登录人{self.env.user.name}于{fields.Datetime.now()}将物业为 {self.accounts_id.property_id.name}的应收账单取消挂起')
f'当前登录人{self.env.user.name}于{fields.Datetime.now()}将物业为 {self.accounts_id.property_name}的应收账单取消挂起')
for record in self.accounts_id:
original_log = record.receivable_log or ''
if original_log:
@@ -56,8 +57,31 @@ class AccountsWizard(models.Model):
}
for rec in self.accounts_id:
model_type = model_type_data.get(rec.management_type_id.name)
if model_type:
model_id = self.env[model_type].search([('contract_id', '=', rec.contract_id.id)])
if model_id:
model_id.write({'is_push': False})
if rec.management_type_id.name == '违约金':
rec.unlink()
continue
if model_type in ('meter.archives.line', 'meter.water.line'):
year = rec.due_date_end.year
month = rec.due_date_end.month
first_day = date(year, month, 1)
if month == 12:
next_month_first_day = date(year + 1, 1, 1)
else:
next_month_first_day = date(year, month + 1, 1)
last_day = next_month_first_day - timedelta(days=1)
model_id = self.env[model_type].search([
('contract_id', '=', rec.contract_id.id),
('meter_date', '>=', first_day),
('meter_date', '<=', last_day)
])
else:
last_day = rec.due_date + relativedelta(months=1) - timedelta(days=1)
model_id = self.env[model_type].search([
('contract_id', '=', rec.contract_id.id),
('due_date', '>=', rec.due_date),
('due_date', '<=', last_day)
])
if model_id:
model_id.write({'is_push': False})
rec.unlink()
@@ -122,6 +122,7 @@ class PropertyReconciliationWizard(models.Model):
if to_delete:
rec.reconciliation_line_ids = to_delete
rec._compute_receivable_total()
@api.onchange('actual_total')
def compute_reconciliation_line_ids(self):