Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion base_cancel_confirm/model/base_cancel_confirm.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class BaseCancelConfirm(models.AbstractModel):
copy=False,
help="An optional cancel reason",
)
cancel_by = fields.Many2one(
comodel_name="res.users",
copy=False,
)
cancel_date = fields.Date(copy=False)

def _cancel_confirm_disabled(self):
key = f"{self._name}.cancel_confirm_disable"
Expand All @@ -50,7 +55,14 @@ def open_cancel_confirm_wizard(self):
return action

def clear_cancel_confirm_data(self):
self.write({"cancel_confirm": False, "cancel_reason": False})
self.write(
{
"cancel_confirm": False,
"cancel_reason": False,
"cancel_by": False,
"cancel_date": False,
}
)

def get_view(self, view_id=None, view_type="form", **options):
res = super().get_view(view_id=view_id, view_type=view_type, **options)
Expand Down
2 changes: 2 additions & 0 deletions base_cancel_confirm/views/cancel_confirm_template.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<div>
<group colspan="4" attrs="{'invisible':[('cancel_reason', '=', False)]}">
<field name="cancel_confirm" invisible="1" />
<field name="cancel_by" readonly="1" />
<field name="cancel_date" readonly="1" />
<field name="cancel_reason" readonly="1" />
</group>
</div>
Expand Down
8 changes: 7 additions & 1 deletion base_cancel_confirm/wizard/cancel_confirm.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ def confirm_cancel(self):
docs.write({"cancel_confirm": True})
# Cancel Reason
if self.has_cancel_reason in ["optional", "required"]:
docs.write({"cancel_reason": self.cancel_reason})
docs.write(
{
"cancel_reason": self.cancel_reason,
"cancel_by": self.env.user,
"cancel_date": fields.Date.context_today(self),
}
)
res = getattr(docs, cancel_method)()
return res