跳至內容
選單
此問題已被標幟
637 瀏覽次數

how to confirmation before create a patient in odoo using wizard to view in xml, i give my code for model and wizard


hms_patient.py (model)

@api.model

hms.patient model

def create(self, vals):

if self.env.context.get('confirm_creation'):

return super(HmsAppointment, self).create(vals)

else:

return self._call_wizard(vals)


def _call_wizard(self, vals):

context = dict(self.env.context or {})

context['default_create_vals'] = vals


return {

'name': _("Confirmation"),

'view_mode': 'form',

'res_model': 'confirmation.warning',

'type': 'ir.actions.act_window',

'target': 'new',

'context': context,

}


confirmation_warning .py (wizard)
from odoo import fields, models, api

class ConfirmationWarning(models.TransientModel):

_name = "confirmation.warning"

_description = "Confirmation Wizard"


message = fields.Char(string="Message", default="Are you sure you want to save this record?")


def action_confirm(self):

create_vals = self.env.context.get('default_create_vals', {})

if create_vals:

self.env['hms.patient'].with_context(confirm_creation=True).create(create_vals)

return {'type': 'ir.actions.act_window_close'}


def action_cancel(self):

return {'type': 'ir.actions.act_window_close'}


xml (view)

confirmation.warning.wizard.form

confirmation.warning




頭像
捨棄