Skip to Content
Menu
This question has been flagged
1 Reply
8260 Views

   As normal button can add confirm info as

 <button name="lock" string="lock" type="object"  confirm="Are you sure you want to lock this record?"/>

So how should I do this action on "save button" to let web pop-up a dialog box  before I confirm.    Or is there any w​ay to  pop-up dialog box to let me confirm after I clicked "save button",I  try to use code as follow:

@api.constrains('data_file', 'filename', 'chip_type')
def get_data(self):
    self.show_dialog()
    do something...

def show_dialog(self)
return {'warning': {

'title': "confirm",
'message': "Are u sure u want to save the record?",
}, 
}                       

  But the dialog did't show after I clicked 'save button',it seems only using @api.onchange with show_dialog   function works,so how should I change my code?

  Thanks a lot.

                              


Avatar
Discard
Best Answer

please override the create function and do the needful.

Avatar
Discard

just sample

from odoo import models, fields, api

class res_partner(models.Model):

_inherit = 'res.partner'

passed_override_write_function = fields.Boolean(string='Has passed our super method')

@api.model

def create(self, values):

# Override the original create function for the res.partner model

record = super(res_partner, self).create(values)

# Change the values of a variable in this super function

record['passed_override_write_function'] = True

print 'Passed this function. passed_override_write_function value: ' + str(record['passed_override_write_function'])

# Return the record so that the changes are applied and everything is stored.

return record