Public release from ruodoo-project: 19.0 - 2026-07-26 21:17:35 UTC
This commit is contained in:
32
directive_layer/wizard/directive_delete_wizard.py
Normal file
32
directive_layer/wizard/directive_delete_wizard.py
Normal file
@ -0,0 +1,32 @@
|
||||
from odoo import fields, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class DirectiveDeleteWizard(models.TransientModel):
|
||||
_name = "directive.delete.wizard"
|
||||
_description = "Directive Delete Wizard"
|
||||
|
||||
mode = fields.Selection(
|
||||
[
|
||||
("archive", "Мягкое удаление (архивировать)"),
|
||||
("delete", "Полное удаление (unlink)"),
|
||||
],
|
||||
string="Режим",
|
||||
required=True,
|
||||
default="archive",
|
||||
)
|
||||
|
||||
def action_confirm(self):
|
||||
active_model = self.env.context.get("active_model")
|
||||
active_id = self.env.context.get("active_id")
|
||||
if not active_model or not active_id:
|
||||
raise UserError("No active record in context.")
|
||||
record = self.env[active_model].browse(active_id).exists()
|
||||
if not record:
|
||||
return {"type": "ir.actions.act_window_close"}
|
||||
|
||||
if self.mode == "archive":
|
||||
record._action_archive()
|
||||
else:
|
||||
record._action_delete_hard()
|
||||
return {"type": "ir.actions.act_window_close"}
|
||||
Reference in New Issue
Block a user