Hello friends,
I would like to display a confirm message with a dynamic text ( adding some fields values ) from a method in Python.
I have tried to show my dynamic text in warning message, but i don't know how to make it in confirm message (with Yes/No):
warning_message = "Distributeur " + str(self.distributeur) + "\n products :" + str(self.pack_ref)
raise RedirectWarning(warning_message, True, (warning_message))
Any solution please?
Instead of returning a warning return a wizard with two buttons. One to confirm and other to cncel
I tried that but the problem is when i click in the confirmation button from the wizard, my function can't execute :
class Wizard_confirmation(models.TransientModel):
_name = "affichage2.wizard_confirmation"
@api.multi
def call_vente(self):
self.env["affichage2.vente_packs"].vendre_cap()
And this is my principal function which was called from the wizard class :
class Vente_pack_distr(models.Model):
_name = 'affichage2.vente_packs'
pack_ref = fields.Many2many('affichage2.pack_stock', string="Numéro de série de pack", required=True,
domain=['&', ('vente', '=', None), ('approved_by', '=', None)])
pack_ref2 = fields.Many2many('affichage2.pack_stock', string="Numéro de série de pack")
distributeur = fields.Many2one('res.users', 'Vendu à Distributeur')
vendeur = fields.Many2one('res.users', 'vendeur')
date_vente = fields.Char(string="Date de vente au distributeur", required=False)
zone_text = fields.Text(string="Zone", required=False)
@api.multi
def call_confirmation_wizard(self):
return {
'name': 'Confirmation',
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'affichage2.wizard_confirmation',
#'res_id': self.id,
#'view_id': self.env.ref("affichage2.confirm_wizard_form").id,
'view_id': False,
'target': 'new',
'nodestroy': True,
}
@api.multi
def vendre_cap(self):
pack_ref2 = self.pack_ref
self.date_vente = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
self.vendeur = self.env['res.users'].search([('id', '=', self.env.uid)])
#self.write({'date_vente': datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")})
#self.write({'vendeur': self.env['res.users'].search([('id', '=', self.env.uid)])})
# change default value to vendu
instance_of_needed_model = self.env['affichage2.pack_stock'].browse(self.pack_ref.id)
instance_of_needed_model.write({'status': 'Vendu'})
# Changer pour chaque capture son distributeur qui a l'acheter
##############################################################
listo3 = list(self.pack_ref)
# chercher les captures qui ont le meme id que dans la relation many2many
for element in listo3:
rec = self.env['affichage2.pack_stock'].search([('id', '=', element.id)])
rec.vente = self.distributeur
#warning_message2 = "Distributeur " + str(self.distributeur) + "\n products :" + str(self.pack_ref)
try this: https://learnopenerp.blogspot.com/2017/12/how-to-display-confirmation-display-box.html