添加功能

This commit is contained in:
李鹏宇
2025-11-28 17:33:52 +08:00
parent 8b751873aa
commit 2e5af8a16b
@@ -256,28 +256,28 @@ class PropertyBankStatements(models.Model):
def revocation(self):
self.ensure_one()
current_rec = self[0]
if current_rec.bank_state == 'reconciled':
domain = [
('your_own_unit', '=', current_rec.your_own_unit),
('bank_state', '=', 'reconciled'),
('name_account', '=', current_rec.name_account)
]
same_group_records = self.env[self._name].search(domain)
if same_group_records:
# 按start_time倒序排序,找到最近的记录
sorted_records = sorted(
same_group_records,
key=lambda r: r.start_time or '',
reverse=True
)
latest_record = sorted_records[0]
# 检查当前记录是否是最近的一条
if current_rec.id != latest_record.id:
raise UserError(
f"只能从最近的记录开始撤销!\n"
f"当前记录时间: {current_rec.start_time + timedelta(hours=8)}\n"
f"最近记录时间: {latest_record.start_time + timedelta(hours=8)}"
)
# if current_rec.bank_state == 'reconciled':
# domain = [
# ('your_own_unit', '=', current_rec.your_own_unit),
# ('bank_state', '=', 'reconciled'),
# ('name_account', '=', current_rec.name_account)
# ]
# same_group_records = self.env[self._name].search(domain)
# if same_group_records:
# # 按start_time倒序排序,找到最近的记录
# sorted_records = sorted(
# same_group_records,
# key=lambda r: r.start_time or '',
# reverse=True
# )
# latest_record = sorted_records[0]
# # 检查当前记录是否是最近的一条
# if current_rec.id != latest_record.id:
# raise UserError(
# f"只能从最近的记录开始撤销!\n"
# f"当前记录时间: {current_rec.start_time + timedelta(hours=8)}\n"
# f"最近记录时间: {latest_record.start_time + timedelta(hours=8)}"
# )
for modify in self.receivable_modify_ids:
if modify.is_write: