I added a wizard model with 2 buttons 'cancel' and 'confirm' ; in the function 'button_validate' in 'stock.picking' model , I want to generate this wizard if quantity_done > product_uom_qty , the function cancel will execute the buttton_validate. When clicking on confirm button I want to continue execute the rest of function 'button_validate', how can I do it using context ?Any help please??
class Wizard(models.TransientModel):
_name = 'wizard.wizard'
def confirm(self):
active_id = self.env['stock.picking'].browse(self.env.context.get('active_id', False))
def cancel(self):
picking_id = self.env['stock.picking'].browse(self.env.context.get('active_id', False))
picking_id.button_validate
class Picking(models.Model): _inherit = "stock.picking" def button_validate(self, is_active_id=False): # Clean-up the context key at validation to avoid forcing the creation of immediate # transfers. ctx = dict(self.env.context) ctx.pop('default_immediate_transfer', None) self = self.with_context(ctx) # Sanity checks. pickings_without_moves = self.browse() pickings_without_quantities = self.browse() pickings_without_lots = self.browse() products_without_lots = self.env['product.product'] for picking in self: for move in picking.move_ids_without_package: if move.quantity_done > move.product_uom_qty: action = self.env["ir.actions.actions"]._for_xml_id("my_module.action_of_my_wizard") return action if not picking.move_lines and not picking.move_line_ids: pickings_without_moves |= picking picking.message_subscribe([self.env.user.partner_id.id]) picking_type = picking.picking_type_id ........