(self)
return {
            "type": "ir.actions.act_window",
            "res_model": self._name,
            "view_mode": "form",
            "view_id": [data_obj.id],
            "res_id": self.id,
            "target": "new",
        }
Action that exports the data into a BOE formatted text file.

        @return: Action dictionary for showing exported file.
Action that exports the data into a BOE formatted text file.
Action that exports the data into a BOE formatted text file .
def action_get_file(self):
        """Action that exports the data into a BOE formatted text file.

        @return: Action dictionary for showing exported file.
        """
        active_id = self.env.context.get("active_id", False)
        active_model = self.env.context.get("active_model", False)
        if not active_id or not active_model:
            return False
        report = self.env[active_model].browse(active_id)
        contents = b""
        if report.export_config_id:
            contents += self.action_get_file_from_config(report)
        else:
            raise exceptions.UserError(_("No export configuration selected."))
        # Generate the file and save as attachment
        file = base64.encodebytes(contents)
        file_name = _("%s_report_%s.txt") % (report.number, fields.Date.today())
        # Delete old files
        attachment_obj = self.env["ir.attachment"]
        attachment_ids = attachment_obj.search(
            [("name", "=", file_name), ("res_model", "=", report._name)]
        )
        attachment_ids.unlink()
        attachment_obj.create(
            {
                "name": file_name,
                "datas": file,
                "res_model": report._name,
                "res_id": report.id,
            }
        )
        self.write({"state": "get", "data": file, "name": file_name})
        # Force view to be the parent one
        data_obj = self.env.ref("l10n_es_aeat.wizard_aeat_export")
        # TODO: Permitir si se quiere heredar la vista padre
        return {
            "type": "ir.actions.act_window",
            "res_model": self._name,
            "view_mode": "form",
            "view_id": [data_obj.id],
            "res_id": self.id,
            "target": "new",
        }
def action_get_file ( self ) : active_id = self . env . context . get ( "active_id" , False ) active_model = self . env . context . get ( "active_model" , False ) if not active_id or not active_model : return False report = self . env [ active_model ] . browse ( active_id ) contents = b"" if report . export_config_id : contents += self . action_get_file_from_config ( report ) else : raise exceptions . UserError ( _ ( "No export configuration selected." ) ) # Generate the file and save as attachment file = base64 . encodebytes ( contents ) file_name = _ ( "%s_report_%s.txt" ) % ( report . number , fields . Date . today ( ) ) # Delete old files attachment_obj = self . env [ "ir.attachment" ] attachment_ids = attachment_obj . search ( [ ( "name" , "=" , file_name ) , ( "res_model" , "=" , report . _name ) ] ) attachment_ids . unlink ( ) attachment_obj . create ( { "name" : file_name , "datas" : file , "res_model" : report . _name , "res_id" : report . id , } ) self . write ( { "state" : "get" , "data" : file , "name" : file_name } ) # Force view to be the parent one data_obj = self . env . ref ( "l10n_es_aeat.wizard_aeat_export" ) # TODO: Permitir si se quiere heredar la vista padre return { "type" : "ir.actions.act_window" , "res_model" : self . _name , "view_mode" : "form" , "view_id" : [ data_obj . id ] , "res_id" : self . id , "target" : "new" , }